10.9.5. Versioning Utilities

PyTan versioning utilities module.

pytan3.utils.versions.version_recomp(v1, v2, vshrink=True)[source]

Recompile version strings into lists.

Parameters:
  • v1 (str or list) –

    Version that is being compared against v2.

    Will be shrunk down to the same dotted length as v2 if vshrink is True.

    Will be split into list using period.

  • v2 (str or list) –

    Version that v1 is being compared against.

    Will be split into list using period.

  • vshrink (bool or int, optional) –

    If True, shrink v1 down to match the same length as v2.

    If False, do not shrink v1 at all.

    If int, shrink both v1 and v2 down to this length.

    Defaults to: True.

Notes

If any non-integers found in v1 or v2, they will be returned as joined strings using periods.

Default python string comparison leads to a less-than-perfect comparison for ints mixed with strs.

Returns:(list of str, list of str) or (str, str)
pytan3.utils.versions.version_eq(v1, v2, vshrink=True)[source]

Check if v1 is equal to v2.

Parameters:
  • v1 (str or list) –

    Version that is being compared against v2.

    Will be shrunk down to the same dotted length as v2 if vshrink is True.

  • v2 (str or list) – Version that v1 is being compared against.
  • vshrink (bool or int, optional) –

    If True, shrink v1 down to match the same length as v2.

    If False, do not shrink v1 at all.

    If int, shrink both v1 and v2 down to this length.

    Defaults to: True.

Returns:

bool

pytan3.utils.versions.version_min(v1, v2, vshrink=True)[source]

Check if v1 is greater than or equal to v2.

Parameters:
  • v1 (str or list) –

    Version that is being compared against v2.

    Will be shrunk down to the same dotted length as v2 if vshrink is True.

  • v2 (str or list) – Version that v1 is being compared against.
  • vshrink (bool or int, optional) –

    If True, shrink v1 down to match the same length as v2.

    If False, do not shrink v1 at all.

    If int, shrink both v1 and v2 down to this length.

    Defaults to: True.

Returns:

bool

pytan3.utils.versions.version_max(v1, v2, vshrink=True)[source]

Check if v1 is less than or equal to v2.

Parameters:
  • v1 (str or list) –

    Version that is being compared against veq, vmax, and vmin.

    Will be be shrunk down to the same dotted length as veq, vmax, and vmin if vshrink is True.

  • v2 (str or list) – Version that v1 is being compared against.
  • vshrink (bool or int, optional) –

    If True, shrink v1 down to match the same length as v2.

    If False, do not shrink v1 at all.

    If int, shrink both v1 and v2 down to this length.

    Defaults to: True.

Returns:

bool

pytan3.utils.versions.version_check(version, veq='', vmax='', vmin='', vshrink=True)[source]

Check if version meets veq, vmax, and vmin.

Parameters:
  • version (str or list) –

    Version that is being compared against veq, vmax, and vmin.

    Will be be shrunk down to the same dotted length as veq, vmax, and vmin if vshrink is True.

  • veq (str, optional) –

    Exact version that version must match.

    No comparison performed if empty.

    Defaults to: “”.

  • vmin (str, optional) –

    Minimum version that version must match.

    No comparison performed if empty.

    Defaults to: “”.

  • vmax (str, optional) –

    Maximum version that version must match.

    No comparison performed if empty.

    Defaults to: “”.

  • vshrink (bool or int, optional) –

    If True, shrink version down to match the same length as veq, vmax, and vmin.

    If False, do not shrink version at all.

    If int, shrink version, veq, vmax, and vmin down to this length.

    Defaults to: True.

Returns:

bool

pytan3.utils.versions.version_check_obj_req(version, src, obj)[source]

Check if veq, vmax, and vmin from a classes get_version_req meets version.

Parameters:
  • version (str or list) –

    Version that is being compared against veq, vmax, and vmin keys in the dict returned from the get_version_req class of obj.

    Will be be shrunk down to the same dotted length as veq, vmax, and vmin if vshrink is True.

  • src (str) – Where version came from, used in exception message.
  • obj (object) – Object or class that has get_version_req class method.
Raises:

pytan3.utils.exceptions.VersionMismatchError – If any of veq, vmax, vmin keys in dict returned by get_version_req do not match version.

pytan3.utils.versions.split_ver(v)[source]

Split v into a list of integers.

Parameters:v (str or list of int or int) – Version string to split using periods.
Returns:list of int or str
pytan3.utils.versions.join_ver(v)[source]

Join v into a dot string.

Parameters:v (str or list of int or int) – Version string to join using periods.
Returns:str