[Zodb-checkins] SVN: ZODB/trunk/release.py Since we always fail to
update some version number in each
Tim Peters
tim.one at comcast.net
Wed Jun 2 23:55:20 EDT 2004
Log message for revision 25212:
Since we always fail to update some version number in each
release, tried to make this script much more robust. Use
r-strings for regexps. Junk unnecessary code that a Unixhead
probably thought was needed for Windows (replacing forward
slashes in filepaths -- Windows accepts those too). Made
the search criteria for NEWS.txt much looser (this is the
one we seem to blow most often). Changed replace() in
several ways: only replace the first occurrence of the
pattern (we never need more than that, and looser searches
are dangerous when replacing all occurrences); provide
feedback on everything done; if the pattern isn't found
at all, print a noisy msg saying so. Completed the list
of modified files in the module docstring.
-=-
Modified: ZODB/trunk/release.py
===================================================================
--- ZODB/trunk/release.py 2004-06-03 03:13:11 UTC (rev 25211)
+++ ZODB/trunk/release.py 2004-06-03 03:55:19 UTC (rev 25212)
@@ -7,23 +7,39 @@
date should be a string like "23-Sep-2003"
The following files are updated:
- - setup.py gets a version number
+ - setup.py
+ - NEWS.txt
+ - doc/guide/zodb.tex
+ - src/ZEO/__init__.py
+ - src/ZEO/version.txt
+ - src/ZODB/__init__.py
"""
import fileinput
import os
import re
-def fixpath(path):
- parts = path.split("/")
- return os.sep.join(parts)
-
+# In file filename, replace the first occurrence of regexp pat with
+# string repl.
def replace(filename, pat, repl):
- parts = filename.split("/")
- filename = os.sep.join(parts)
+ foundone = False
for line in fileinput.input([filename], inplace=True, backup="~"):
- print re.sub(pat, repl, line),
+ if foundone:
+ print line,
+ else:
+ new = re.sub(pat, repl, line)
+ if new != line:
+ foundone = True
+ print "In %r, replaced:" % filename
+ print " ", line
+ print "by:"
+ print " ", new
+ print new,
+ if not foundone:
+ print "*" * 60, "Oops!"
+ print " Failed to find %r in %r" % (pat, filename)
+
def compute_zeoversion(version):
# ZEO version's trail ZODB versions by one full revision.
# ZODB 3.2c1 corresponds to ZEO 2.2c1
@@ -32,7 +48,7 @@
return "%s.%s" % (major, rest)
def write_zeoversion(path, version):
- f = open(fixpath(path), "wb")
+ f = file(path, "w")
print >> f, version
f.close()
@@ -40,16 +56,19 @@
version, date = args
zeoversion = compute_zeoversion(version)
- replace("setup.py", 'version="\S+"', 'version="%s"' % version)
+ replace("setup.py",
+ r'version="\S+"',
+ 'version="%s"' % version)
replace("src/ZODB/__init__.py",
- '__version__ = "\S+"',
+ r'__version__ = "\S+"',
'__version__ = "%s"' % version)
replace("src/ZEO/__init__.py",
- 'version = "\S+"',
+ r'version = "\S+"',
'version = "%s"' % zeoversion)
write_zeoversion("src/ZEO/version.txt", zeoversion)
replace("NEWS.txt",
- "Release date: XX-\S+-\S+", "Release date: %s" % date)
+ r"^Release date: .*",
+ "Release date: %s" % date)
if __name__ == "__main__":
import sys
More information about the Zodb-checkins
mailing list