Show
Ignore:
Timestamp:
11/28/07 00:52:52 (16 years ago)
Author:
jerome
Message:

Code cleaning.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/pkpgpdls/analyzer.py

    r519 r520  
    5656        self.workfile = None  
    5757        self.mustclose = None 
     58        self.firstblock = None 
     59        self.lastblock = None 
    5860         
    5961    def getJobSize(self) :     
     
    126128            self.workfile.close()     
    127129         
     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             
    128141    def detectPDLHandler(self) :     
    129142        """Tries to autodetect the document format. 
     
    133146        if not os.stat(self.filename).st_size : 
    134147            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() 
    144149             
    145150        # IMPORTANT : the order is important below. FIXME. 
     
    162167                       plain) :     # IMPORTANT : don't move this one up ! 
    163168            try :                
    164                 return module.Parser(self.filename, firstblock, 
    165                                                     lastblock, 
    166                                                     self.options.debug) 
     169                return module.Parser(self) 
    167170            except pdlparser.PDLParserError : 
    168171                pass # try next parser