Changeset 1485
- Timestamp:
- 05/19/04 21:09:36 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r1483 r1485 24 24 - 1.19alpha10 : 25 25 26 - 25% Speedup in PCL parser. Getting more of the Python version 27 will probably be difficult, since the completely table driven 28 parser I wrote is slower than the original algorithm. Then, 29 the original algorithm is still used for now. 30 Probable that more speed could be achieved using mmap, at the 31 expense of severe memory consumption. 32 26 33 - configuration simplifications : the "accounter" directive's 27 34 'hardware' arguments now accepts what was in the "requester" -
pykota/trunk/pykota/pdlanalyzer.py
r1482 r1485 22 22 # 23 23 # $Log$ 24 # Revision 1.2 2004/05/19 19:09:36 jalet 25 # Speed improvement 26 # 24 27 # Revision 1.1 2004/05/18 09:59:54 jalet 25 28 # pkpgcounter is now just a wrapper around the PDLAnalyzer class … … 54 57 """Initialize PCL Analyzer.""" 55 58 self.infile = infile 59 60 def skip(self, nb) : 61 """Reads a new datablock.""" 62 newpos = self.pos + nb 63 if newpos >= self.len : 64 oldlen = self.len 65 self.data = self.infile.read(1024*1024) 66 self.len = len(self.data) 67 if not self.len : 68 return 69 self.pos = newpos - oldlen 70 else : 71 self.pos = newpos 72 73 def readone(self) : 74 """Reads a new byte.""" 75 if self.pos < self.len : 76 char = self.data[self.pos] 77 else : 78 self.data = self.infile.read(1024*1024) 79 self.len = len(self.data) 80 self.pos = 0 81 if not self.len : 82 return 83 char = self.data[0] 84 self.pos += 1 85 return char 56 86 57 87 def getJobSize(self) : … … 84 114 "&p" : "X", 85 115 "&l" : "X" } 116 self.data = [] 117 self.pos = self.len = 0 86 118 copies = 1 87 119 pagecount = resets = 0 88 120 tag = None 89 121 while 1 : 90 char = self. infile.read(1)122 char = self.readone() 91 123 if not char : # EOF ? 92 124 break … … 110 142 # <ESC>&p###X -> Start of a non printable characters block 111 143 # 112 tagstart = self. infile.read(1)144 tagstart = self.readone() 113 145 if tagstart in "E9=YZ" : # one byte PCL tag 114 146 if tagstart == "E" : 115 147 resets += 1 116 148 continue # skip to next tag 117 tag = tagstart + self. infile.read(1)149 tag = tagstart + self.readone() 118 150 try : 119 151 tagend = tagsends[tag] … … 124 156 size = 0 125 157 while 1 : 126 char = self. infile.read(1)158 char = self.readone() 127 159 if not char.isdigit() : 128 160 break … … 139 171 # which is before the string itself 140 172 size += 1 141 self. infile.read(size) # skips block, while avoiding seek()173 self.skip(size) 142 174 143 175 # if pagecount is still 0, we will return the number