[Checkins] SVN: zope.kgs/trunk/src/zope/kgs/intro.py add optparse and logging
Paul Carduner
paulcarduner at gmail.com
Sat Jan 24 00:30:38 EST 2009
Log message for revision 94969:
add optparse and logging
Changed:
U zope.kgs/trunk/src/zope/kgs/intro.py
-=-
Modified: zope.kgs/trunk/src/zope/kgs/intro.py
===================================================================
--- zope.kgs/trunk/src/zope/kgs/intro.py 2009-01-24 05:16:53 UTC (rev 94968)
+++ zope.kgs/trunk/src/zope/kgs/intro.py 2009-01-24 05:30:36 UTC (rev 94969)
@@ -19,7 +19,9 @@
The path of the file under which the generated intro file is stored.
"""
+import logging
import os
+import optparse
import sys
import zope.pagetemplate.pagetemplatefile
@@ -65,16 +67,30 @@
return rval
+parser = optparse.OptionParser(
+ usage="%prog [options] -d DIR",
+ description="This script regenerates the intro page for a kgs configuration")
+
+parser.add_option("-d","--dir", action="store",
+ type="string", dest="outputDir", metavar="DIR",
+ help="The directory where the kgs configuration is located.")
+
def main(args=None):
+ logging.basicConfig(level=logging.INFO)
+
if args is None:
args = sys.argv[1:]
+ if not args:
+ args = ['-h']
- if len(args) < 0:
- print __file__.__doc__
+ options, args = parser.parse_args(args)
+ if not options.outputDir:
+ logging.error("You must specify the location of the kgs configuration "
+ "the -d option.")
sys.exit(1)
- outputPath = args[0]
-
- page = IntroPage(os.path.dirname(outputPath))
+ page = IntroPage(options.outputDir)
page.update()
- open(outputPath, 'w').write(page())
+ outputFile = os.path.join(options.outputDir, 'intro.html')
+ logging.info("Generating %s" % outputFile)
+ open(outputFile, 'w').write(page())
More information about the Checkins
mailing list