diff options
author | Fabrice Douchant <Fabrice.Douchant@logilab.fr> | 2008-10-13 17:22:14 +0200 |
---|---|---|
committer | Fabrice Douchant <Fabrice.Douchant@logilab.fr> | 2008-10-13 17:22:14 +0200 |
commit | 87ee3e314de58b2a9be4de73a71fdc403f758c73 (patch) | |
tree | dd0a2584288eff6b69b64f1d0fe915c4ed31f80a | |
parent | ab9434f0b350b8ca9da6c40e17f12f0a7eba2e9e (diff) | |
download | logilab-common-87ee3e314de58b2a9be4de73a71fdc403f758c73.tar.gz |
modify @require_version. No more regexp.
-rw-r--r-- | decorators.py | 10 |
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' |