[Checkins] SVN: zc.sourcerelease/branches/matt-option-parsing/src/zc/sourcerelease/__init__.py Non-working, checking in prgress on using optparse.
matt@zope.com
cvs-admin at zope.org
Fri Nov 7 14:52:51 EST 2008
Log message for revision 92833:
Non-working, checking in prgress on using optparse.
Changed:
U zc.sourcerelease/branches/matt-option-parsing/src/zc/sourcerelease/__init__.py
-=-
Modified: zc.sourcerelease/branches/matt-option-parsing/src/zc/sourcerelease/__init__.py
===================================================================
--- zc.sourcerelease/branches/matt-option-parsing/src/zc/sourcerelease/__init__.py 2008-11-07 16:29:17 UTC (rev 92832)
+++ zc.sourcerelease/branches/matt-option-parsing/src/zc/sourcerelease/__init__.py 2008-11-07 19:52:50 UTC (rev 92833)
@@ -12,6 +12,7 @@
#
##############################################################################
+import optparse
import os
import shutil
import subprocess
@@ -55,11 +56,19 @@
url = args.pop(0)
config = args.pop(0)
+ # set up command line options
+ parser = optparse.OptionParser()
+ parser.add_option("-n", "--name", dest="filename",
+ help="create custom named files", metavar="NAME_FILE")
+
+ # retrieve options
+ (options, args_two) = parser.parse_args(['-n','none','--name','none'])
+
clopts = []
- for arg in args:
- name, value = arg.split('=', 1)
- section, option = name.split(':')
- clopts.append((section, option, value))
+ #for arg in args:
+ # name, value = arg.split('=', 1)
+ # section, option = name.split(':')
+ # clopts.append((section, option, value))
if url.endswith('/'):
# Remove ending slash
@@ -73,6 +82,14 @@
name = name + '_' + url_parts[-1]
else:
name = url_parts[-1]
+
+ # use optparse to find custom filename
+ if options.filename != "none":
+ name = options.filename
+ title, value = name.split('=', 1)
+ section, option = title.split(':')
+ clopts.append((section, option, value))
+
t1 = tempfile.mkdtemp('source-release1')
t2 = tempfile.mkdtemp('source-release2')
co1 = os.path.join(t1, name)
More information about the Checkins
mailing list