Changeset 538 for pkpgcounter/trunk

Show
Ignore:
Timestamp:
12/08/07 16:34:49 (16 years ago)
Author:
jerome
Message:

Improved detection of PCL3/4/5 datas.

Files:
1 modified

Legend:

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

    r527 r538  
    9393    def isValid(self) :     
    9494        """Returns True if data is PCL3/4/5, else False.""" 
    95         if self.firstblock.startswith("\033E\033") or \ 
    96            (self.firstblock.startswith("\033*rbC") and (not self.lastblock[-3:] == "\f\033@")) or \ 
    97            self.firstblock.startswith("\033*rB\033") or \ 
    98            self.firstblock.startswith("\033%8\033") or \ 
    99            (self.firstblock.find("\033%-12345X") != -1) or \ 
    100            (self.firstblock.find("@PJL ENTER LANGUAGE=PCL\012\015\033") != -1) or \ 
    101            (self.firstblock.startswith(chr(0xcd)+chr(0xca)) and (self.firstblock.find("\033E\033") != -1)) : 
    102             self.logdebug("DEBUG: Input file is in the PCL3/4/5 format.") 
    103             return True 
     95        try : 
     96            pos = 0 
     97            while self.firstblock[pos] == chr(0) : 
     98                pos += 1 
     99        except IndexError :         
     100            return False 
    104101        else :     
    105             return False 
     102            firstblock = self.firstblock[pos:] 
     103            if firstblock.startswith("\033E\033") or \ 
     104               ((pos == 11000) and firstblock.startswith("\033")) or \ 
     105               (firstblock.startswith("\033*rbC") and (not self.lastblock[-3:] == "\f\033@")) or \ 
     106               firstblock.startswith("\033*rB\033") or \ 
     107               firstblock.startswith("\033%8\033") or \ 
     108               (firstblock.find("\033%-12345X") != -1) or \ 
     109               (firstblock.find("@PJL ENTER LANGUAGE=PCL\012\015\033") != -1) or \ 
     110               (firstblock.startswith(chr(0xcd)+chr(0xca)) and (firstblock.find("\033E\033") != -1)) : 
     111                self.logdebug("DEBUG: Input file is in the PCL3/4/5 format.") 
     112                return True 
     113            else :     
     114                return False 
    106115         
    107116    def setPageDict(self, attribute, value) :