Changeset 533 for pkpgcounter/trunk
- Timestamp:
- 11/30/07 23:48:48 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/spl1.py
r522 r533 23 23 """This modules implements a page counter for SPL1 documents.""" 24 24 25 import sys26 25 import os 27 26 import mmap 28 from struct import unpack 27 import struct 29 28 30 29 import pdlparser … … 51 50 self.unpackShort = self.unpackType[2] 52 51 self.unpackLong = self.unpackType[4] 52 # self.logdebug("Little Endian") 53 53 return 0 54 54 … … 58 58 self.unpackShort = self.unpackType[2] 59 59 self.unpackLong = self.unpackType[4] 60 # self.logdebug("Big Endian") 60 61 return 0 61 62 … … 87 88 if datas.endswith("$PJL BITMAP START\r\n") : 88 89 self.isbitmap = True 90 # self.logdebug("New bitmap") 89 91 self.logdebug("Escaped datas : [%s]" % repr(datas)) 90 92 return endpos - pos + 1 … … 100 102 self.escapedStuff = {} # For escaped datas, mostly PJL commands 101 103 self.bigEndian() 102 codesop = chr(0x06) + chr(0x00) + chr(0x00) + chr(0x80) + chr(0x13) + chr(0x40)103 104 self.isbitmap = False 104 105 pos = 0 106 unpack = struct.unpack 105 107 try : 106 108 try : … … 112 114 if not self.isbitmap : 113 115 raise pdlparser.PDLParserError, "Unfortunately SPL1 is incompletely recognized. Parsing aborted. Please report the problem to %s" % version.__authoremail__ 114 offset = unpack(self.unpackLong, minfile[pos:pos+4])[0]115 sequencenum = unpack(self.unpackShort, minfile[pos+4:pos+6])[0]116 if minfile[pos+6:pos+12] != codesop :117 raise pdlparser.PDLParserError, "Unfortunately SPL1 is incompletely recognized. Parsing aborted. Please report the problem to %s" % version.__authoremail__118 if not sequencenum :116 (offset, 117 seqnum) = unpack(">IH", minfile[pos:pos+6]) 118 # self.logdebug("Offset : %i Sequence Number : %i" % (offset, seqnum)) 119 if not seqnum : 120 # Sequence number resets to 0 for each new page. 119 121 self.pagecount += 1 120 122 pos += 4 + offset 123 except struct.error, msg : 124 raise pdlparser.PDLParserError, "Unfortunately SPL1 is incompletely recognized (%s). Parsing aborted. Please report the problem to %s" % (msg, version.__authoremail__) 121 125 except IndexError : # EOF ? 122 126 pass