lucidity¶
-
lucidity.discover_templates(paths=None, recursive=True)[source]¶ Search paths for mount points and load templates from them.
paths should be a list of filesystem paths to search for mount points. If not specified will try to use value from environment variable
LUCIDITY_TEMPLATE_PATH.A mount point is a Python file that defines a ‘register’ function. The function should return a list of instantiated
Templateobjects.If recursive is True (the default) then all directories under a path will also be searched.
-
lucidity.parse(path, templates)[source]¶ Parse path against templates.
path should be a string to parse.
templates should be a list of
Templateinstances in the order that they should be tried.Return
(data, template)from first successful parse.Raise
ParseErrorif path is not parseable by any of the supplied templates.
-
lucidity.format(data, templates)[source]¶ Format data using templates.
data should be a dictionary of data to format into a path.
templates should be a list of
Templateinstances in the order that they should be tried.Return
(path, template)from first successful format.Raise
FormatErrorif data is not formattable by any of the supplied templates.