[Checkins] SVN: zopyx.convert2/trunk/src/zopyx/convert2/cli.py minor fixes
Andreas Jung
andreas at andreas-jung.com
Fri Dec 26 11:20:29 EST 2008
Log message for revision 94356:
minor fixes
Changed:
U zopyx.convert2/trunk/src/zopyx/convert2/cli.py
-=-
Modified: zopyx.convert2/trunk/src/zopyx/convert2/cli.py
===================================================================
--- zopyx.convert2/trunk/src/zopyx/convert2/cli.py 2008-12-26 16:20:07 UTC (rev 94355)
+++ zopyx.convert2/trunk/src/zopyx/convert2/cli.py 2008-12-26 16:20:28 UTC (rev 94356)
@@ -4,6 +4,8 @@
# (C) 2007, 2008, ZOPYX Ltd & Co. KG, Tuebingen, Germany
##########################################################################
+
+import sys
import tempfile
from optparse import OptionParser
from convert import Converter
@@ -33,13 +35,15 @@
cls = registry.converter_registry[name]
print '%s: %s.html -> %s.%s' % (name, tmpf, tmpf, cls.output_format)
C = Converter(tmpf + '.html', verbose=True)
- output_filename = C(name, output_filename=tmpf + '.' + cls.output_format)
+ try:
+ output_filename = C(name, output_filename=tmpf + '.' + cls.output_format)
+ except:
+ print 'FAILED'
print
elif options.show_converters:
print 'Available converters: %s' % ', '.join(registry.availableConverters())
-
else:
for fn in args:
@@ -50,8 +54,8 @@
def main():
-
- parser = OptionParser()
+ usage = "usage: %prog [options] arg1 arg2"
+ parser = OptionParser(usage=usage)
parser.add_option('-v', '--verbose', dest='verbose', action='store_true',
default=False, help='verbose on')
parser.add_option('-f', '--format', dest='format',
@@ -63,8 +67,10 @@
parser.add_option('-t', '--test', dest='test_mode', action='store_true',
help='test converters')
(options, args) = parser.parse_args()
+ if not args and not options.test_mode:
+ parser.print_help()
+ sys.exit(1)
convert(options, args)
-
if __name__ == '__main__':
main()
More information about the Checkins
mailing list