Skip to content

Commit

Permalink
support for non PEP 440 version format
Browse files Browse the repository at this point in the history
  • Loading branch information
rudra-iitm committed Jan 11, 2024
1 parent f07e82d commit 4ffad1a
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions updatesnap/SnapModule/snapmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import yaml

import pkg_resources
import debian.debian_support


class Colors:
Expand Down Expand Up @@ -119,11 +120,22 @@ def _get_version(self, part_name, entry, entry_format, check):
if '%V' in entry_format['format']:
if not entry.startswith(entry_format['format'].split('%')[0]):
return None
version = pkg_resources.parse_version(entry[len(entry_format['format'].split('%')[0]):])
if (("lower-than" in entry_format) and
(version >= pkg_resources.parse_version(str(entry_format["lower-than"])))):
return None
return version
try:
version = pkg_resources.parse_version(
entry[len(entry_format['format'].split('%')[0]):])
if (("lower-than" in entry_format) and
(version >= pkg_resources.parse_version(
str(entry_format["lower-than"])))):
return None
return version
except pkg_resources.extern.packaging.version.InvalidVersion:
version = debian.debian_support.Version(
entry[len(entry_format['format'].split('%')[0]):])
if (("lower-than" in entry_format) and
(version >= debian.debian_support.Version(
str(entry_format["lower-than"])))):
return None
return version
major = 0
minor = 0
revision = 0
Expand Down

0 comments on commit 4ffad1a

Please sign in to comment.