Skip to content

Commit

Permalink
Small fix in __lt__ and __gt__
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebi2020 committed Feb 18, 2019
1 parent 3c98592 commit 6c973a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ print(a)
foo@bar:~$ python test.py
0.1.0
1.0.0-pre+build.1
2.0.0-pre+build.1
2.0.0-dev+build.1
```

### Manipulate specific parts
Expand Down
24 changes: 6 additions & 18 deletions csemver/csemver.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
""", re.VERBOSE)
_num = re.compile(r"^[1-9][0-9]*$")

if not hasattr(__builtins__, 'cmp'):
def cmp(a, b):
return (a > b) - (a < b)


class csemver:
""" Representation of an semantic software version """

Expand All @@ -53,16 +48,6 @@ def __init__(self, version = "0.1.0"):
'!=': self.__ne__
}

def _build(self, val):
if _valid_ident.match(val) is not None:
self._version['build'] = val;
else:
raise ValueError("Not a valid build tag!")

def _prerelease(self,val):
newstr = sv.format_version(self._version['major'],self._version['minor'],self._version['patch'],val,self._version['build']);
self._version = sv.parse(newstr);

@deprecated
def setNumber(self,val):
self._version = self._parse(val)
Expand Down Expand Up @@ -137,7 +122,10 @@ def __setitem__(self, key, val):
raise ValueError("%s must be a number or a string!" % key)
self._version[key] = int(val);
else:
if not isinstance(val, str):
if val is None:
self._version[key] = None
return
if not isinstance(val,str):
raise TypeError("%s must be a string" % key)
if _valid_ident.match(val) is None:
raise ValueError("%s must be a valid semver identifier!" % key)
Expand Down Expand Up @@ -189,7 +177,7 @@ def __gt__(self, value):
i,v = next(mmp)
if (i is None) and (v is not None):
return True
elif (i is not None) and (v is None):
elif i is None or v is None:
return False

# Check prerelease identfiers
Expand Down Expand Up @@ -224,7 +212,7 @@ def __lt__(self, value):
i,v = next(mmp)
if (i is not None) and (v is None):
return True
elif (i is None) and (v is not None):
elif i is None or v is None:
return False

# Check prerelease identfiers
Expand Down

0 comments on commit 6c973a6

Please sign in to comment.