Changeset 475 for pkpgcounter/trunk/pkpgpdls
- Timestamp:
- 09/21/07 00:14:48 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/escpages03.py
r474 r475 32 32 33 33 class Parser(pdlparser.PDLParser) : 34 """A parser for ESC/P AGES03 documents."""34 """A parser for ESC/PageS03 documents.""" 35 35 def isValid(self) : 36 36 """Returns True if data is TIFF, else False.""" 37 37 if self.firstblock.startswith("\033\1@EJL") and \ 38 38 (self.firstblock.find("=ESC/PAGES03\n") != -1) : 39 self.logdebug("DEBUG: Input file is in the ESC/P AGES03 format.")39 self.logdebug("DEBUG: Input file is in the ESC/PageS03 format.") 40 40 return True 41 41 else : … … 43 43 44 44 def getJobSize(self) : 45 """Counts pages in an ESC/P AGES03 document.45 """Counts pages in an ESC/PageS03 document. 46 46 47 47 Algorithm by Jerome Alet. … … 55 55 startsequence = chr(0x1d) 56 56 if startpos == -1 : 57 raise pdlparser.PDLParserError, "Invalid ESC/P AGES03 file."57 raise pdlparser.PDLParserError, "Invalid ESC/PageS03 file." 58 58 startpos += len(marker) 59 59 if minfile[startpos] != startsequence : 60 raise pdlparser.PDLParserError, "Invalid ESC/P AGES03 file."60 raise pdlparser.PDLParserError, "Invalid ESC/PageS03 file." 61 61 endsequence = "eps{I" 62 62 lgendsequence = len(endsequence) … … 65 65 while True : 66 66 if minfile[startpos] == startsequence : 67 #self.logdebug("Start sequence at %08x" % startpos)68 67 skiplen = 0 69 68 while True : … … 71 70 c = minfile[startpos] 72 71 if not c.isdigit() : 73 #self.logdebug("stop on %02x at %08x" % (ord(c), startpos))74 72 break 75 73 else : 76 74 skiplen = (skiplen * 10) + int(c) 77 75 if minfile[startpos:startpos+lgendsequence] == endsequence : 78 #self.logdebug("skipped %i bytes at %08x until %08x" % (skiplen, startpos, startpos+skiplen+lgendsequence)) 79 startpos += skiplen + lgendsequence 80 else : 81 #self.logdebug("Problem at %08x" % startpos) 82 pass 76 startpos += (skiplen + lgendsequence) 83 77 else : 84 78 if minfile[startpos:startpos+6] == "\033\1@EJL" : 85 # self.logdebug("EJL found at %08x" % startpos) 79 # Probably near the end of the file. 80 # Test suite was too small to be sure. 86 81 ejlparser = pjl.EJLParser(minfile[startpos:]) 87 82 pagecount = ejlparser.environment_variables.get("PAGES", "1") … … 90 85 pagecount = int(pagecount) 91 86 if pagecount <= 0 : 92 pagecount = 1 # TODO : 1000000;-)87 pagecount = 1 # TODO : 0 or 1000000 ??? ;-) 93 88 break 94 else :95 #self.logdebug("Skipped byte at %08x" % startpos)96 pass97 89 startpos += 1 98 90 except IndexError :