Skip to main content

Flatpages based on files with yaml syntax

Project description

Install

pip install yamlpage

Usage

>>> import os
>>> from yamlpage import YamlPage
>>> p = YamlPage('./content')

Put page

>>> url = '/my/url'
>>> p.put(url, (
...     ('title', 'foo'),
...     ('body', 'foo\nbar'),
... ))
>>> path = './content/^my^url.yaml'
>>> content = open(path).read()
>>> print(content)
title: foo
body: |-
    foo
    bar
<BLANKLINE>

Get page

>>> p.get(url) == {'body': 'foo\nbar', '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

Project details


Release history Release notifications

This version
History Node

3.1.1

History Node

3.1.0

History Node

3.0.0

History Node

2.1.0

History Node

2.0.1

History Node

2.0.0

History Node

1.0.2

History Node

1.0.1

History Node

1.0.0

History Node

0.1.1

History Node

0.1.0

History Node

0.0.6

History Node

0.0.5

History Node

0.0.4

History Node

0.0.3

History Node

0.0.2

History Node

0.0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
yamlpage-3.1.1.tar.gz (3.7 kB) Copy SHA256 hash SHA256 Source None Aug 7, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page