[Zope-Checkins] CVS: Zope/lib/python/App - version_txt.py:1.11
Fred L. Drake, Jr.
fred@zope.com
Thu, 13 Feb 2003 10:55:07 -0500
Update of /cvs-repository/Zope/lib/python/App
In directory cvs.zope.org:/tmp/cvs-serv21464
Modified Files:
version_txt.py
Log Message:
More cleanup, make this actually pass the (new) tests.
=== Zope/lib/python/App/version_txt.py 1.10 => 1.11 ===
--- Zope/lib/python/App/version_txt.py:1.10 Wed Feb 12 15:43:43 2003
+++ Zope/lib/python/App/version_txt.py Thu Feb 13 10:55:06 2003
@@ -18,13 +18,11 @@
_version_string = None
_zope_version = None
-
-def intval(dict, key):
- return int(dict.get(key, 0))
-
-def strval(dict, key):
- return str(dict.get(key, ''))
-
+def _test_reset():
+ # Needed for testing.
+ global _version_string, _zope_version
+ _version_string = None
+ _zope_version = None
def _prep_version_data():
global _version_string, _zope_version
@@ -39,18 +37,19 @@
'(?P<status>[A-Za-z]+)?(?P<release>[0-9]+)?')
try:
s = open(fn).read()
+ except IOError:
+ ss = 'unreleased version'
+ _zope_version = (-1, -1, -1, '', -1)
+ else:
ss = re.sub("\(.*?\)\?","",s)
-
dict = expr.match(s).groupdict()
_zope_version = (
- intval(dict, 'major'),
- intval(dict, 'minor'),
- intval(dict, 'micro'),
- strval(dict, 'status'),
- intval(dict, 'release'))
- except:
- ss = 'unreleased version'
- _zope_version = (-1, -1, -1, '', -1)
+ int(dict.get('major') or -1),
+ int(dict.get('minor') or -1),
+ int(dict.get('micro') or -1),
+ dict.get('status') or '',
+ int(dict.get('release') or -1),
+ )
_version_string = "%s, %s" % (ss, pyver)