Changeset 522 for pkpgcounter/trunk/pkpgpdls/analyzer.py
- Timestamp:
- 11/28/07 11:13:33 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/analyzer.py
r520 r522 56 56 self.workfile = None 57 57 self.mustclose = None 58 self.firstblock = None59 self.lastblock = None60 58 61 59 def getJobSize(self) : … … 128 126 self.workfile.close() 129 127 130 def readFirstAndLastBlocks(self ) :128 def readFirstAndLastBlocks(self, inputfile) : 131 129 """Reads the first and last blocks of data.""" 132 130 # Now read first and last block of the input file 133 131 # 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)132 firstblock = inputfile.read(pdlparser.FIRSTBLOCKSIZE) 133 try : 134 inputfile.seek(-pdlparser.LASTBLOCKSIZE, 2) 135 lastblock = inputfile.read(pdlparser.LASTBLOCKSIZE) 138 136 except IOError : 139 self.lastblock = "" 137 lastblock = "" 138 return (firstblock, lastblock) 140 139 141 140 def detectPDLHandler(self) : … … 146 145 if not os.stat(self.filename).st_size : 147 146 raise pdlparser.PDLParserError, "input file %s is empty !" % str(self.filename) 148 self.readFirstAndLastBlocks()147 (firstblock, lastblock) = self.readFirstAndLastBlocks(self.workfile) 149 148 150 149 # IMPORTANT : the order is important below. FIXME. … … 167 166 plain) : # IMPORTANT : don't move this one up ! 168 167 try : 169 return module.Parser(self )168 return module.Parser(self, (firstblock, lastblock)) 170 169 except pdlparser.PDLParserError : 171 170 pass # try next parser