API Docs¶
User-level API.
-
class
invenio_sequencegenerator.api.
Sequence
(template, **kwargs)[source]¶ Iterator for sequences.
Initialize.
Parameters: - template – The template that this sequence is based on.
- **kwargs – The kwargs to instantiate the template.
-
class
invenio_sequencegenerator.api.
Template
(name, _model=None)[source]¶ API for defining sequences.
Initialize template.
Parameters: - name – The identifier of the template.
- _model – The model object of the template.
-
classmethod
create
(name, meta_template, start=0, step=1)[source]¶ Create a new sequence definition.
Parameters: - name – The identifier of the template definition.
- meta_template – The template generator.
- start – The starting counter of sequences based on this template.
- step – The incremental step of sequences based on this template.
Models¶
Models for storing counters for each pattern.
-
class
invenio_sequencegenerator.models.
Counter
(**kwargs)[source]¶ Stores generated identifiers.
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
counter
¶ Running counter.
-
definition_name
¶ Link to the template definition.
-
template_instance
¶ The template string to use.
-
-
class
invenio_sequencegenerator.models.
TemplateDefinition
(**kwargs)[source]¶ Representation of a template definition.
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
-
COUNTER_REGEX
= <_sre.SRE_Pattern object>¶ Regular expression matching the counter inside the template string.
-
meta_template
¶ The template generator.
-
name
¶ The identifier of the template definition.
-
parent_name
¶ Indicate that the template depends on another one.
-
start
¶ The starting counter of sequences generated from
meta_template
.
-
step
¶ The incremental step of sequences generated from
meta_template
.
-