Changeset 1574
- Timestamp:
- 06/28/04 00:59:37 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/pdlanalyzer.py
r1573 r1574 22 22 # 23 23 # $Log$ 24 # Revision 1.18 2004/06/27 22:59:37 jalet 25 # More work on PCLXL parser 26 # 24 27 # Revision 1.17 2004/06/26 23:20:01 jalet 25 28 # Additionnal speedup for GhostScript generated PCL5 files … … 263 266 if line[1:12] == " HP-PCL XL;" : 264 267 found = 1 265 if line[0] == ")" : 268 endian = ord(line[0]) 269 if endian == 0x29 : 266 270 self.littleendian() 267 elif line[0] == "(":271 elif endian == 0x28 : 268 272 self.bigendian() 273 else : 274 raise PDLAnalyzerError, "No endianness marker 0x%02x at start !" % endian 269 275 if not found : 270 276 raise PDLAnalyzerError, "This file doesn't seem to be PCLXL (aka PCL6)" 271 277 else : 272 278 self.tags = [ self.skipped ] * 256 273 self.tags[0x28] = self.bigendian # big endian 274 self.tags[0x29] = self.littleendian # big endian 279 self.tags[0x27] = lambda: self.debug("%08x : ASCII Binding" % self.infile.tell()) 280 self.tags[0x28] = self.bigendian 281 self.tags[0x29] = self.littleendian 282 283 self.tags[0x41] = lambda: self.debug("%08x : BeginSession" % self.infile.tell()) 284 self.tags[0x42] = lambda: self.debug("%08x : EndSession" % self.infile.tell()) 285 275 286 self.tags[0x43] = self.beginPage # BeginPage 276 287 self.tags[0x44] = self.endPage # EndPage 288 289 self.tags[0x47] = lambda: self.debug("%08x : Comment" % self.infile.tell()) 290 self.tags[0x48] = lambda: self.debug("%08x : OpenDataSource" % self.infile.tell()) 291 self.tags[0x49] = lambda: self.debug("%08x : CloseDataSource" % self.infile.tell()) 277 292 278 293 self.tags[0xc0] = lambda: self.debug("%08x : ubyte" % self.infile.tell()) or 1 # ubyte … … 385 400 fmt = ">I" 386 401 pos = self.infile.tell() 387 val = struct.unpack(fmt, self.infile.read(4))[0] 388 self.debug("%08x : Large datablock length : 0x%04x" % (self.infile.tell()-4, val)) 402 data = self.infile.read(4) 403 val = struct.unpack(fmt, data)[0] 404 if val & 0xff000000 : # tries to detect possible errors when we missed an indianness tag maybe 405 if fmt == "<I" : 406 fmt = ">I" 407 else : 408 fmt = "<I" 409 val = struct.unpack(fmt, data)[0] 410 self.debug("%08x : Large datablock length : 0x%08x" % (self.infile.tell()-4, val)) 411 self.debug("Endian : %i" % self.islittleendian) 412 self.debug("Data read : %s" % str(["0x%02x" % ord(x) for x in data])) 389 413 return val 390 414