Changeset 1449
- Timestamp:
- 05/04/04 14:21:55 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkpgcounter
r1448 r1449 24 24 # 25 25 # $Log$ 26 # Revision 1.4 2004/05/04 12:21:55 jalet 27 # Now uses mmap in PCL mode 28 # 26 29 # Revision 1.3 2004/05/04 04:39:26 jalet 27 30 # Better PCL support … … 36 39 37 40 import sys 41 import os 42 import mmap 38 43 import tempfile 39 44 … … 81 86 # published under the terms of the GNU General Public Licence v2. 82 87 # 83 # Backported from C to Python by Jerome Alet 88 # Backported from C to Python by Jerome Alet, then enhanced 89 # with more PCL tags detected. I think all the necessary PCL tags 90 # are recognized to correctly handle PCL5e files wrt their number 91 # of pages 84 92 # 93 infileno = infile.fileno() 94 infile = mmap.mmap(infileno, os.fstat(infileno).st_size, access=mmap.ACCESS_READ) 85 95 tagsends = { "&n" : "W", "&b": "W", "*i" : "W", "*l" : "W", "*m" : "W", "*v": "W", "*c" : "W", "(f" : "W", "*b" : "VW", "(s" : "W", ")s" : "W", "&p" : "X", "&l" : "X" } 86 96 copies = 1 87 97 pagecount = 0 88 98 tag = None 99 position = 0 89 100 while 1 : 90 char = infile.read(1) # TODO : speed this up if possible 101 try : 102 char = infile[position] 103 except IndexError : # EOF 104 break 105 position += 1 91 106 if not char : 92 107 break … … 110 125 # <ESC>&p###X -> Start of a non printable characters block 111 126 # 112 tagstart = infile.read(1) 127 tagstart = infile[position] 128 position += 1 113 129 if tagstart in "E9=YZ" : # one byte PCL tag 114 130 continue # skip to next tag 115 tag = tagstart + infile.read(1) 131 tag = tagstart + infile[position] 132 position += 1 116 133 try : 117 134 tagend = tagsends[tag] … … 122 139 size = 0 123 140 while 1 : 124 char = infile.read(1) 141 char = infile[position] 142 position += 1 125 143 if not char.isdigit() : 126 144 break … … 137 155 # which is before the string itself 138 156 size += 1 139 infile.read(size)157 position += size 140 158 return copies * pagecount 141 159 -
pykota/trunk/NEWS
r1448 r1449 28 28 29 29 - improved PCL support in pkpgcounter. 30 31 - pkpgcounter now uses mmap to speed things up : duration 32 is halved with the sample 87 pages PCL document I use. 30 33 31 34 - 1.19alpha3 :