Template(name, pattern, anchor=1, default_placeholder_expression='[\w_.\-]+', duplicate_placeholder_mode=1, template_resolver=None)¶
__init__(name, pattern, anchor=1, default_placeholder_expression='[\\w_.\\-]+', duplicate_placeholder_mode=1, template_resolver=None)¶
Initialise with name and pattern.
anchor determines how the pattern is anchored during a parse. A value of
ANCHOR_START(the default) will match the pattern against the start of a path.
ANCHOR_ENDwill match against the end of a path. To anchor at both the start and end (a full path match) use
Nonewill try to match the pattern once anywhere in the path.
duplicate_placeholder_mode determines how duplicate placeholders will be handled during parsing.
RELAXEDmode extracts the last matching value without checking the other values.
STRICTmode ensures that all duplicate placeholders extract the same value and raises
ParseErrorif they do not.
If template_resolver is supplied, use it to resolve any template references in the pattern during operations. It should conform to the
Resolverinterface. It can be changed at any time on the instance to affect future operations.
Return name of template.
Return template pattern.
Return pattern with all referenced templates expanded recursively.
lucidity.error.ResolveErrorif pattern contains a reference that cannot be resolved by currently set template_resolver.
Return dictionary of data extracted from path using this template.
ParseErrorif path is not parsable by this template.
Return a path formatted by applying data to this template.
FormatErrorif data does not supply enough information to fill the template fields.
Return unique set of placeholders in pattern.
Return unique set of referenced templates in pattern.