Skip to content

functions

Generators for version parts.

Classes

CalVerFunction

CalVerFunction(calver_format: str)

Bases: PartFunction

This is a class that provides a CalVer function for version parts.

Methods:

bump
bump(value: Optional[str] = None) -> str

Return the optional value.

validate
validate(value: str) -> None

CalVer values come from the date and can’t be set explicitly.

IndependentFunction

IndependentFunction(value: Union[str, int, None] = None)

Bases: PartFunction

This is a class that provides an independent function for version parts.

It simply returns the optional value, which is equal to the first value.

Methods:

bump
bump(value: Optional[str] = None) -> str

Return the optional value.

NumericFunction

NumericFunction(optional_value: Union[str, int, None] = None, first_value: Union[str, int, None] = None)

Bases: PartFunction

This is a class that provides a numeric function for version parts.

It simply starts with the provided first_value (0 by default) and increases it following the sequence of integer numbers.

The optional value of this function is equal to the first value.

This function also supports alphanumeric parts, altering just the numeric part (e.g. ‘r3’ –> ‘r4’). Only the first numeric group found in the part is considered (e.g. ‘r3-001’ –> ‘r4-001’).

Methods:

bump
bump(value: Union[str, int]) -> str

Increase the first numerical value by one.

validate
validate(value: str) -> None

Raise a ValueError if the value has no digit or is lower than the first value.

PartFunction

Base class for a version part function.

Methods:

bump
bump(value: str) -> str

Increase the value.

validate
validate(value: str) -> None

Raise a ValueError if the value can’t be explicitly set on this part.

ValuesFunction

ValuesFunction(values: List[str], optional_value: Optional[str] = None, first_value: Optional[str] = None)

Bases: PartFunction

This is a class that provides a values list based function for version parts.

It is initialized with a list of values and iterates through them when bumping the part.

The default optional value of this function is equal to the first value, but may be otherwise specified.

When trying to bump a part which has already the maximum value in the list you get a ValueError exception.

Methods:

bump
bump(value: str) -> str

Return the item after value in the list.

validate
validate(value: str) -> None

Raise a ValueError if the value isn’t one of the configured values.

Functions: