499 | | return self.pagecount or nbmediasourcesdefault |
| 499 | |
| 500 | self.pagecount = self.pagecount or nbmediasourcesdefault |
| 501 | |
| 502 | |
| 503 | defaultpjlcopies = 1 |
| 504 | defaultduplexmode = "Simplex" |
| 505 | defaultpapersize = "" |
| 506 | oldpjlcopies = -1 |
| 507 | oldduplexmode = "" |
| 508 | oldpapersize = "" |
| 509 | for pnum in range(self.pagecount) : |
| 510 | # if no number of copies defined, take the preceding one else the one set before any page else 1. |
| 511 | page = self.pages.get(pnum, self.pages.get(pnum - 1, self.pages.get(0, { "copies" : 1, "mediasource" : "Main", "mediasize" : "Default", "mediatype" : "Plain", "orientation" : "Portrait", "escaped" : "", "duplex": 0}))) |
| 512 | pjlstuff = page["escaped"] |
| 513 | if pjlstuff : |
| 514 | pjlparser = pjl.PJLParser(pjlstuff) |
| 515 | nbdefaultcopies = int(pjlparser.default_variables.get("COPIES", -1)) |
| 516 | nbcopies = int(pjlparser.environment_variables.get("COPIES", -1)) |
| 517 | nbdefaultqty = int(pjlparser.default_variables.get("QTY", -1)) |
| 518 | nbqty = int(pjlparser.environment_variables.get("QTY", -1)) |
| 519 | if nbdefaultcopies > -1 : |
| 520 | defaultpjlcopies = nbdefaultcopies |
| 521 | if nbdefaultqty > -1 : |
| 522 | defaultpjlcopies = nbdefaultqty |
| 523 | if nbcopies > -1 : |
| 524 | pjlcopies = nbcopies |
| 525 | elif nbqty > -1 : |
| 526 | pjlcopies = nbqty |
| 527 | else : |
| 528 | if oldpjlcopies == -1 : |
| 529 | pjlcopies = defaultpjlcopies |
| 530 | else : |
| 531 | pjlcopies = oldpjlcopies |
| 532 | if page["duplex"] : |
| 533 | duplexmode = "Duplex" |
| 534 | else : |
| 535 | defaultdm = pjlparser.default_variables.get("DUPLEX", "") |
| 536 | if defaultdm : |
| 537 | if defaultdm.upper() == "ON" : |
| 538 | defaultduplexmode = "Duplex" |
| 539 | else : |
| 540 | defaultduplexmode = "Simplex" |
| 541 | envdm = pjlparser.environment_variables.get("DUPLEX", "") |
| 542 | if envdm : |
| 543 | if envdm.upper() == "ON" : |
| 544 | duplexmode = "Duplex" |
| 545 | else : |
| 546 | duplexmode = "Simplex" |
| 547 | else : |
| 548 | duplexmode = oldduplexmode or defaultduplexmode |
| 549 | defaultps = pjlparser.default_variables.get("PAPER", "") |
| 550 | if defaultps : |
| 551 | defaultpapersize = defaultps |
| 552 | envps = pjlparser.environment_variables.get("PAPER", "") |
| 553 | if envps : |
| 554 | papersize = envps |
| 555 | else : |
| 556 | if not oldpapersize : |
| 557 | papersize = defaultpapersize |
| 558 | else : |
| 559 | papersize = oldpapersize |
| 560 | else : |
| 561 | if oldpjlcopies == -1 : |
| 562 | pjlcopies = defaultpjlcopies |
| 563 | else : |
| 564 | pjlcopies = oldpjlcopies |
| 565 | |
| 566 | duplexmode = (page["duplex"] and "Duplex") or oldduplexmode or defaultduplexmode |
| 567 | if not oldpapersize : |
| 568 | papersize = defaultpapersize |
| 569 | else : |
| 570 | papersize = oldpapersize |
| 571 | papersize = oldpapersize or page["mediasize"] |
| 572 | if page["mediasize"] != "Default" : |
| 573 | papersize = page["mediasize"] |
| 574 | if not duplexmode : |
| 575 | duplexmode = oldduplexmode or defaultduplexmode |
| 576 | oldpjlcopies = pjlcopies |
| 577 | oldduplexmode = duplexmode |
| 578 | oldpapersize = papersize |
| 579 | copies = pjlcopies * page["copies"] |
| 580 | self.pagecount += (copies - 1) |
| 581 | self.logdebug("%s*%s*%s*%s*%s*%s*BW" % (copies, \ |
| 582 | page["mediatype"], \ |
| 583 | papersize, \ |
| 584 | page["orientation"], \ |
| 585 | page["mediasource"], \ |
| 586 | duplexmode)) |
| 587 | |
| 588 | return self.pagecount |