mozilla_version package¶
Submodules¶
mozilla_version.balrog module¶
Defines characteristics of a Balrog release name.
Balrog is the server that delivers Firefox and Thunderbird updates. Release names follow the pattern “{product}-{version}-build{build_number}”
Examples
from mozilla_version.balrog import BalrogReleaseName
balrog_release = BalrogReleaseName.parse('firefox-60.0.1-build1')
balrog_release.product # firefox
balrog_release.version.major_number # 60
str(balrog_release) # 'firefox-60.0.1-build1'
previous_release = BalrogReleaseName.parse('firefox-60.0-build2')
previous_release < balrog_release # True
BalrogReleaseName.parse('60.0.1') # raises PatternNotMatchedError
BalrogReleaseName.parse('firefox-60.0.1') # raises PatternNotMatchedError
# Releases can be built thanks to version classes like FirefoxVersion
BalrogReleaseName('firefox', FirefoxVersion(60, 0, 1)) # 'firefox-60.0-build1'
- class mozilla_version.balrog.BalrogReleaseName(product, version: GeckoVersion)¶
Bases:
objectClass that validates and handles Balrog release names.
- Raises:
PatternNotMatchedError – if a parsed string doesn’t match the pattern of a valid release
MissingFieldError – if a mandatory field is missing in the string. Mandatory fields are product, major_number, minor_number, and build_number
ValueError – if an integer can’t be cast or is not (strictly) positive
TooManyTypesError – if the string matches more than 1 VersionType
NoVersionTypeError – if the string matches none.
- __attrs_post_init__()¶
Ensure attributes are sane all together.
- __str__()¶
Implement string representation.
Computes a new string based on the given attributes.
- classmethod parse(release_string)¶
Construct an object representing a valid Firefox version number.
mozilla_version.gecko module¶
Defines characteristics of a Gecko version number, including Firefox.
Examples
from mozilla_version.gecko import FirefoxVersion
version = FirefoxVersion.parse('60.0.1')
version.major_number # 60
version.minor_number # 0
version.patch_number # 1
version.is_release # True
version.is_beta # False
version.is_nightly # False
str(version) # '60.0.1'
previous_version = FirefoxVersion.parse('60.0b14')
previous_version < version # True
previous_version.beta_number # 14
previous_version.major_number # 60
previous_version.minor_number # 0
previous_version.patch_number # raises AttributeError
previous_version.is_beta # True
previous_version.is_release # False
previous_version.is_nightly # False
FirefoxVersion.parse('60.1') # raises PatternNotMatchedError
FirefoxVersion.parse('60.0.0') # raises PatternNotMatchedError
version = FirefoxVersion.parse('60.0') # valid
# Versions can be built by raw values
FirefoxVersion(60, 0)) # '60.0'
FirefoxVersion(60, 0, 1)) # '60.0.1'
FirefoxVersion(60, 1, 0)) # '60.1.0'
FirefoxVersion(60, 0, 1, 1)) # '60.0.1build1'
FirefoxVersion(60, 0, beta_number=1)) # '60.0b1'
FirefoxVersion(60, 0, is_nightly=True)) # '60.0a1'
FirefoxVersion(60, 0, is_aurora_or_devedition=True)) # '60.0a2'
FirefoxVersion(60, 0, is_esr=True)) # '60.0esr'
FirefoxVersion(60, 0, 1, is_esr=True)) # '60.0.1esr'
- class mozilla_version.gecko.DeveditionVersion(major_number, minor_number, patch_number=None, build_number=None, beta_number=None, is_nightly: bool = False, is_aurora_or_devedition: bool = False, is_esr: bool = False, old_fourth_number=None, release_candidate_number=None)¶
Bases:
GeckoVersionClass that validates and handles Devedition after it shipped alongside beta.
- class mozilla_version.gecko.FennecVersion(major_number, minor_number, patch_number=None, build_number=None, beta_number=None, is_nightly: bool = False, is_aurora_or_devedition: bool = False, is_esr: bool = False, old_fourth_number=None, release_candidate_number=None)¶
Bases:
_VersionWithEdgeCasesClass that validates and handles Fennec (Firefox for Android) version numbers.
- __attrs_post_init__()¶
Ensure attributes are sane all together.
- class mozilla_version.gecko.FirefoxVersion(major_number, minor_number, patch_number=None, build_number=None, beta_number=None, is_nightly: bool = False, is_aurora_or_devedition: bool = False, is_esr: bool = False, old_fourth_number=None, release_candidate_number=None)¶
Bases:
_VersionWithEdgeCasesClass that validates and handles Firefox version numbers.
- class mozilla_version.gecko.GeckoSnapVersion(major_number, minor_number, patch_number=None, build_number=None, beta_number=None, is_nightly: bool = False, is_aurora_or_devedition: bool = False, is_esr: bool = False, old_fourth_number=None, release_candidate_number=None)¶
Bases:
GeckoVersionClass that validates and handles Gecko’s Snap version numbers.
Snap is a Linux packaging format developed by Canonical. Valid numbers are like “63.0b7-1”, “1” stands for “build1”. Release Engineering set this scheme at the beginning of Snap and now we can’t rename published snap to the regular pattern like “63.0b7-build1”.
- __str__()¶
Implement string representation.
Returns format like “63.0b7-1”
- class mozilla_version.gecko.GeckoVersion(major_number, minor_number, patch_number=None, build_number=None, beta_number=None, is_nightly: bool = False, is_aurora_or_devedition: bool = False, is_esr: bool = False, old_fourth_number=None, release_candidate_number=None)¶
Bases:
ShipItVersionClass that validates and handles version numbers for Gecko-based products.
You may want to use specific classes like FirefoxVersion. These classes define edge cases that were shipped.
- Raises:
PatternNotMatchedError – if the string doesn’t match the pattern of a valid version number
MissingFieldError – if a mandatory field is missing in the string. Mandatory fields are major_number and minor_number
ValueError – if an integer can’t be cast or is not (strictly) positive
TooManyTypesError – if the string matches more than 1 VersionType
NoVersionTypeError – if the string matches none.
- __eq__(other)¶
Implement == operator.
A version is considered equal to another if all numbers match and if they are of the same VersionType. Like said in VersionType, release and ESR are considered equal (if they share the same numbers). If a version contains a build number but not the other, the build number won’t be considered in the comparison.
Examples
GeckoVersion.parse('60.0') == GeckoVersion.parse('60.0') GeckoVersion.parse('60.0') == GeckoVersion.parse('60.0esr') GeckoVersion.parse('60.0') == GeckoVersion.parse('60.0build1') GeckoVersion.parse('60.0build1') == GeckoVersion.parse('60.0build1') GeckoVersion.parse('60.0') != GeckoVersion.parse('61.0') GeckoVersion.parse('60.0') != GeckoVersion.parse('60.1.0') GeckoVersion.parse('60.0') != GeckoVersion.parse('60.0.1') GeckoVersion.parse('60.0') != GeckoVersion.parse('60.0a1') GeckoVersion.parse('60.0') != GeckoVersion.parse('60.0a2') GeckoVersion.parse('60.0') != GeckoVersion.parse('60.0b1') GeckoVersion.parse('60.0build1') != GeckoVersion.parse('60.0build2')
- __str__()¶
Implement string representation.
Computes a new string based on the given attributes.
- bump_version_type()¶
Bump version type to the next one.
- Returns:
A new GeckoVersion with the version type set to the next one. Builds numbers are reset, if originally set.
- For instance:
32.0a1 is bumped to 32.0b1
32.0bX is bumped to 32.0
32.0 is bumped to 32.0esr
31.0build1 is bumped to 31.0esrbuild1
31.0build2 is bumped to 31.0esrbuild1
- property is_beta¶
Return True if GeckoVersion was built with a beta_number.
- property is_four_digit_scheme¶
Return True if GeckoVersion was built with the 4 digits schemes.
Only Firefox 1.5.x.y and 2.0.x.y were.
- property is_major¶
Return True if GeckoVersion is considered to be a major version.
It’s usually the .0 release but some exceptions may occur. ESR are not considered major versions.
- property is_rapid_release_scheme¶
Return True if GeckoVersion was built with the rapid release scheme.
- property is_release¶
Return True if GeckoVersion was built as a release version.
- property is_release_candidate¶
Return True if GeckoVersion was built with release_candidate_number.
- property is_stability¶
Return True if GeckoVersion is a version that fixed a major one.
- classmethod parse(version_string)¶
Construct an object representing a valid Firefox version number.
- class mozilla_version.gecko.ThunderbirdVersion(major_number, minor_number, patch_number=None, build_number=None, beta_number=None, is_nightly: bool = False, is_aurora_or_devedition: bool = False, is_esr: bool = False, old_fourth_number=None, release_candidate_number=None)¶
Bases:
_VersionWithEdgeCasesClass that validates and handles Thunderbird version numbers.
mozilla_version.version module¶
Defines common characteristics of a version at Mozilla.
- class mozilla_version.version.BaseVersion(major_number, minor_number, patch_number=None)¶
Bases:
objectClass that validates and handles general version numbers.
- __eq__(other)¶
Implement == operator.
- __ge__(other)¶
Implement >= operator.
- __gt__(other)¶
Implement > operator.
- __le__(other)¶
Implement <= operator.
- __lt__(other)¶
Implement < operator.
- __ne__(other)¶
Implement != operator.
- __str__()¶
Implement string representation.
Computes a new string based on the given attributes.
- bump(field)¶
Bump the number defined field.
- Returns:
A new BaseVersion with the right field bumped and the following ones set to 0, if they exist or if they need to be set.
- For instance:
32.0 is bumped to 33.0, because the patch number does not exist
32.0.1 is bumped to 33.0.0, because the patch number exists
32.0 is bumped to 32.1.0, because patch number must be defined if the minor number is not 0.
- classmethod parse(version_string, regex_groups=())¶
Construct an object representing a valid version number.
- class mozilla_version.version.ShipItVersion(major_number, minor_number, patch_number=None)¶
Bases:
BaseVersionClass that represent a version in the way ShipIt intends it to be.
ShipIt is Release Engineering’s https://github.com/mozilla-releng/shipit/
- __attrs_post_init__()¶
Ensure attributes are sane all together.
- property is_development¶
Return True if ShipItVersion was known to require further development.
It’s usually a beta or before the rapid release scheme, a release candidate.
- property is_major¶
Return True if ShipItVersion is considered to be a major version.
It’s usually the .0 release but some exceptions may occur.
- property is_stability¶
Return True if ShipItVersion is a version that fixed a major one.
- class mozilla_version.version.VersionType(*values)¶
Bases:
EnumEnum that sorts types of versions (e.g.: nightly, beta, release, esr).
Supports comparison. ESR is considered higher than RELEASE (even if they technically have the same codebase). For instance: 60.0.1 < 60.0.1esr but 61.0 > 60.0.1esr. This choice has a practical use case: if you have a list of Release and ESR version, you can easily extract one kind or the other thanks to the VersionType.
Examples
assert VersionType.NIGHTLY == VersionType.NIGHTLY assert VersionType.ESR > VersionType.RELEASE
- AURORA_OR_DEVEDITION = 2¶
- BETA = 3¶
- ESR = 6¶
- NIGHTLY = 1¶
- RELEASE = 5¶
- RELEASE_CANDIDATE = 4¶
- __eq__(other)¶
Implement == operator.
- __ge__(other)¶
Implement >= operator.
- __gt__(other)¶
Implement > operator.
- __le__(other)¶
Implement <= operator.
- __lt__(other)¶
Implement < operator.
- __ne__(other)¶
Implement != operator.
- compare(other)¶
Compare this VersionType with anotherself.
- Returns:
0 if equal < 0 is this precedes the other > 0 if the other precedes this
mozilla_version.errors module¶
Defines all errors reported by mozilla-version.
- exception mozilla_version.errors.MissingFieldError(version_string, field_name)¶
Bases:
ValueErrorError when version_string lacks an expected field.
- Parameters:
version_string (str) – The string it was unable to extract a given field.
field_name (str) – The name of the missing field.
- exception mozilla_version.errors.NoVersionTypeError(version_string)¶
Bases:
ValueErrorError when version_string matched the pattern, but was unable to find its type.
- Parameters:
version_string (str) – The string it was unable to guess the type.
- exception mozilla_version.errors.PatternNotMatchedError(string, patterns)¶
Bases:
ValueErrorError when a string doesn’t match an expected pattern.
- Parameters:
string (str) – The string it was unable to match.
patterns (sequence) – The patterns it tried to match.
- exception mozilla_version.errors.TooManyTypesError(version_string, first_matched_type, second_matched_type)¶
Bases:
ValueErrorError when version_string has too many types.
- Parameters:
version_string (str) – The string that gave too many types.
first_matched_type (str) – The name of the first detected type.
second_matched_type (str) – The name of the second detected type