version.py: handle both '0.2.0' and '0.2.0-1', remove 'tags' for now

This commit is contained in:
Brian Warner 2007-05-03 20:31:27 -07:00
parent 3f6b660272
commit 9bd213abe7

View File

@ -44,10 +44,10 @@ from distutils import version
# Developers see "full version strings", like this: # Developers see "full version strings", like this:
# "1.0.0a1-55-UNSTABLE" # "1.0.0a1-55"
# ^ ^ ^^^ ^ ^ # ^ ^ ^^^ ^
# | | ||| | | # | | ||| |
# | | ||| | '- tags # | | ||| |
# | | ||| '- nano version number # | | ||| '- nano version number
# | | ||'- release number # | | ||'- release number
# | | |'- alpha or beta (or none) # | | |'- alpha or beta (or none)
@ -59,9 +59,6 @@ from distutils import version
# developers. It gets bumped whenever a developer changes anything that another # developers. It gets bumped whenever a developer changes anything that another
# developer might care about. # developer might care about.
# The last part is the "tags" separated by "_". Standard tags are
# "STABLE" and "UNSTABLE".
class Tag(str): class Tag(str):
def __cmp__(t1, t2): def __cmp__(t1, t2):
if t1 == t2: if t1 == t2:
@ -79,7 +76,7 @@ class Version:
def parse(self, vstring): def parse(self, vstring):
i = vstring.find('-') i = vstring.find('-')
if i: if i != -1:
svstring = vstring[:i] svstring = vstring[:i]
estring = vstring[i+1:] estring = vstring[i+1:]
else: else:
@ -88,16 +85,16 @@ class Version:
self.strictversion = version.StrictVersion(svstring) self.strictversion = version.StrictVersion(svstring)
self.nanovernum = None
self.tags = []
if estring: if estring:
try: self.nanovernum = estring
(self.nanovernum, tags,) = estring.split('-')
except:
print estring
raise
self.tags = map(Tag, tags.split('_'))
self.tags.sort()
self.fullstr = '-'.join([str(self.strictversion), str(self.nanovernum), '_'.join(self.tags)]) self.fullstr = str(self.strictversion)
if self.nanovernum is not None:
self.fullstr += "-" + str(self.nanovernum)
if self.tags:
self.fullstr += '_'.join(self.tags)
def tags(self): def tags(self):
return self.tags return self.tags