Install
pip install yamlpage
Usage
>>> import os
>>> from yamlpage import YamlPage, SingleFolderBackend, MultiFolderBackend
>>> p = YamlPage('./content')
Put page
>>> url = '/my/url' >>> p.put(url, ( ... ('title', 'foo'), ... ('body|md', '- foo\n- bar'), ... ))>>> path = './content/^my^url.yaml' >>> content = open(path).read() >>> print(content) title: foo body|md: |- - foo - bar <BLANKLINE>
Get page
>>> p.get(url) == {'body|md': '- foo\n- bar', 'title': 'foo'} True>>> p.get('/not/found/') is None True
Check if page exists
>>> p.exists(url)
True
>>> p.exists('/not/found/')
False
Built in backends
SingleFolderBackend (default) maps ‘my/url’ to filename ‘my^url.yaml’
>>> p = YamlPage('./content')
>>> p.put('single/folder/backend', 'data')
>>> os.path.exists('./content/single^folder^backend.yaml')
True
MultiFolderBackend maps ‘my/url’ to filename ‘my/url.yaml’
>>> p = YamlPage('./content', backend=MultiFolderBackend)
>>> p.put('multi/folder/backend', 'data')
>>> os.path.exists('./content/multi/folder/backend.yaml')
True
Filters
You can automaticaly apply filters to a particular page fields. As an example let’s render body markdown to html.
>>> import misaka
>>> p = YamlPage('./content', filters={"md": misaka.html})
>>> p.get(url)["body"] == '<ul>\n<li>foo</li>\n<li>bar</li>\n</ul>\n'
True
Release files for yamlpage 3.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| yamlpage-3.2.0.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yamlpage-3.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.6 kB
Release files / yamlpage-3.2.0.tar.gz
| Download URL | yamlpage-3.2.0.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b526f40de803b6bc33734a9d72728f5ed6f604395521aafa1e33f4f6e2cb1f0d
|
|
BLAKE2b-256 checksum How to use checksums |
fdd25d6d239758418832845bb93796ff68cbfda589b562d76dd3e59248844b35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|
Release files / yamlpage-3.2.0-py3-none-any.whl
| Download URL | yamlpage-3.2.0-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cbfd84158d25f04d36fc490e1298ba875ab37b857143ff93090bc838a6576ba1
|
|
BLAKE2b-256 checksum How to use checksums |
45cdf92ecc2a13c8185052860ab885333a2a8ae9c4a3a9251bdd37879b0dde83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2
|