[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools - app.py:1.34
Fred L. Drake, Jr.
fred at zope.com
Tue Apr 20 14:43:06 EDT 2004
Update of /cvs-repository/Packages/zpkgtools/zpkgtools
In directory cvs.zope.org:/tmp/cvs-serv21742/zpkgtools
Modified Files:
app.py
Log Message:
get the version number from the revision tag where possible
=== Packages/zpkgtools/zpkgtools/app.py 1.33 => 1.34 ===
--- Packages/zpkgtools/zpkgtools/app.py:1.33 Tue Apr 20 11:27:55 2004
+++ Packages/zpkgtools/zpkgtools/app.py Tue Apr 20 14:42:34 2004
@@ -16,6 +16,7 @@
import logging
import optparse
import os
+import re
import sets
import shutil
import sys
@@ -520,6 +521,21 @@
"""
+def version_from_tagname(tagname):
+ """Compute a version number based on a revision control tag.
+
+ :param tagname: The name of the tag to convert.
+ :return: A version number for a release.
+ """
+ parts = tagname.split("-")
+ version = parts[-1].replace("_", ".")
+ m = re.match(r"\d+\.\d+(?:\.\d+(?:\.\d+)?)?(?:[a-z]+\d*)?$", version)
+ if m is None:
+ return None
+ else:
+ return version
+
+
def parse_args(argv):
"""Parse the command line, return an options object and the
identifier of the resource to be packaged.
@@ -564,14 +580,17 @@
help="include copies of the zpkgtools support code (the default)")
parser.add_option(
"-v", dest="version",
- help="version label for the new distribution",
- default="0.0.0")
+ help="version label for the new distribution")
options, args = parser.parse_args(argv[1:])
if len(args) != 1:
parser.error("wrong number of arguments")
options.program = prog
options.args = args
options.resource = args[0]
+ if options.revision_tag and not options.version:
+ options.version = version_from_tagname(options.revision_tag)
+ if not options.version:
+ options.version = "0.0.0"
return options
More information about the Zope-CVS
mailing list