zfec: import latest version.py module from pyutil library

This commit is contained in:
Zooko O'Whielacronx 2007-05-09 15:58:40 -07:00
parent c3ccd10108
commit 361cbbb711
1 changed files with 13 additions and 3 deletions

View File

@ -74,6 +74,12 @@ class Tag(str):
class Version: class Version:
def __init__(self, vstring=None): def __init__(self, vstring=None):
self.major = None
self.minor = None
self.micro = None
self.prereleasetag = None
self.nano = None
self.tags = None
if vstring: if vstring:
self.parse(vstring) self.parse(vstring)
@ -87,17 +93,21 @@ class Version:
estring = None estring = None
self.strictversion = version.StrictVersion(svstring) self.strictversion = version.StrictVersion(svstring)
self.major = self.strictversion.version[0]
self.minor = self.strictversion.version[1]
self.micro = self.strictversion.version[2]
self.prereleasetag = self.strictversion.prerelease
if estring: if estring:
try: try:
(self.nanovernum, tags,) = estring.split('-') (self.nano, tags,) = estring.split('-')
except: except:
print estring print estring
raise raise
self.tags = map(Tag, tags.split('_')) self.tags = map(Tag, tags.split('_'))
self.tags.sort() self.tags.sort()
self.fullstr = '-'.join([str(self.strictversion), str(self.nanovernum), '_'.join(self.tags)]) self.fullstr = '-'.join([str(self.strictversion), str(self.nano), '_'.join(self.tags)])
def tags(self): def tags(self):
return self.tags return self.tags
@ -122,7 +132,7 @@ class Version:
if res != 0: if res != 0:
return res return res
res = cmp(self.nanovernum, other.nanovernum) res = cmp(self.nano, other.nano)
if res != 0: if res != 0:
return res return res