summaryrefslogtreecommitdiff
path: root/decorators.py
diff options
context:
space:
mode:
authorFabrice Douchant <Fabrice.Douchant@logilab.fr>2008-10-13 17:22:14 +0200
committerFabrice Douchant <Fabrice.Douchant@logilab.fr>2008-10-13 17:22:14 +0200
commit87ee3e314de58b2a9be4de73a71fdc403f758c73 (patch)
treedd0a2584288eff6b69b64f1d0fe915c4ed31f80a /decorators.py
parentab9434f0b350b8ca9da6c40e17f12f0a7eba2e9e (diff)
downloadlogilab-common-87ee3e314de58b2a9be4de73a71fdc403f758c73.tar.gz
modify @require_version. No more regexp.
Diffstat (limited to 'decorators.py')
-rw-r--r--decorators.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/decorators.py b/decorators.py
index 71cd325..64b5e08 100644
--- a/decorators.py
+++ b/decorators.py
@@ -149,12 +149,12 @@ def require_version(version):
if older.
"""
def check_require_version(f):
+ version_elements = version.split('.')
+ try:
+ compare = tuple([int(v) for v in version_elements])
+ except ValueError:
+ raise ValueError('%s is not a correct version : should be X.Y[.Z].' % version)
current = sys.version_info[:3]
- version_rgx = re.compile('^(\d+)\.(\d+)\.?(\d+)?$') # version = X.Y[.Z]
- match = re.search(version_rgx, version)
- if match == None:
- raise ValueError('%s is not a correct version : sould be X.Y[.Z].' % version)
- compare = tuple([ int(x) for x in match.groups() if x ])
#print 'comp', current, compare
if current < compare:
#print 'version too old'