Changeset 302
- Timestamp:
- 01/17/06 22:55:27 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/pclxl.py
r301 r302 4 4 # pkpgcounter : a generic Page Description Language parser 5 5 # 6 # (c) 2003, 2004, 2005 Jerome Alet <alet@librelogiciel.com>6 # (c) 2003, 2004, 2005, 2006 Jerome Alet <alet@librelogiciel.com> 7 7 # This program is free software; you can redistribute it and/or modify 8 8 # it under the terms of the GNU General Public License as published by … … 102 102 # this saves time because we don't need a complete parser ! 103 103 minfile = self.minfile 104 105 # self.logdebug("--------------") 106 # for i in range(100) : 107 # self.logdebug("%08i ==> 0x%02x ==> '%s'" % (self.pos - 98 + i, ord(self.minfile[self.pos - 98 + i]), self.minfile[self.pos - 98 + i])) 108 # self.logdebug("--------------") 109 104 110 pos = self.pos - 2 105 111 while pos > 0 : # safety check : don't go back to far ! … … 110 116 mediasource = ord(minfile[pos - 2]) 111 117 mediasourcelabel = self.mediasources.get(mediasource, str(mediasource)) 112 pos = pos -4118 pos -= 4 113 119 elif val == 0x25 : 114 mediasize = ord(minfile[pos - 2]) 115 mediasizelabel = self.mediasizes.get(mediasize, str(mediasize)) 116 pos = pos - 4 120 while (pos > 0) and (ord(minfile[pos]) != 0xc0) : 121 # we search the preceding ubyte tag 122 pos -= 1 123 if pos > 0 : 124 if ord(minfile[pos-1]) == 0xc8 : 125 # if we found an ubyte_array then the media 126 # size is completely spelled 127 arraylength = ord(minfile[pos+1]) 128 mediasizelabel = minfile[pos+2:pos+2+arraylength].title() 129 pos -= 1 130 else : 131 # if we just found an ubyte, then the media 132 # size is known by its index 133 mediasize = ord(minfile[pos+1]) 134 mediasizelabel = self.mediasizes.get(mediasize, str(mediasize)) 135 pos -= 1 117 136 elif val == 0x28 : 118 137 orientation = ord(minfile[pos - 2]) 119 138 orientationlabel = self.orientations.get(orientation, str(orientation)) 120 pos = pos -4139 pos -= 4 121 140 elif val == 0x27 : 122 141 savepos = pos 123 pos = pos -1142 pos -= 1 124 143 startpos = size = None 125 144 while pos > 0 : # safety check : don't go back to far ! … … 143 162 elif val == 0x34 : 144 163 duplexmode = "Simplex" 145 pos = pos -2164 pos -= 2 146 165 elif val in (0x35, 0x36) : 147 166 duplexmode = "Duplex" 148 pos = pos -2167 pos -= 2 149 168 # else : TODO : CUSTOM MEDIA SIZE AND UNIT ! 150 169 else : 151 pos = pos - 2# ignored170 pos -= 1 # ignored 152 171 self.pages[self.pagecount] = { "copies" : 1, 153 172 "orientation" : orientationlabel,