187 | | while 1 : |
188 | | char = self.readone() |
189 | | if not char : # EOF ? |
190 | | break |
191 | | if char == "\014" : |
192 | | pagecount += 1 |
193 | | elif char == "\033" : |
194 | | # |
195 | | # <ESC>*b###W -> Start of a raster data row/block |
196 | | # <ESC>*b###V -> Start of a raster data plane |
197 | | # <ESC>*c###W -> Start of a user defined pattern |
198 | | # <ESC>*i###W -> Start of a viewing illuminant block |
199 | | # <ESC>*l###W -> Start of a color lookup table |
200 | | # <ESC>*m###W -> Start of a download dither matrix block |
201 | | # <ESC>*v###W -> Start of a configure image data block |
202 | | # <ESC>(s###W -> Start of a characters description block |
203 | | # <ESC>)s###W -> Start of a fonts description block |
204 | | # <ESC>(f###W -> Start of a symbol set block |
205 | | # <ESC>&b###W -> Start of configuration data block |
206 | | # <ESC>&l###X -> Number of copies for current page |
207 | | # <ESC>&n###W -> Starts an alphanumeric string ID block |
208 | | # <ESC>&p###X -> Start of a non printable characters block |
209 | | # <ESC>&a2G -> Back side when duplex mode as generated by rastertohp |
210 | | # <ESC>&l0H -> Eject if NumPlanes > 1, as generated by rastertohp |
211 | | # |
212 | | tagstart = self.readone() |
213 | | if tagstart in "E9=YZ" : # one byte PCL tag |
214 | | if tagstart == "E" : |
215 | | resets += 1 |
216 | | continue # skip to next tag |
217 | | tag = tagstart + self.readone() |
218 | | try : |
219 | | tagend = tagsends[tag] |
220 | | except KeyError : |
221 | | pass # Unsupported PCL tag |
222 | | else : |
223 | | # Now read the numeric argument |
224 | | size = 0 |
225 | | while 1 : |
226 | | char = self.readone() |
227 | | if not char.isdigit() : |
228 | | break |
229 | | size = (size * 10) + int(char) |
230 | | if char in tagend : |
231 | | if (tag == "&l") and (char == "X") : # copies for current page |
232 | | copies[pagecount] = size |
233 | | elif (tag == "&l") and (char == "H") and (size == 0) : |
234 | | ejects += 1 # Eject |
235 | | elif (tag == "&a") and (size == 2) : |
236 | | backsides += 1 # Back side in duplex mode |
237 | | else : |
238 | | # doing a read will prevent the seek |
239 | | # for unseekable streams. |
240 | | # we just ignore the block anyway. |
241 | | if tag == "&n" : |
242 | | # we have to take care of the operation id byte |
243 | | # which is before the string itself |
244 | | size += 1 |
245 | | self.skip(size) |
| 163 | pos = 0 |
| 164 | try : |
| 165 | while 1 : |
| 166 | char = minfile[pos] ; pos += 1 |
| 167 | if char == "\014" : |
| 168 | pagecount += 1 |
| 169 | elif char == "\033" : |
| 170 | # |
| 171 | # <ESC>*b###W -> Start of a raster data row/block |
| 172 | # <ESC>*b###V -> Start of a raster data plane |
| 173 | # <ESC>*c###W -> Start of a user defined pattern |
| 174 | # <ESC>*i###W -> Start of a viewing illuminant block |
| 175 | # <ESC>*l###W -> Start of a color lookup table |
| 176 | # <ESC>*m###W -> Start of a download dither matrix block |
| 177 | # <ESC>*v###W -> Start of a configure image data block |
| 178 | # <ESC>(s###W -> Start of a characters description block |
| 179 | # <ESC>)s###W -> Start of a fonts description block |
| 180 | # <ESC>(f###W -> Start of a symbol set block |
| 181 | # <ESC>&b###W -> Start of configuration data block |
| 182 | # <ESC>&l###X -> Number of copies for current page |
| 183 | # <ESC>&n###W -> Starts an alphanumeric string ID block |
| 184 | # <ESC>&p###X -> Start of a non printable characters block |
| 185 | # <ESC>&a2G -> Back side when duplex mode as generated by rastertohp |
| 186 | # <ESC>&l0H -> Eject if NumPlanes > 1, as generated by rastertohp |
| 187 | # |
| 188 | tagstart = minfile[pos] ; pos += 1 |
| 189 | if tagstart in "E9=YZ" : # one byte PCL tag |
| 190 | if tagstart == "E" : |
| 191 | resets += 1 |
| 192 | continue # skip to next tag |
| 193 | tag = tagstart + minfile[pos] ; pos += 1 |
| 194 | try : |
| 195 | tagend = tagsends[tag] |
| 196 | except KeyError : |
| 197 | pass # Unsupported PCL tag |
| 198 | else : |
| 199 | # Now read the numeric argument |
| 200 | size = 0 |
| 201 | while 1 : |
| 202 | char = minfile[pos] ; pos += 1 |
| 203 | if not char.isdigit() : |
| 204 | break |
| 205 | size = (size * 10) + int(char) |
| 206 | if char in tagend : |
| 207 | if (tag == "&l") and (char == "X") : # copies for current page |
| 208 | copies[pagecount] = size |
| 209 | elif (tag == "&l") and (char == "H") and (size == 0) : |
| 210 | ejects += 1 # Eject |
| 211 | elif (tag == "&a") and (size == 2) : |
| 212 | backsides += 1 # Back side in duplex mode |
| 213 | else : |
| 214 | # we just ignore the block. |
| 215 | if tag == "&n" : |
| 216 | # we have to take care of the operation id byte |
| 217 | # which is before the string itself |
| 218 | size += 1 |
| 219 | pos += size |
| 220 | except IndexError : # EOF ? |
| 221 | minfile.close() # reached EOF |