Changeset 252 for pkpgcounter/trunk/pkpgpdls/pclxl.py
- Timestamp:
- 09/03/05 00:40:57 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/pclxl.py
r248 r252 28 28 29 29 import pdlparser 30 import pjl 30 31 31 32 class Parser(pdlparser.PDLParser) : … … 82 83 ((self.firstblock.find("LANGUAGE=PCLXL") != -1) or \ 83 84 (self.firstblock.find("LANGUAGE = PCLXL") != -1))) : 84 if self.debug : 85 sys.stderr.write("DEBUG: Input file is in the PCLXL (aka PCL6) format.\n") 85 self.logdebug("DEBUG: Input file is in the PCLXL (aka PCL6) format.") 86 86 return 1 87 87 else : … … 116 116 elif val == 0x28 : 117 117 orientation = ord(minfile[pos - 2]) 118 orien ationlabel = self.orientations.get(orientation, str(orientation))118 orientationlabel = self.orientations.get(orientation, str(orientation)) 119 119 pos = pos - 4 120 120 elif val == 0x27 : … … 246 246 def reservedForFutureUse(self) : 247 247 """Outputs something when a reserved byte is encountered.""" 248 if self.debug : 249 sys.stderr.write("Byte at %s is out of the PCLXL Protocol Class 2.0 Specification\n" % self.pos) 248 self.logdebug("Byte at %s is out of the PCLXL Protocol Class 2.0 Specification" % self.pos) 250 249 return 0 251 250 … … 255 254 if self.minfile[pos : pos+8] == r"%-12345X" : 256 255 endpos = pos + 9 257 endmark = chr(0x0c) + chr(0x00) 256 endmark = chr(0x0c) + chr(0x00) + chr(0x1b) 258 257 asciilimit = chr(0x80) 259 258 while (self.minfile[endpos] not in endmark) and (self.minfile[endpos] < asciilimit) : … … 264 263 stuff = self.escapedStuff.setdefault(self.pagecount, []) 265 264 stuff.append(self.minfile[pos : endpos]) 266 if self.debug : 267 sys.stderr.write("Escaped datas : [%s]\n" % repr(self.minfile[pos : endpos])) 265 self.logdebug("Escaped datas : [%s]" % repr(self.minfile[pos : endpos])) 268 266 return endpos - pos 269 267 … … 489 487 else : 490 488 colormode = "Black" 489 490 defaultpjlcopies = 1 491 oldpjlcopies = -1 491 492 for pnum in range(1, self.pagecount + 1) : 492 493 # if no number of copies defined, take 1, as explained … … 496 497 # to decrease the total number of pages in this case. 497 498 page = self.pages.get(pnum, self.pages.get(1, { "copies" : 1 })) 498 copies = page["copies"] 499 pjlstuff = self.escapedStuff.get(pnum, []) 500 if pjlstuff : 501 pjlparser = pjl.PJLParser("".join(pjlstuff)) 502 nbdefaultcopies = int(pjlparser.default_variables.get("COPIES", -1)) 503 nbcopies = int(pjlparser.environment_variables.get("COPIES", -1)) 504 nbdefaultqty = int(pjlparser.default_variables.get("QTY", -1)) 505 nbqty = int(pjlparser.environment_variables.get("QTY", -1)) 506 if nbdefaultcopies > -1 : 507 defaultpjlcopies = nbdefaultcopies 508 if nbdefaultqty > -1 : 509 defaultpjlcopies = nbdefaultqty 510 if nbcopies > -1 : 511 oldpjlcopies = pjlcopies = nbcopies 512 elif nbqty > -1 : 513 oldpjlcopies = pjlcopies = nbqty 514 else : 515 if oldpjlcopies == -1 : 516 oldpjlcopies = defaultpjlcopies 517 pjlcopies = oldpjlcopies 518 else : 519 if oldpjlcopies == -1 : 520 pjlcopies = defaultpjlcopies 521 else : 522 pjlcopies = oldpjlcopies 523 copies = pjlcopies * page["copies"] 499 524 self.pagecount += (copies - 1) 500 if self.debug : 501 sys.stderr.write("%s*%s*%s*%s*%s*%s\n" % (copies, 502 page["mediatype"], 503 page["mediasize"], 504 page["orientation"], 505 page["mediasource"], 506 colormode)) 525 self.logdebug("%s*%s*%s*%s*%s*%s" % (copies, 526 page["mediatype"], 527 page["mediasize"], 528 page["orientation"], 529 page["mediasource"], 530 colormode)) 507 531 return self.pagecount 508 532