VMM/common: Made the version re pattern object accessible as VERSION_RE. v0.6.x
authorPascal Volk <neverseen@users.sourceforge.net>
Sat, 07 Aug 2010 03:17:46 +0000
branchv0.6.x
changeset 347 586367ee042b
parent 346 95d45e4ec1a6
child 348 ca7575401549
VMM/common: Made the version re pattern object accessible as VERSION_RE. Small 'global …' cleanups.
VirtualMailManager/common.py
--- a/VirtualMailManager/common.py	Fri Aug 06 23:06:19 2010 +0000
+++ b/VirtualMailManager/common.py	Sat Aug 07 03:17:46 2010 +0000
@@ -17,7 +17,8 @@
 from VirtualMailManager.errors import VMMError
 
 
-_version_re = re.compile(r'^(\d+)\.(\d+)\.(?:(\d+)|(alpha|beta|rc)(\d+))$')
+VERSION_RE = re.compile(r'^(\d+)\.(\d+)\.(?:(\d+)|(alpha|beta|rc)(\d+))$')
+
 _version_level = dict(alpha=0xA, beta=0xB, rc=0xC)
 _version_cache = {}
 _ = lambda msg: msg
@@ -73,11 +74,11 @@
     version_hex('1.2.3') -> 270548736
     hex(version_hex('1.2.3')) -> '0x10203f00'
     """
-    global _version_cache, _version_level, _version_re
+    global _version_cache
     if version_string in _version_cache:
         return _version_cache[version_string]
     version = 0
-    version_mo = _version_re.match(version_string)
+    version_mo = VERSION_RE.match(version_string)
     if not version_mo:
         raise ValueError('Invalid version string: %r' % version_string)
     major, minor, patch, level, serial = version_mo.groups()
@@ -110,7 +111,7 @@
     Raises a `TypeError` if *version* is not an int/long.
     Raises a `ValueError` if *version* is an incorrect int version.
     """
-    global _version_cache, _version_level
+    global _version_cache
     if version in _version_cache:
         return _version_cache[version]
     if not isinstance(version, (int, long)):