Commit 1f97e260 authored by Fred Drake's avatar Fred Drake

More cleanup, make this actually pass the (new) tests.

parent 88ac137a
...@@ -18,13 +18,11 @@ from App.config import getConfiguration ...@@ -18,13 +18,11 @@ from App.config import getConfiguration
_version_string = None _version_string = None
_zope_version = None _zope_version = None
def _test_reset():
def intval(dict, key): # Needed for testing.
return int(dict.get(key, 0)) global _version_string, _zope_version
_version_string = None
def strval(dict, key): _zope_version = None
return str(dict.get(key, ''))
def _prep_version_data(): def _prep_version_data():
global _version_string, _zope_version global _version_string, _zope_version
...@@ -39,18 +37,19 @@ def _prep_version_data(): ...@@ -39,18 +37,19 @@ def _prep_version_data():
'(?P<status>[A-Za-z]+)?(?P<release>[0-9]+)?') '(?P<status>[A-Za-z]+)?(?P<release>[0-9]+)?')
try: try:
s = open(fn).read() s = open(fn).read()
except IOError:
ss = 'unreleased version'
_zope_version = (-1, -1, -1, '', -1)
else:
ss = re.sub("\(.*?\)\?","",s) ss = re.sub("\(.*?\)\?","",s)
dict = expr.match(s).groupdict() dict = expr.match(s).groupdict()
_zope_version = ( _zope_version = (
intval(dict, 'major'), int(dict.get('major') or -1),
intval(dict, 'minor'), int(dict.get('minor') or -1),
intval(dict, 'micro'), int(dict.get('micro') or -1),
strval(dict, 'status'), dict.get('status') or '',
intval(dict, 'release')) int(dict.get('release') or -1),
except: )
ss = 'unreleased version'
_zope_version = (-1, -1, -1, '', -1)
_version_string = "%s, %s" % (ss, pyver) _version_string = "%s, %s" % (ss, pyver)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment