Changeset 1573
- Timestamp:
- 06/27/04 01:20:01 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r1572 r1573 24 24 - 1.19alpha27 : 25 25 26 - Additionnal 10% speed increase in PCL5 parser for GhostScript 27 generated files (untested yet with other PCL files). 28 26 29 - Reintroduced the use of mmap in PCL5 parser : this speedups 27 30 PCL5 parsing by almost 4 times. -
pykota/trunk/pykota/pdlanalyzer.py
r1572 r1573 22 22 # 23 23 # $Log$ 24 # Revision 1.17 2004/06/26 23:20:01 jalet 25 # Additionnal speedup for GhostScript generated PCL5 files 26 # 24 27 # Revision 1.16 2004/06/26 15:31:00 jalet 25 28 # mmap reintroduced in PCL5 parser … … 114 117 def getJobSize(self) : 115 118 """Counts pages in a PDF document.""" 116 regexp = re.compile(r"(/Type) ?(/Page)[/ \ r\n]")119 regexp = re.compile(r"(/Type) ?(/Page)[/ \t\r\n]") 117 120 pagecount = 0 118 121 for line in self.infile.xreadlines() : … … 151 154 "*c" : "W", 152 155 "(f" : "W", 153 "*b" : "VW",154 156 "(s" : "W", 155 157 ")s" : "W", … … 157 159 "&l" : "XH", 158 160 "&a" : "G", 161 # "*b" : "VW", # treated specially because it occurs very often 159 162 } 160 163 pagecount = resets = ejects = backsides = 0 … … 192 195 continue # skip to next tag 193 196 tag = tagstart + minfile[pos] ; pos += 1 194 try : 195 tagend = tagsends[tag] 196 except KeyError : 197 pass # Unsupported PCL tag 197 if tag == "*b" : 198 tagend = "VW" 198 199 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 200 try : 201 tagend = tagsends[tag] 202 except KeyError : 203 continue # Unsupported PCL tag 204 # Now read the numeric argument 205 size = 0 206 while 1 : 207 char = minfile[pos] ; pos += 1 208 if not char.isdigit() : 209 break 210 size = (size * 10) + int(char) 211 if char in tagend : 212 if (tag == "&l") and (char == "X") : # copies for current page 213 copies[pagecount] = size 214 elif (tag == "&l") and (char == "H") and (size == 0) : 215 ejects += 1 # Eject 216 elif (tag == "&a") and (size == 2) : 217 backsides += 1 # Back side in duplex mode 218 else : 219 # we just ignore the block. 220 if tag == "&n" : 221 # we have to take care of the operation id byte 222 # which is before the string itself 223 size += 1 224 pos += size 220 225 except IndexError : # EOF ? 221 226 minfile.close() # reached EOF