summaryrefslogtreecommitdiff
path: root/semantic_version/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'semantic_version/base.py')
-rw-r--r--semantic_version/base.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/semantic_version/base.py b/semantic_version/base.py
index a8e39a4..d34d03e 100644
--- a/semantic_version/base.py
+++ b/semantic_version/base.py
@@ -379,6 +379,7 @@ class Version(object):
class SpecItem(object):
"""A requirement specification."""
+ KIND_ANY = '*'
KIND_LT = '<'
KIND_LTE = '<='
KIND_EQUAL = '=='
@@ -386,15 +387,6 @@ class SpecItem(object):
KIND_GT = '>'
KIND_NEQ = '!='
- STRICT_KINDS = (
- KIND_LT,
- KIND_LTE,
- KIND_EQUAL,
- KIND_GTE,
- KIND_GT,
- KIND_NEQ,
- )
-
re_spec = re.compile(r'^(<|<=|==|>=|>|!=)(\d.*)$')
def __init__(self, requirement_string):
@@ -407,6 +399,10 @@ class SpecItem(object):
if not requirement_string:
raise ValueError("Invalid empty requirement specification: %r" % requirement_string)
+ # Special case: the 'any' version spec.
+ if requirement_string == '*':
+ return (cls.KIND_ANY, '')
+
match = cls.re_spec.match(requirement_string)
if not match:
raise ValueError("Invalid requirement specification: %r" % requirement_string)
@@ -416,7 +412,9 @@ class SpecItem(object):
return (kind, spec)
def match(self, version):
- if self.kind == self.KIND_LT:
+ if self.kind == self.KIND_ANY:
+ return True
+ elif self.kind == self.KIND_LT:
return version < self.spec
elif self.kind == self.KIND_LTE:
return version <= self.spec