Changeset 555 for pkpgcounter/trunk

Show
Ignore:
Timestamp:
12/09/07 15:26:15 (16 years ago)
Author:
jerome
Message:

Each parser now has a 'format' attribute containing its short name.

Location:
pkpgcounter/trunk/pkpgpdls
Files:
21 modified

Legend:

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

    r553 r555  
    3030class Parser(pdlparser.PDLParser) : 
    3131    """A parser for Canon BJ documents.""" 
     32    format = "Canon BJ/BJC" 
    3233    def isValid(self) :         
    3334        """Returns True if data is BJ/BJC, else False.""" 
    3435        if self.firstblock.startswith("\033[K\002\000") : 
    35             self.logdebug("DEBUG: Input file is in the Canon BJ format.") 
    3636            return True 
    3737        else :     
  • pkpgcounter/trunk/pkpgpdls/cfax.py

    r539 r555  
    2929class Parser(pdlparser.PDLParser) : 
    3030    """A parser for Structured Fax documents.""" 
     31    format = "Structured Fax" 
    3132    def isValid(self) :         
    3233        """Returns True if data is Structured Fax, else False.""" 
    3334        if self.firstblock.startswith("Sfff") : 
    34             self.logdebug("DEBUG: Input file is in the Structured Fax format.") 
    3535            return True 
    3636        else :     
  • pkpgcounter/trunk/pkpgpdls/dvi.py

    r527 r555  
    3434    totiffcommands = [ 'dvips -q -o - "%(infname)s" | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r"%(dpi)i" -sOutputFile="%(outfname)s" -' ] 
    3535    required = [ "dvips", "gs" ] 
     36    format = "DVI" 
    3637    def isValid(self) :         
    3738        """Returns True if data is DVI, else False.""" 
     
    3940            if (ord(self.firstblock[0]) == 0xf7) \ 
    4041                and (ord(self.lastblock[-1]) == 0xdf) : 
    41                 self.logdebug("DEBUG: Input file is in the DVI format.") 
    4242                return True 
    4343            else :     
  • pkpgcounter/trunk/pkpgpdls/escp2.py

    r522 r555  
    2929class Parser(pdlparser.PDLParser) : 
    3030    """A parser for ESC/P2 documents.""" 
     31    format = "ESC/P2" 
    3132    def isValid(self) :         
    3233        """Returns True if data is ESC/P2, else False.""" 
     
    3536           self.firstblock.startswith("\n\033@") or \ 
    3637           self.firstblock.startswith("\0\0\0\033\1@EJL") : # ESC/P Raster ??? Seen on Stylus Photo 1284 
    37             self.logdebug("DEBUG: Input file is in the ESC/P2 format.") 
    3838            return True 
    3939        else :     
  • pkpgcounter/trunk/pkpgpdls/escpages03.py

    r522 r555  
    3333class Parser(pdlparser.PDLParser) : 
    3434    """A parser for ESC/PageS03 documents.""" 
     35    format = "ESC/PageS03" 
    3536    def isValid(self) :         
    3637        """Returns True if data is TIFF, else False.""" 
    3738        if self.firstblock.startswith("\033\1@EJL") and \ 
    3839            (self.firstblock.find("=ESC/PAGES03\n") != -1) : 
    39             self.logdebug("DEBUG: Input file is in the ESC/PageS03 format.") 
    4040            return True 
    4141        else :     
  • pkpgcounter/trunk/pkpgpdls/hbp.py

    r522 r555  
    3232class Parser(pdlparser.PDLParser) : 
    3333    """A parser for HBP documents.""" 
     34    format = "Brother HBP" 
    3435    def isValid(self) :         
    3536        """Returns True if data is HBP, else False.""" 
    3637        if self.firstblock.find("@PJL ENTER LANGUAGE = HBP\n") != -1 : 
    37             self.logdebug("DEBUG: Input file is in the HBP format.") 
    3838            return True 
    3939        else :     
  • pkpgcounter/trunk/pkpgpdls/lidil.py

    r532 r555  
    5252class Parser(pdlparser.PDLParser) : 
    5353    """A parser for HP LIDIL documents.""" 
     54    format = "Hewlett-Packard LIDIL" 
    5455    def isValid(self) :     
    5556        """Returns True if data is LIDIL, else False.""" 
     
    6465        if self.firstblock.startswith(BOFMarker) \ 
    6566           and self.lastblock.endswith(EOFMarker) : 
    66             self.logdebug("DEBUG: Input file is in the Hewlett-Packard LIDIL format.") 
    6767            return True 
    6868        else :     
  • pkpgcounter/trunk/pkpgpdls/mscrap.py

    r529 r555  
    3333    totiffcommands = [ 'xvfb-run -a abiword --import-extension=.doc --print="| gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r\"%(dpi)i\" -sOutputFile=\"%(outfname)s\" -" "%(infname)s"' ] 
    3434    required = [ "xvfb-run", "xauth", "abiword", "gs" ] 
     35    format = "Microsoft shitty" 
    3536    def isValid(self) :     
    3637        """Returns True if data is MS crap, else False. 
     
    4647           or self.firstblock.startswith("\x31\xbe\x00\x00") \ 
    4748           or self.firstblock[2112:].startswith("MSWordDoc") : 
    48             self.logdebug("DEBUG: Input file seems to be in a Microsoft shitty file format.") 
    4949            # Here we do the missing test because all commands will be needed even in page counting mode 
    5050            if self.isMissing(self.required) : 
  • pkpgcounter/trunk/pkpgpdls/ooo.py

    r527 r555  
    3232    totiffcommands = [ 'xvfb-run -a abiword --import-extension=.odt --print="| gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r\"%(dpi)i\" -sOutputFile=\"%(outfname)s\" -" "%(infname)s"' ] 
    3333    required = [ "xvfb-run", "xauth", "abiword", "gs" ] 
     34    format = "ISO/IEC DIS 26300" 
    3435    def isValid(self) :         
    3536        """Returns True if data is OpenDocument, else False.""" 
     
    4243                return False 
    4344            else : 
    44                 self.logdebug("DEBUG: Input file is in the OpenDocument (ISO/IEC DIS 26300) format.") 
    4545                return True 
    4646        else :     
  • pkpgcounter/trunk/pkpgpdls/pcl345.py

    r543 r555  
    4343                     ] 
    4444    required = [ "pcl6", "gs" ] 
     45    format = "PCL3/4/5" 
    4546    mediasizes = {  # ESC&l####A 
    4647                    0 : "Default", 
     
    110111               (firstblock.find("@PJL ENTER LANGUAGE=PCL\012\015\033") != -1) or \ 
    111112               (firstblock.startswith(chr(0xcd)+chr(0xca)) and (firstblock.find("\033E\033") != -1)) : 
    112                 self.logdebug("DEBUG: Input file is in the PCL3/4/5 format.") 
    113113                return True 
    114114            else :     
  • pkpgcounter/trunk/pkpgpdls/pclxl.py

    r527 r555  
    3737                     ] 
    3838    required = [ "pcl6", "gs" ] 
     39    format = "PCLXL (aka PCL6)" 
    3940    mediasizes = {  
    4041                    0 : "Letter", 
     
    8990              (self.firstblock.find("LANGUAGE = PCLXL") != -1)))) \ 
    9091             or ((self.firstblock.startswith(chr(0xcd)+chr(0xca)) and (self.firstblock.find(" HP-PCL XL;") != -1))) : 
    91             self.logdebug("DEBUG: Input file is in the PCLXL (aka PCL6) format.") 
    9292            return True 
    9393        else :     
  • pkpgcounter/trunk/pkpgpdls/pdf.py

    r527 r555  
    4646    required = [ "gs" ] 
    4747    openmode = "rU" 
     48    format = "PDF" 
    4849    def isValid(self) :     
    4950        """Returns True if data is PDF, else False.""" 
     
    5253           ((self.firstblock[:128].find("\033%-12345X") != -1) and (self.firstblock.upper().find("LANGUAGE=PDF") != -1)) or \ 
    5354           (self.firstblock.find("%PDF-") != -1) : 
    54             self.logdebug("DEBUG: Input file is in the PDF format.") 
    5555            return True 
    5656        else :     
  • pkpgcounter/trunk/pkpgpdls/pdlparser.py

    r529 r555  
    4343    required = []               # Default list of required commands 
    4444    openmode = "rb"             # Default file opening mode 
     45    format = "Unknown"          # Default file format 
    4546    def __init__(self, parent, filename, (firstblock, lastblock)) : 
    4647        """Initialize the generic parser.""" 
     
    5455        if not self.isValid() : 
    5556            raise PDLParserError, "Invalid file format !" 
     57        else :     
     58            self.logdebug("Input file is in the '%s' file format." % self.format) 
    5659        try : 
    5760            import psyco  
  • pkpgcounter/trunk/pkpgpdls/pil.py

    r527 r555  
    4444            return False 
    4545        else :     
    46             self.logdebug("DEBUG: Input file seems to be an image in the %s (%s) format." % (image.format, image.format_description)) 
     46            self.format = "%s (%s)" % (image.format, image.format_description) 
    4747            return True 
    4848             
  • pkpgcounter/trunk/pkpgpdls/plain.py

    r527 r555  
    3333    required = [ "a2ps | enscript", "gs" ] 
    3434    openmode = "rU"                  
     35    format = "plain text" 
    3536    def isValid(self) :     
    3637        """Returns True if data is plain text, else False. 
     
    4647                lines = lines[0].split("\n") 
    4748        if len(lines) > 1 : 
    48             self.logdebug("DEBUG: Input file seems to be in the plain text format.") 
    4949            return True 
    5050        else :     
  • pkpgcounter/trunk/pkpgpdls/pnmascii.py

    r554 r555  
    2828    """A parser for PNM (ascii) documents.""" 
    2929    openmode = "rU"                  
     30    format = "PNM (ascii)" 
    3031    def isValid(self) :     
    3132        """Returns True if data is ASCII PNM, else False.""" 
    3233        if self.firstblock.split()[0] in ("P1", "P2", "P3") : 
    33             self.logdebug("DEBUG: Input file seems to be in the PNM (ascii) format.") 
    3434            self.marker = self.firstblock[:2] 
    3535            return True 
  • pkpgcounter/trunk/pkpgpdls/postscript.py

    r527 r555  
    3434    required = [ "gs" ] 
    3535    openmode = "rU" 
     36    format = "PostScript" 
    3637    def isValid(self) :     
    3738        """Returns True if data is PostScript, else False.""" 
     
    4445              (self.firstblock.find("LANGUAGE = Postscript") != -1))) or \ 
    4546              (self.firstblock.find("%!PS-Adobe") != -1) : 
    46             self.logdebug("DEBUG: Input file is in the PostScript format.") 
    4747            return True 
    4848        else :     
  • pkpgcounter/trunk/pkpgpdls/qpdl.py

    r522 r555  
    3333class Parser(pdlparser.PDLParser) : 
    3434    """A parser for QPDL (aka SPL2) documents.""" 
     35    format = "QPDL (aka SPL2)" 
    3536    mediasizes = {  
    3637                    # The first values are identical to that of PCLXL 
     
    7677             ((self.firstblock.find("LANGUAGE=QPDL") != -1) or \ 
    7778              (self.firstblock.find("LANGUAGE = QPDL") != -1))) : 
    78             self.logdebug("DEBUG: Input file is in the QPDL (aka SPL2) format.") 
    7979            return True 
    8080        else :     
  • pkpgcounter/trunk/pkpgpdls/spl1.py

    r533 r555  
    3434class Parser(pdlparser.PDLParser) : 
    3535    """A parser for SPL1 documents.""" 
     36    format = "SPL1 (aka GDI)" 
    3637    def isValid(self) :     
    3738        """Returns True if data is SPL1, else False.""" 
     
    4041             ((self.firstblock.find("LANGUAGE=SMART") != -1) or \ 
    4142              (self.firstblock.find("LANGUAGE = SMART") != -1))) : 
    42             self.logdebug("DEBUG: Input file is in the SPL1 format.") 
    4343            return True 
    4444        else :     
  • pkpgcounter/trunk/pkpgpdls/tiff.py

    r527 r555  
    3434    totiffcommands = [ 'cp "%(infname)s" "%(outfname)s"' ] 
    3535    required = [ "cp" ] 
     36    format = "TIFF" 
    3637    def isValid(self) :         
    3738        """Returns True if data is TIFF, else False.""" 
     
    3940        bigendian = (chr(0x4d)*2) + chr(0) + chr(0x2a) 
    4041        if self.firstblock[:4] in (littleendian, bigendian) : 
    41             self.logdebug("DEBUG: Input file is in the TIFF format.") 
    4242            return True 
    4343        else :     
  • pkpgcounter/trunk/pkpgpdls/zjstream.py

    r532 r555  
    3232        """Returns True if data is ZjStream, else False.""" 
    3333        if self.firstblock[:4] == "ZJZJ" : 
    34             self.logdebug("DEBUG: Input file is in the Zenographics ZjStream (little endian) format.") 
     34            self.format = "Zenographics ZjStream (little endian)" 
    3535            return self.littleEndian() 
    3636        elif self.firstblock[:4] == "JZJZ" :     
    37             self.logdebug("DEBUG: Input file is in the Zenographics ZjStream (big endian) format.") 
     37            self.format = "Zenographics ZjStream (big endian)" 
    3838            return self.bigEndian() 
    3939        else :