Changeset 520 for pkpgcounter/trunk/pkpgpdls/analyzer.py
- Timestamp:
- 11/28/07 00:52:52 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/analyzer.py
r519 r520 56 56 self.workfile = None 57 57 self.mustclose = None 58 self.firstblock = None 59 self.lastblock = None 58 60 59 61 def getJobSize(self) : … … 126 128 self.workfile.close() 127 129 130 def readFirstAndLastBlocks(self) : 131 """Reads the first and last blocks of data.""" 132 # Now read first and last block of the input file 133 # to be able to detect the real file format and the parser to use. 134 self.firstblock = self.workfile.read(pdlparser.FIRSTBLOCKSIZE) 135 try : 136 self.workfile.seek(-pdlparser.LASTBLOCKSIZE, 2) 137 self.lastblock = self.workfile.read(pdlparser.LASTBLOCKSIZE) 138 except IOError : 139 self.lastblock = "" 140 128 141 def detectPDLHandler(self) : 129 142 """Tries to autodetect the document format. … … 133 146 if not os.stat(self.filename).st_size : 134 147 raise pdlparser.PDLParserError, "input file %s is empty !" % str(self.filename) 135 136 # Now read first and last block of the input file 137 # to be able to detect the real file format and the parser to use. 138 firstblock = self.workfile.read(pdlparser.FIRSTBLOCKSIZE) 139 try : 140 self.workfile.seek(-pdlparser.LASTBLOCKSIZE, 2) 141 lastblock = self.workfile.read(pdlparser.LASTBLOCKSIZE) 142 except IOError : 143 lastblock = "" 148 self.readFirstAndLastBlocks() 144 149 145 150 # IMPORTANT : the order is important below. FIXME. … … 162 167 plain) : # IMPORTANT : don't move this one up ! 163 168 try : 164 return module.Parser(self.filename, firstblock, 165 lastblock, 166 self.options.debug) 169 return module.Parser(self) 167 170 except pdlparser.PDLParserError : 168 171 pass # try next parser