summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2011-01-28 15:13:01 +0100
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2011-01-28 15:13:01 +0100
commit59e46b0d804514c026479abe7b1562cfd70d16ca (patch)
tree318c8526d783a813cbb08441e4b531f472c0d6b0
parent411a7146c2bd30a6cab6756b1dbae0a51e85f830 (diff)
downloadlogilab-common-59e46b0d804514c026479abe7b1562cfd70d16ca.tar.gz
refactor to ease overriding
-rw-r--r--changelog.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/changelog.py b/changelog.py
index b65a419..862d126 100644
--- a/changelog.py
+++ b/changelog.py
@@ -42,11 +42,8 @@ Each entry contains a set of messages corresponding to changes done in this
release.
All the non empty lines before the first entry are considered as the change
log title.
-
-
-
-
"""
+
__docformat__ = "restructuredtext en"
import sys
@@ -66,16 +63,21 @@ class Version(tuple):
"""simple class to handle soft version number has a tuple while
correctly printing it as X.Y.Z
"""
- def __new__(klass, versionstr):
+ def __new__(cls, versionstr):
if isinstance(versionstr, basestring):
- versionstr = versionstr.strip(' :')
- try:
- parsed = [int(i) for i in versionstr.split('.')]
- except ValueError, ex:
- raise ValueError("invalid literal for version '%s' (%s)"%(versionstr, ex))
+ versionstr = versionstr.strip(' :') # XXX (syt) duh?
+ parsed = cls.parse(versionstr)
else:
parsed = versionstr
- return tuple.__new__(klass, parsed)
+ return tuple.__new__(cls, parsed)
+
+ @classmethod
+ def parse(cls, versionstr):
+ versionstr = versionstr.strip(' :')
+ try:
+ return [int(i) for i in versionstr.split('.')]
+ except ValueError, ex:
+ raise ValueError("invalid literal for version '%s' (%s)"%(versionstr, ex))
def __str__(self):
return '.'.join([str(i) for i in self])