Changeset 555 for pkpgcounter/trunk
- Timestamp:
- 12/09/07 15:26:15 (17 years ago)
- Location:
- pkpgcounter/trunk/pkpgpdls
- Files:
-
- 21 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/bj.py
r553 r555 30 30 class Parser(pdlparser.PDLParser) : 31 31 """A parser for Canon BJ documents.""" 32 format = "Canon BJ/BJC" 32 33 def isValid(self) : 33 34 """Returns True if data is BJ/BJC, else False.""" 34 35 if self.firstblock.startswith("\033[K\002\000") : 35 self.logdebug("DEBUG: Input file is in the Canon BJ format.")36 36 return True 37 37 else : -
pkpgcounter/trunk/pkpgpdls/cfax.py
r539 r555 29 29 class Parser(pdlparser.PDLParser) : 30 30 """A parser for Structured Fax documents.""" 31 format = "Structured Fax" 31 32 def isValid(self) : 32 33 """Returns True if data is Structured Fax, else False.""" 33 34 if self.firstblock.startswith("Sfff") : 34 self.logdebug("DEBUG: Input file is in the Structured Fax format.")35 35 return True 36 36 else : -
pkpgcounter/trunk/pkpgpdls/dvi.py
r527 r555 34 34 totiffcommands = [ 'dvips -q -o - "%(infname)s" | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r"%(dpi)i" -sOutputFile="%(outfname)s" -' ] 35 35 required = [ "dvips", "gs" ] 36 format = "DVI" 36 37 def isValid(self) : 37 38 """Returns True if data is DVI, else False.""" … … 39 40 if (ord(self.firstblock[0]) == 0xf7) \ 40 41 and (ord(self.lastblock[-1]) == 0xdf) : 41 self.logdebug("DEBUG: Input file is in the DVI format.")42 42 return True 43 43 else : -
pkpgcounter/trunk/pkpgpdls/escp2.py
r522 r555 29 29 class Parser(pdlparser.PDLParser) : 30 30 """A parser for ESC/P2 documents.""" 31 format = "ESC/P2" 31 32 def isValid(self) : 32 33 """Returns True if data is ESC/P2, else False.""" … … 35 36 self.firstblock.startswith("\n\033@") or \ 36 37 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.")38 38 return True 39 39 else : -
pkpgcounter/trunk/pkpgpdls/escpages03.py
r522 r555 33 33 class Parser(pdlparser.PDLParser) : 34 34 """A parser for ESC/PageS03 documents.""" 35 format = "ESC/PageS03" 35 36 def isValid(self) : 36 37 """Returns True if data is TIFF, else False.""" 37 38 if self.firstblock.startswith("\033\1@EJL") and \ 38 39 (self.firstblock.find("=ESC/PAGES03\n") != -1) : 39 self.logdebug("DEBUG: Input file is in the ESC/PageS03 format.")40 40 return True 41 41 else : -
pkpgcounter/trunk/pkpgpdls/hbp.py
r522 r555 32 32 class Parser(pdlparser.PDLParser) : 33 33 """A parser for HBP documents.""" 34 format = "Brother HBP" 34 35 def isValid(self) : 35 36 """Returns True if data is HBP, else False.""" 36 37 if self.firstblock.find("@PJL ENTER LANGUAGE = HBP\n") != -1 : 37 self.logdebug("DEBUG: Input file is in the HBP format.")38 38 return True 39 39 else : -
pkpgcounter/trunk/pkpgpdls/lidil.py
r532 r555 52 52 class Parser(pdlparser.PDLParser) : 53 53 """A parser for HP LIDIL documents.""" 54 format = "Hewlett-Packard LIDIL" 54 55 def isValid(self) : 55 56 """Returns True if data is LIDIL, else False.""" … … 64 65 if self.firstblock.startswith(BOFMarker) \ 65 66 and self.lastblock.endswith(EOFMarker) : 66 self.logdebug("DEBUG: Input file is in the Hewlett-Packard LIDIL format.")67 67 return True 68 68 else : -
pkpgcounter/trunk/pkpgpdls/mscrap.py
r529 r555 33 33 totiffcommands = [ 'xvfb-run -a abiword --import-extension=.doc --print="| gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r\"%(dpi)i\" -sOutputFile=\"%(outfname)s\" -" "%(infname)s"' ] 34 34 required = [ "xvfb-run", "xauth", "abiword", "gs" ] 35 format = "Microsoft shitty" 35 36 def isValid(self) : 36 37 """Returns True if data is MS crap, else False. … … 46 47 or self.firstblock.startswith("\x31\xbe\x00\x00") \ 47 48 or self.firstblock[2112:].startswith("MSWordDoc") : 48 self.logdebug("DEBUG: Input file seems to be in a Microsoft shitty file format.")49 49 # Here we do the missing test because all commands will be needed even in page counting mode 50 50 if self.isMissing(self.required) : -
pkpgcounter/trunk/pkpgpdls/ooo.py
r527 r555 32 32 totiffcommands = [ 'xvfb-run -a abiword --import-extension=.odt --print="| gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r\"%(dpi)i\" -sOutputFile=\"%(outfname)s\" -" "%(infname)s"' ] 33 33 required = [ "xvfb-run", "xauth", "abiword", "gs" ] 34 format = "ISO/IEC DIS 26300" 34 35 def isValid(self) : 35 36 """Returns True if data is OpenDocument, else False.""" … … 42 43 return False 43 44 else : 44 self.logdebug("DEBUG: Input file is in the OpenDocument (ISO/IEC DIS 26300) format.")45 45 return True 46 46 else : -
pkpgcounter/trunk/pkpgpdls/pcl345.py
r543 r555 43 43 ] 44 44 required = [ "pcl6", "gs" ] 45 format = "PCL3/4/5" 45 46 mediasizes = { # ESC&l####A 46 47 0 : "Default", … … 110 111 (firstblock.find("@PJL ENTER LANGUAGE=PCL\012\015\033") != -1) or \ 111 112 (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.")113 113 return True 114 114 else : -
pkpgcounter/trunk/pkpgpdls/pclxl.py
r527 r555 37 37 ] 38 38 required = [ "pcl6", "gs" ] 39 format = "PCLXL (aka PCL6)" 39 40 mediasizes = { 40 41 0 : "Letter", … … 89 90 (self.firstblock.find("LANGUAGE = PCLXL") != -1)))) \ 90 91 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.")92 92 return True 93 93 else : -
pkpgcounter/trunk/pkpgpdls/pdf.py
r527 r555 46 46 required = [ "gs" ] 47 47 openmode = "rU" 48 format = "PDF" 48 49 def isValid(self) : 49 50 """Returns True if data is PDF, else False.""" … … 52 53 ((self.firstblock[:128].find("\033%-12345X") != -1) and (self.firstblock.upper().find("LANGUAGE=PDF") != -1)) or \ 53 54 (self.firstblock.find("%PDF-") != -1) : 54 self.logdebug("DEBUG: Input file is in the PDF format.")55 55 return True 56 56 else : -
pkpgcounter/trunk/pkpgpdls/pdlparser.py
r529 r555 43 43 required = [] # Default list of required commands 44 44 openmode = "rb" # Default file opening mode 45 format = "Unknown" # Default file format 45 46 def __init__(self, parent, filename, (firstblock, lastblock)) : 46 47 """Initialize the generic parser.""" … … 54 55 if not self.isValid() : 55 56 raise PDLParserError, "Invalid file format !" 57 else : 58 self.logdebug("Input file is in the '%s' file format." % self.format) 56 59 try : 57 60 import psyco -
pkpgcounter/trunk/pkpgpdls/pil.py
r527 r555 44 44 return False 45 45 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) 47 47 return True 48 48 -
pkpgcounter/trunk/pkpgpdls/plain.py
r527 r555 33 33 required = [ "a2ps | enscript", "gs" ] 34 34 openmode = "rU" 35 format = "plain text" 35 36 def isValid(self) : 36 37 """Returns True if data is plain text, else False. … … 46 47 lines = lines[0].split("\n") 47 48 if len(lines) > 1 : 48 self.logdebug("DEBUG: Input file seems to be in the plain text format.")49 49 return True 50 50 else : -
pkpgcounter/trunk/pkpgpdls/pnmascii.py
r554 r555 28 28 """A parser for PNM (ascii) documents.""" 29 29 openmode = "rU" 30 format = "PNM (ascii)" 30 31 def isValid(self) : 31 32 """Returns True if data is ASCII PNM, else False.""" 32 33 if self.firstblock.split()[0] in ("P1", "P2", "P3") : 33 self.logdebug("DEBUG: Input file seems to be in the PNM (ascii) format.")34 34 self.marker = self.firstblock[:2] 35 35 return True -
pkpgcounter/trunk/pkpgpdls/postscript.py
r527 r555 34 34 required = [ "gs" ] 35 35 openmode = "rU" 36 format = "PostScript" 36 37 def isValid(self) : 37 38 """Returns True if data is PostScript, else False.""" … … 44 45 (self.firstblock.find("LANGUAGE = Postscript") != -1))) or \ 45 46 (self.firstblock.find("%!PS-Adobe") != -1) : 46 self.logdebug("DEBUG: Input file is in the PostScript format.")47 47 return True 48 48 else : -
pkpgcounter/trunk/pkpgpdls/qpdl.py
r522 r555 33 33 class Parser(pdlparser.PDLParser) : 34 34 """A parser for QPDL (aka SPL2) documents.""" 35 format = "QPDL (aka SPL2)" 35 36 mediasizes = { 36 37 # The first values are identical to that of PCLXL … … 76 77 ((self.firstblock.find("LANGUAGE=QPDL") != -1) or \ 77 78 (self.firstblock.find("LANGUAGE = QPDL") != -1))) : 78 self.logdebug("DEBUG: Input file is in the QPDL (aka SPL2) format.")79 79 return True 80 80 else : -
pkpgcounter/trunk/pkpgpdls/spl1.py
r533 r555 34 34 class Parser(pdlparser.PDLParser) : 35 35 """A parser for SPL1 documents.""" 36 format = "SPL1 (aka GDI)" 36 37 def isValid(self) : 37 38 """Returns True if data is SPL1, else False.""" … … 40 41 ((self.firstblock.find("LANGUAGE=SMART") != -1) or \ 41 42 (self.firstblock.find("LANGUAGE = SMART") != -1))) : 42 self.logdebug("DEBUG: Input file is in the SPL1 format.")43 43 return True 44 44 else : -
pkpgcounter/trunk/pkpgpdls/tiff.py
r527 r555 34 34 totiffcommands = [ 'cp "%(infname)s" "%(outfname)s"' ] 35 35 required = [ "cp" ] 36 format = "TIFF" 36 37 def isValid(self) : 37 38 """Returns True if data is TIFF, else False.""" … … 39 40 bigendian = (chr(0x4d)*2) + chr(0) + chr(0x2a) 40 41 if self.firstblock[:4] in (littleendian, bigendian) : 41 self.logdebug("DEBUG: Input file is in the TIFF format.")42 42 return True 43 43 else : -
pkpgcounter/trunk/pkpgpdls/zjstream.py
r532 r555 32 32 """Returns True if data is ZjStream, else False.""" 33 33 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)" 35 35 return self.littleEndian() 36 36 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)" 38 38 return self.bigEndian() 39 39 else :