Changeset 353 for pkpgcounter/trunk
- Timestamp:
- 08/14/06 00:49:13 (18 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/analyzer.py
r351 r353 20 20 # 21 21 22 """This is the main module of pkpgcounter. 23 24 It defines the PDLAnalyzer class, which provides a generic way to parse 25 input files, by automatically detecting the best parser to use.""" 26 22 27 import sys 23 28 import tempfile … … 26 31 escp2, dvi, tiff, ooo, zjstream 27 32 28 class NoOption : 29 """A class for use as a default parameter to PDLAnalyzer's constructor.""" 30 debug = None 31 colorspace = None 32 resolution = None 33 34 class AnalyzerOption : 35 """A class for use as the options parameter to PDLAnalyzer's constructor.""" 36 def __init__(self, debug=None, 37 colorspace=None, 38 resolution=None) : 39 """Sets initial attributes.""" 40 self.debug = debug 41 self.colorspace = colorspace 42 self.resolution = resolution 43 33 44 34 45 class PDLAnalyzer : 35 46 """Class for PDL autodetection.""" 36 def __init__(self, filename, options= NoOption()) :47 def __init__(self, filename, options=AnalyzerOption()) : 37 48 """Initializes the PDL analyzer. 38 49 … … 43 54 self.options = options 44 55 self.filename = filename 56 self.infile = None 57 self.mustclose = None 45 58 46 59 def getJobSize(self) : … … 95 108 try : 96 109 self.infile.seek(0) 97 except :110 except IOError : 98 111 pass # probably stdin, which is not seekable 99 112 … … 142 155 return valower 143 156 else : 144 choices = ", ".join( map(repr, option.cichoices))157 choices = ", ".join([repr(o) for o in option.cichoices]) 145 158 raise optparse.OptionValueError( 146 159 "option %s: invalid choice: %r (choose from %s)"