Skip to main content

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)

Source distribution for yamlpage 3.2.0
File Size Uploaded
yamlpage-3.2.0.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yamlpage 3.2.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

3.2.0 This release

2 release files

3.1.4

2 release files

3.1.2

2 release files

3.1.1

1 release file

3.1.0

1 release file

3.0.0

1 release file

2.1.0

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page