summaryrefslogtreecommitdiff
path: root/semantic_version
diff options
context:
space:
mode:
authorMartin Ek <mail@ekmartin.com>2016-02-23 23:24:32 +0100
committerMartin Ek <mail@ekmartin.com>2016-02-25 22:48:00 +0100
commit0c96767bd36ea082620f444ff5f3410025a9e99f (patch)
tree46af9014fa12b8edb817501bdb618c2e326c73c5 /semantic_version
parentd10ab4cb1d1ca8090132f205017dfc90473c91cc (diff)
downloadsemantic-version-0c96767bd36ea082620f444ff5f3410025a9e99f.tar.gz
Add support for compatible release ranges, fixes #37
Diffstat (limited to 'semantic_version')
-rw-r--r--semantic_version/base.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/semantic_version/base.py b/semantic_version/base.py
index 1504642..83a9c25 100644
--- a/semantic_version/base.py
+++ b/semantic_version/base.py
@@ -405,6 +405,7 @@ class SpecItem(object):
KIND_NEQ = '!='
KIND_CARET = '^'
KIND_TILDE = '~'
+ KIND_COMPATIBLE = '~='
# Map a kind alias to its full version
KIND_ALIASES = {
@@ -412,7 +413,7 @@ class SpecItem(object):
KIND_EMPTY: KIND_EQUAL,
}
- re_spec = re.compile(r'^(<|<=||=|==|>=|>|!=|\^|~)(\d.*)$')
+ re_spec = re.compile(r'^(<|<=||=|==|>=|>|!=|\^|~|~=)(\d.*)$')
def __init__(self, requirement_string):
kind, spec = self.parse(requirement_string)
@@ -468,6 +469,12 @@ class SpecItem(object):
return self.spec <= version < upper
elif self.kind == self.KIND_TILDE:
return self.spec <= version < self.spec.next_minor()
+ elif self.kind == self.KIND_COMPATIBLE:
+ if self.spec.patch:
+ upper = self.spec.next_minor()
+ else:
+ upper = self.spec.next_major()
+ return self.spec <= version < upper
else: # pragma: no cover
raise ValueError('Unexpected match kind: %r' % self.kind)