Persistent memory for small values, set and get in a single function. If you set a value, it returns whether the new value is different to the previous.
>>> memoize("Foo", 1)
False
>>> memoize("Foo", 1)
True
>>> memoize("Foo", 2)
False
>>> memoize("Foo")
2
| Parameters: |
|
|---|
Takes a list of dictionaries and performs union of each. Can take additional key=values as parameters to overwrite or add key/value-pairs. No side-effects,
Creates entry in filesystem. Overwrite only if fileobj differs.
| Parameters: |
|
|---|
Substitutes/expands URL parameters beginning with a colon.
| Parameters: |
|
|---|
>>> expand('/:year/:slug/', {'year': 2012, 'slug': 'awesome title'})
'/2011/awesome-title/'
Joins multiple urls pieces to one single URL without loosing the root (first element). If the URL ends with a slash, Acrylamid automatically appends index.html.
>>> joinurl('/hello/', '/world/')
'/hello/world/index.html'
Generates an ASCII-only slug. Borrowed from http://flask.pocoo.org/snippets/5/
Yields a triple ((next, current, previous), list of entries, has changed) of a paginated entrylist. It will first filter by the specified function, then split the ist into several sublists and check wether the list or an entry has changed.
| Parameters: |
|
|---|
>>> for x, values, _, paginate(entryrange(20), 6, orphans=2):
... print x, values
(None, 0, 1), [entries 1..6]
(0, 1, 2), [entries 7..12]
(1, 2, None), [entries 12..20]
Safe string to fit in to the YAML standard (hopefully). Counterpart to acrylamid.readers.unsafe().
A simple front-end to python’s horrible Popen-interface which lets you run a single shell command (only one, semicolon and && is not supported by os.execvp(). Does not catch OSError!
| Parameters: |
|
|---|
This helper class provides an easy mechanism to give user feedback of created, changed or deleted files. As side-effect every it allows you to register your own functions to these events.
Acrylamid has the following, fairly self-explanatory events: create, update, skip, identical and remove. A callback receives the current namespace and the path. The namespace might be None if not specified by the originator, but it is recommended to achieve a informal standard:
- the views supply their lowercase name such as 'entry' or 'archive' as namespace.
- asset generation uses the 'assets' namespace.
- the init, import and new task use their name as namespace.
To make this clear, the following example just records all newly created items from the entry view:
from acrylamid.hepers import event
skipped = []
def callback(ns, path):
if ns == 'entry':
skipped.add(path)
event.register(callback, to=['create'])
Note
This class is a singleton and should not be initialized
| Parameters: | event (string) – count calls of this particular event |
|---|
Register a callback to a list of events. Everytime the event eventuates, your callback gets called with all arguments of this particular event handler.
| Parameters: |
|
|---|
Return the given string after chopping of a substring from the end.
| Parameters: |
|
|---|
Import and initialize modules from directories list.
| Parameters: |
|
|---|