- Timestamp:
- 06/25/04 11:50:28 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r1566 r1568 28 28 - Fixed number of copies handling in PCL5 parser : the number 29 29 of copies could vary from page to page. 30 31 - Added more debug information to PCLXL parser. 30 32 31 33 - 1.19alpha25 : -
pykota/trunk/pykota/pdlanalyzer.py
r1567 r1568 22 22 # 23 23 # $Log$ 24 # Revision 1.14 2004/06/25 09:50:28 jalet 25 # More debug info in PCLXL parser 26 # 24 27 # Revision 1.13 2004/06/25 08:10:08 jalet 25 28 # Another fix for PCL5 parser … … 283 286 raise PDLAnalyzerError, "This file doesn't seem to be PCLXL (aka PCL6)" 284 287 else : 285 self.tags = [ lambda: None] * 256288 self.tags = [ self.skipped ] * 256 286 289 self.tags[0x28] = self.bigendian # big endian 287 290 self.tags[0x29] = self.littleendian # big endian … … 289 292 self.tags[0x44] = self.endPage # EndPage 290 293 291 self.tags[0xc0] = lambda: 1 # ubyte292 self.tags[0xc1] = lambda: 2 # uint16293 self.tags[0xc2] = lambda: 4 # uint32294 self.tags[0xc3] = lambda: 2 # sint16295 self.tags[0xc4] = lambda: 4 # sint32296 self.tags[0xc5] = lambda: 4 # real32294 self.tags[0xc0] = lambda: self.debug("%08x : ubyte" % self.infile.tell()) or 1 # ubyte 295 self.tags[0xc1] = lambda: self.debug("%08x : uint16" % self.infile.tell()) or 2 # uint16 296 self.tags[0xc2] = lambda: self.debug("%08x : uint32" % self.infile.tell()) or 4 # uint32 297 self.tags[0xc3] = lambda: self.debug("%08x : sint16" % self.infile.tell()) or 2 # sint16 298 self.tags[0xc4] = lambda: self.debug("%08x : sint32" % self.infile.tell()) or 4 # sint32 299 self.tags[0xc5] = lambda: self.debug("%08x : real32" % self.infile.tell()) or 4 # real32 297 300 298 301 self.tags[0xc8] = self.array_8 # ubyte_array … … 303 306 self.tags[0xcd] = self.array_32 # real32_array 304 307 305 self.tags[0xd0] = lambda: 2 # ubyte_xy306 self.tags[0xd1] = lambda: 4 # uint16_xy307 self.tags[0xd2] = lambda: 8 # uint32_xy308 self.tags[0xd3] = lambda: 4 # sint16_xy309 self.tags[0xd4] = lambda: 8 # sint32_xy310 self.tags[0xd5] = lambda: 8 # real32_xy311 312 self.tags[0xd0] = lambda: 4 # ubyte_box313 self.tags[0xd1] = lambda: 8 # uint16_box314 self.tags[0xd2] = lambda: 16 # uint32_box315 self.tags[0xd3] = lambda: 8 # sint16_box316 self.tags[0xd4] = lambda: 16 # sint32_box317 self.tags[0xd5] = lambda: 16 # real32_box318 319 self.tags[0xf8] = lambda: 1 # attr_ubyte320 self.tags[0xf9] = lambda: 2 # attr_uint16308 self.tags[0xd0] = lambda: self.debug("%08x : ubyte_xy" % self.infile.tell()) or 2 # ubyte_xy 309 self.tags[0xd1] = lambda: self.debug("%08x : uint16_xy" % self.infile.tell()) or 4 # uint16_xy 310 self.tags[0xd2] = lambda: self.debug("%08x : uint32_xy" % self.infile.tell()) or 8 # uint32_xy 311 self.tags[0xd3] = lambda: self.debug("%08x : sint16_xy" % self.infile.tell()) or 4 # sint16_xy 312 self.tags[0xd4] = lambda: self.debug("%08x : sint32_xy" % self.infile.tell()) or 8 # sint32_xy 313 self.tags[0xd5] = lambda: self.debug("%08x : real32_xy" % self.infile.tell()) or 8 # real32_xy 314 315 self.tags[0xd0] = lambda: self.debug("%08x : ubyte_box" % self.infile.tell()) or 4 # ubyte_box 316 self.tags[0xd1] = lambda: self.debug("%08x : uint16_box" % self.infile.tell()) or 8 # uint16_box 317 self.tags[0xd2] = lambda: self.debug("%08x : uint32_box" % self.infile.tell()) or 16 # uint32_box 318 self.tags[0xd3] = lambda: self.debug("%08x : sint16_box" % self.infile.tell()) or 8 # sint16_box 319 self.tags[0xd4] = lambda: self.debug("%08x : sint32_box" % self.infile.tell()) or 16 # sint32_box 320 self.tags[0xd5] = lambda: self.debug("%08x : real32_box" % self.infile.tell()) or 16 # real32_box 321 322 self.tags[0xf8] = lambda: self.debug("%08x : attr_ubyte" % self.infile.tell()) or 1 # attr_ubyte 323 self.tags[0xf9] = lambda: self.debug("%08x : attr_uint16" % self.infile.tell()) or 2 # attr_uint16 321 324 322 325 self.tags[0xfa] = self.embeddedData # dataLength … … 328 331 sys.stderr.flush() 329 332 333 def skipped(self) : 334 """Skips a byte.""" 335 self.debug("%08x : skip" % self.infile.tell()) 336 330 337 def beginPage(self) : 331 338 """Indicates the beginning of a new page.""" 332 339 self.pagecount += 1 333 self.debug(" Begin page %i at %s" % (self.pagecount, self.infile.tell()))340 self.debug("%08x : beginPage (%i)" % (self.infile.tell(), self.pagecount)) 334 341 335 342 def endPage(self) : 336 343 """Indicates the end of a page.""" 337 self.debug(" End page %i at %s" % (self.pagecount, self.infile.tell()))344 self.debug("%08x : endPage (%i)" % (self.infile.tell(), self.pagecount)) 338 345 339 346 def handleArray(self, itemsize) : … … 341 348 pos = self.infile.tell() 342 349 datatype = self.infile.read(1) 350 self.debug("%08x : Array of datatype 0x%02x" % (pos, ord(datatype))) 343 351 length = self.tags[ord(datatype)]() 344 352 if length is None : … … 359 367 raise PDLAnalyzerError, "Error on array size at %s" % self.infile.tell() 360 368 arraysize = struct.unpack(fmt, sarraysize)[0] 361 self.debug(" Array at %s, itemsize %s, datatype 0x%02x, size %s" % (pos, itemsize, ord(datatype),arraysize))369 self.debug("itemsize %s * size %s = %s" % (itemsize, arraysize, itemsize*arraysize)) 362 370 return arraysize * itemsize 363 371 364 372 def array_8(self) : 365 373 """Handles byte arrays.""" 374 self.debug("%08x : array_8" % self.infile.tell()) 366 375 return self.handleArray(1) 367 376 368 377 def array_16(self) : 369 378 """Handles byte arrays.""" 379 self.debug("%08x : array_16" % self.infile.tell()) 370 380 return self.handleArray(2) 371 381 372 382 def array_32(self) : 373 383 """Handles byte arrays.""" 384 self.debug("%08x : array_32" % self.infile.tell()) 374 385 return self.handleArray(4) 375 386 376 387 def embeddedDataSmall(self) : 377 388 """Handle small amounts of data.""" 389 self.debug("%08x : small_datablock" % self.infile.tell()) 378 390 pos = self.infile.tell() 379 391 val = ord(self.infile.read(1)) 380 self.debug(" smalldatablock at %s (0x%02x)" % (pos, val))392 self.debug("%08x : Small datablock length : 0x%02x" % (self.infile.tell()-1, val)) 381 393 return val 382 394 383 395 def embeddedData(self) : 384 396 """Handle normal amounts of data.""" 397 self.debug("%08x : large_datablock" % self.infile.tell()) 385 398 if self.islittleendian : 386 399 fmt = "<I" … … 389 402 pos = self.infile.tell() 390 403 val = struct.unpack(fmt, self.infile.read(4))[0] 391 self.debug(" datablock at %s (0x%08x)" % (pos, val))404 self.debug("%08x : Large datablock length : 0x%04x" % (self.infile.tell()-4, val)) 392 405 return val 393 406 394 407 def littleendian(self) : 395 408 """Toggles to little endianness.""" 409 self.debug("%08x : littleendian" % self.infile.tell()) 396 410 self.islittleendian = 1 # little endian 397 411 398 412 def bigendian(self) : 399 413 """Toggles to big endianness.""" 414 self.debug("%08x : bigendian" % self.infile.tell()) 400 415 self.islittleendian = 0 # big endian 401 416