Skip to content

Commit

Permalink
Add an attribute with always numeric version number
Browse files Browse the repository at this point in the history
Fix rpm-software-management#9

For example for Fedora Rawhide that would mean that `distro.version`
will be `"rawhide"` and `distro.version_number` will be e.g. `"41"`.
  • Loading branch information
FrostyX committed Mar 6, 2024
1 parent 4136d98 commit 4f2d8c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fedora_distro_aliases/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def from_bodhi_release(cls, release):
Create a `Distro` object from Bodhi `release`
"""
keys = ["name", "long_name", "version", "state", "branch", "id_prefix"]
return cls({k: getattr(release, k) for k in keys})
distro = cls({k: getattr(release, k) for k in keys})
distro.version_number = distro.version
return distro

@property
def product(self):
Expand Down
1 change: 1 addition & 0 deletions tests/test_fedora_distro_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def test_distro():
assert distro.namever == "foo-123"
assert distro.product == "fedora"
assert distro.product == "fedora"
assert distro.version_number == "123"
assert "nonsense" not in distro
assert "additional" not in distro

Expand Down

0 comments on commit 4f2d8c0

Please sign in to comment.