Show
Ignore:
Timestamp:
11/28/07 11:13:33 (17 years ago)
Author:
jerome
Message:

Finally we need to duplicate some datas, since for some file formats (e.g. mstrash)
a preliminary conversion will have to be done (through wvware for example) and we
would need to overwrite original values, which is not desirable.

Files:
1 modified

Legend:

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

    r520 r522  
    5656        self.workfile = None  
    5757        self.mustclose = None 
    58         self.firstblock = None 
    59         self.lastblock = None 
    6058         
    6159    def getJobSize(self) :     
     
    128126            self.workfile.close()     
    129127         
    130     def readFirstAndLastBlocks(self) :     
     128    def readFirstAndLastBlocks(self, inputfile) : 
    131129        """Reads the first and last blocks of data.""" 
    132130        # Now read first and last block of the input file 
    133131        # 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) 
    138136        except IOError :     
    139             self.lastblock = "" 
     137            lastblock = "" 
     138        return (firstblock, lastblock)      
    140139             
    141140    def detectPDLHandler(self) :     
     
    146145        if not os.stat(self.filename).st_size : 
    147146            raise pdlparser.PDLParserError, "input file %s is empty !" % str(self.filename) 
    148         self.readFirstAndLastBlocks() 
     147        (firstblock, lastblock) = self.readFirstAndLastBlocks(self.workfile) 
    149148             
    150149        # IMPORTANT : the order is important below. FIXME. 
     
    167166                       plain) :     # IMPORTANT : don't move this one up ! 
    168167            try :                
    169                 return module.Parser(self) 
     168                return module.Parser(self, (firstblock, lastblock)) 
    170169            except pdlparser.PDLParserError : 
    171170                pass # try next parser