docker_tag_updater.helpers.regex_rules
#
Dictionary object for version parsing using regex.
This module defines the most fundamental object that is used by all other modules of this subpackage.
- DefaultRules: RegexRules = {'default': 'v?(?:ersion-)?(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+).*'}#
The default rule that should work for most standard semantic versions.
This object has the following equivalent aliases: default, docker.io, and docker.
- class RegexRules(rules)#
Bases:
dict
An aliased dictionary with defined regex rules for version parsing.
- Parameters:
rules (
dict
[str
,str
]) – A dictionary containing names as keys and regex strings as values.
Examples
The DefaultRules object that is provided in this module is created as follows.
>>> DefaultRules = RegexRules( ... rules = { ... "default": r"v?(?:ersion-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+).*", ... } ... )
Notes
RegexRules objects can be added together to concatenate into a larger RegexRules object. Do take note that a new rule is always prioritised over an existing rule with the same name, i.e., the operation does not always commute.
See also
DefaultRules
For an example of a RegexRules object.
- add_alias(main_rule, *aliases)#
Add a number of aliases to the rule.
- Parameters:
- Return type:
Examples
To add the aliases “docker.io” and “docker” to the rule named “default”, do the following: >>> DefaultRules.add_alias(“default”, “docker.io”, “docker”)
- Raises:
NotImplementedError – If there are no aliases to be added.