Changeset 348 for pkpgcounter/trunk/pkpgpdls/analyzer.py
- Timestamp:
- 08/13/06 23:27:25 (18 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/analyzer.py
r347 r348 22 22 import sys 23 23 import tempfile 24 import optparse 24 25 25 26 import version, pdlparser, postscript, pdf, pcl345, pclxl, \ … … 127 128 def main() : 128 129 """Entry point for PDL Analyzer.""" 129 if (len(sys.argv) < 2) or ((not sys.stdin.isatty()) and ("-" not in sys.argv[1:])) : 130 sys.argv.append("-") 131 132 if ("-h" in sys.argv[1:]) or ("--help" in sys.argv[1:]) : 133 print "usage : python analyzer.py file1 file2 ... fileN" 134 elif ("-v" in sys.argv[1:]) or ("--version" in sys.argv[1:]) : 130 parser = optparse.OptionParser(usage="python analyzer.py [options] file1 [file2 ...]") 131 parser.add_option("-v", "--version", 132 action="store_true", 133 dest="version", 134 help="show pkpgcounter's version number and exit.") 135 parser.add_option("-d", "--debug", 136 action="store_true", 137 dest="debug", 138 help="activate debug mode.") 139 (options, arguments) = parser.parse_args() 140 if options.version : 135 141 print "%s" % version.__version__ 136 142 else : 143 if (not arguments) or ((not sys.stdin.isatty()) and ("-" not in arguments)) : 144 arguments.append("-") 137 145 totalsize = 0 138 debug = 0 139 minindex = 1 140 if sys.argv[1] in ("-d", "--debug") : 141 minindex = 2 142 debug = 1 143 for arg in sys.argv[minindex:] : 146 for arg in arguments : 144 147 try : 145 parser = PDLAnalyzer(arg, debug)148 parser = PDLAnalyzer(arg, options.debug) 146 149 totalsize += parser.getJobSize() 147 except pdlparser.PDLParserError, msg :150 except (IOError, pdlparser.PDLParserError), msg : 148 151 sys.stderr.write("ERROR: %s\n" % msg) 149 152 sys.stderr.flush()