Skip to content

Commit

Permalink
Bug 1829965 - Update mozilla-version to 2.0.0 r=releng-reviewers,jcri…
Browse files Browse the repository at this point in the history
…stau

I updated the mozilla-version entry in requirements.in, then ran 'mach vendor python'.

Differential Revision: https://phabricator.services.mozilla.com/D176470
  • Loading branch information
gbrownmozilla committed Apr 26, 2023
1 parent 432f59e commit 7332627
Show file tree
Hide file tree
Showing 17 changed files with 706 additions and 138 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
Metadata-Version: 2.1
Name: mozilla-version
Version: 0.3.4
Summary: Process Firefox versions numbers. Tells whether they are valid or not, whether they are nightlies or regular releases, whether this version precedes that other.
Version: 2.0.0
Summary: Process Firefox versions numbers. Tells whether they are valid or not, whether they are nightlies or regular releases, whether this version precedes that other.
Home-page: https://github.com/mozilla-releng/mozilla-version
Author: Mozilla Release Engineering
Author-email: [email protected]
License: MPL2
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Requires-Dist: attrs
Requires-Dist: enum34 ; python_version < "3.4"

UNKNOWN

License-File: LICENSE
Requires-Dist: attrs (>=19.2)

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
mozilla_version/__init__.py,sha256=ro9IDUmjUco6GHJhqbgynResbswRnh6HL5Iv1ttDuWU,60
mozilla_version/balrog.py,sha256=p75Ln9W5IiEzO8C-HIDmKsgdpN4hc9zbvTEOMZodNhQ,4961
mozilla_version/errors.py,sha256=DvBsNaJdhpaT3wb4E3Rnl7KAuxnqXlElBllYOcijwbQ,2468
mozilla_version/fenix.py,sha256=zruk3WsTMCeaRaaNi5ezxaSAb8t_8CATXpLhbVryOPM,199
mozilla_version/gecko.py,sha256=t4JcuF7mehXqFhKIxvFM3hrEx-qZpCmF9YcwWTUuCHM,24783
mozilla_version/maven.py,sha256=jH0F-Rq3tJJ_N3KbNE1KBi0i_BlXGZCYyjZ7K_CRxoM,1988
mozilla_version/mobile.py,sha256=3VJgbC90NpQMUTfy75zWyK4kMKjb3E7MnE_cfdHZriM,9520
mozilla_version/parser.py,sha256=kwaw3UeAbWgUFtCmCheY9grKwabmq9tc64JyTlPrHS8,1335
mozilla_version/version.py,sha256=MNTbIWmRWlN4jofkt2wKmyq3z3MWGWFDqrJYN1nKxj0,7929
mozilla_version/test/__init__.py,sha256=r9z_NrSZeN6vCBiocNFI00XPm2bveSogzO-jsLa7Q-I,87
mozilla_version/test/test_balrog.py,sha256=olr3NBdF1wtsz2Rfnb1aT3-cD7YgWQlDMfszmgz-ZgM,7839
mozilla_version/test/test_errors.py,sha256=oR6PZorSCYDWDRrye560gz6MCXD2E4J-eyfIVCVoenw,933
mozilla_version/test/test_fenix.py,sha256=qs8sD39N_cM9rNEZxyCaLuxx53hIIeHZIrJe_EBpYoQ,193
mozilla_version/test/test_gecko.py,sha256=TbIoRzfvCqtbrdIOw8aeNi-eieuZBSCE9c7nNghsOps,24494
mozilla_version/test/test_maven.py,sha256=_KaMDq47nQNctmPfA8zbTSq35vUFtaHyLkjdP9HL0zk,3526
mozilla_version/test/test_mobile.py,sha256=uMNZhPE1Go4vJ7hxzIs23T9qBVbNYQVs6gjN32NTP4U,11948
mozilla_version/test/test_version.py,sha256=AeWRvkgW739mEbq3JBd1hlY9hQqHro4h9gaUuLAChqU,7441
mozilla_version-2.0.0.dist-info/LICENSE,sha256=YCIsKMGn9qksffmOXF9EWeYk5uKF4Lm5RGevX2qzND0,15922
mozilla_version-2.0.0.dist-info/METADATA,sha256=3ZeZKRMprBj6yz8xBbHQTvK5h3vk18joltdq29yj2gY,482
mozilla_version-2.0.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
mozilla_version-2.0.0.dist-info/top_level.txt,sha256=K1r8SXa4ny0i7OTfimG0Ct33oHkXtLjuU1E5_aHBe94,16
mozilla_version-2.0.0.dist-info/RECORD,,
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.33.4)
Generator: bdist_wheel (0.38.4)
Root-Is-Purelib: true
Tag: py2-none-any
Tag: py3-none-any

16 changes: 8 additions & 8 deletions third_party/python/mozilla_version/mozilla_version/balrog.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@
def _supported_product(string):
product = string.lower()
if product not in _SUPPORTED_PRODUCTS:
raise PatternNotMatchedError(string, pattern='unknown product')
raise PatternNotMatchedError(string, patterns=('unknown product',))
return product


def _products_must_be_identical(method):
def checker(this, other):
if this.product != other.product:
raise ValueError('Cannot compare "{}" and "{}"'.format(this.product, other.product))
raise ValueError(f'Cannot compare "{this.product}" and "{other.product}"')
return method(this, other)
return checker


@attr.s(frozen=True, cmp=False, hash=True)
class BalrogReleaseName(object):
@attr.s(frozen=True, eq=False, hash=True)
class BalrogReleaseName:
"""Class that validates and handles Balrog release names.
Raises:
Expand All @@ -83,20 +83,20 @@ class BalrogReleaseName(object):
def __attrs_post_init__(self):
"""Ensure attributes are sane all together."""
if self.version.build_number is None:
raise PatternNotMatchedError(self, pattern='build_number must exist')
raise PatternNotMatchedError(self, patterns=('build_number must exist',))

@classmethod
def parse(cls, release_string):
"""Construct an object representing a valid Firefox version number."""
regex_matches = _VALID_ENOUGH_BALROG_RELEASE_PATTERN.match(release_string)
if regex_matches is None:
raise PatternNotMatchedError(release_string, _VALID_ENOUGH_BALROG_RELEASE_PATTERN)
raise PatternNotMatchedError(release_string, (_VALID_ENOUGH_BALROG_RELEASE_PATTERN,))

product = get_value_matched_by_regex('product', regex_matches, release_string)
try:
VersionClass = _SUPPORTED_PRODUCTS[product.lower()]
except KeyError:
raise PatternNotMatchedError(release_string, pattern='unknown product')
raise PatternNotMatchedError(release_string, patterns=('unknown product',))

version_string = get_value_matched_by_regex('version', regex_matches, release_string)
version = VersionClass.parse(version_string)
Expand All @@ -109,7 +109,7 @@ def __str__(self):
Computes a new string based on the given attributes.
"""
version_string = str(self.version).replace('build', '-build')
return '{}-{}'.format(self.product, version_string)
return f'{self.product}-{version_string}'

@_products_must_be_identical
def __eq__(self, other):
Expand Down
55 changes: 33 additions & 22 deletions third_party/python/mozilla_version/mozilla_version/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@ class PatternNotMatchedError(ValueError):
Args:
string (str): The string it was unable to match.
pattern (str): The pattern used it tried to match.
patterns (sequence): The patterns it tried to match.
"""

def __init__(self, string, pattern):
"""Constructor."""
super(PatternNotMatchedError, self).__init__(
'"{}" does not match the pattern: {}'.format(string, pattern)
)
def __init__(self, string, patterns):
"""Initialize error."""
number_of_patterns = len(patterns)
if number_of_patterns == 0:
raise ValueError('At least one pattern must be provided')
elif number_of_patterns == 1:
message = f'"{string}" does not match the pattern: {patterns[0]}'
else:
message = '"{}" does not match the patterns:\n - {}'.format(
string,
'\n - '.join(patterns)
)

super().__init__(message)


class NoVersionTypeError(ValueError):
Expand All @@ -24,10 +33,12 @@ class NoVersionTypeError(ValueError):
"""

def __init__(self, version_string):
"""Constructor."""
super(NoVersionTypeError, self).__init__(
'Version "{}" matched the pattern of a valid version, but it is unable to find what type it is. \
This is likely a bug in mozilla-version'.format(version_string)
"""Initialize error."""
super().__init__(
'Version "{}" matched the pattern of a valid version, but it is unable to '
'find what type it is. This is likely a bug in mozilla-version'.format(
version_string
)
)


Expand All @@ -40,24 +51,24 @@ class MissingFieldError(ValueError):
"""

def __init__(self, version_string, field_name):
"""Constructor."""
super(MissingFieldError, self).__init__(
'Release "{}" does not contain a valid {}'.format(version_string, field_name)
"""Initialize error."""
super().__init__(
f'Release "{version_string}" does not contain a valid {field_name}'
)


class TooManyTypesError(ValueError):
"""Error when `version_string` has too many types."""
"""Error when `version_string` has too many types.
Args:
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
"""

def __init__(self, version_string, first_matched_type, second_matched_type):
"""Constructor.
Args:
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
"""
super(TooManyTypesError, self).__init__(
"""Initialize error."""
super().__init__(
'Release "{}" cannot match types "{}" and "{}"'.format(
version_string, first_matched_type, second_matched_type
)
Expand Down
3 changes: 3 additions & 0 deletions third_party/python/mozilla_version/mozilla_version/fenix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Deprecated module for backwards compatibility."""
# TODO remove in a future release - deprecated in favor of MobileVersion
from mozilla_version.mobile import MobileVersion as FenixVersion # noqa
Loading

0 comments on commit 7332627

Please sign in to comment.