Show
Ignore:
Timestamp:
07/02/05 15:41:30 (19 years ago)
Author:
jerome
Message:

Big improvements on readability + maintainability

Files:
1 modified

Legend:

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

    r211 r220  
    2828from pdlanalyzer import pdlparser 
    2929 
    30 class PCL345Parser(pdlparser.PDLParser) : 
     30class Parser(pdlparser.PDLParser) : 
    3131    """A parser for PCL3, PCL4, PCL5 documents.""" 
    3232    mediasizes = {  # ESC&l####A 
     
    7777                     4 : "Transparent", 
    7878                   } 
     79         
     80    def isValid(self) :     
     81        """Returns 1 if data is PCL, else 0.""" 
     82        if self.firstblock.startswith("\033E\033") or \ 
     83           (self.firstblock.startswith("\033*rbC") and (not self.lastblock[-3:] == "\f\033@")) or \ 
     84           self.firstblock.startswith("\033%8\033") or \ 
     85           (self.firstblock.find("\033%-12345X") != -1) : 
     86            if self.debug :   
     87                sys.stderr.write("DEBUG: Input file is in the PCL3/4/5 format.\n") 
     88            return 1 
     89        else :     
     90            return 0 
    7991         
    8092    def setPageDict(self, pages, number, attribute, value) : 
     
    346358            mustclose = 1 
    347359        try : 
    348             parser = PCL345Parser(infile, debug=1) 
     360            parser = Parser(infile, debug=1) 
    349361            totalsize += parser.getJobSize() 
    350362        except pdlparser.PDLParserError, msg :