Changeset 529 for pkpgcounter/trunk/pkpgpdls
- Timestamp:
- 11/28/07 20:48:45 (17 years ago)
- Location:
- pkpgcounter/trunk/pkpgpdls
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/analyzer.py
r527 r529 166 166 plain) : # IMPORTANT : don't move this one up ! 167 167 try : 168 return module.Parser(self, (firstblock, lastblock)) 168 return module.Parser(self, self.filename, 169 (firstblock, lastblock)) 169 170 except pdlparser.PDLParserError : 170 171 pass # try next parser -
pkpgcounter/trunk/pkpgpdls/mscrap.py
r527 r529 24 24 25 25 import os 26 import urllib226 import tempfile 27 27 28 28 import pdlparser … … 56 56 57 57 def getJobSize(self) : 58 """Counts pages in a Microsoft Word (r) (tm) (c) (etc...) document.""" 59 return 0 58 """Counts pages in a Microsoft Word (r) (tm) (c) (etc...) document. 59 60 First we convert from .doc to .ps, then we use the PostScript parser. 61 """ 62 doctops = 'xvfb-run -a abiword --import-extension=.doc --print="%(outfname)s" "%(infname)s"' 63 workfile = tempfile.NamedTemporaryFile(mode="w+b") 64 try : 65 outfname = workfile.name 66 infname = self.filename 67 status = os.system(doctops % locals()) 68 if status or not os.stat(outfname).st_size : 69 raise pdlparser.PDLParserError, "Impossible to convert input document %(infname)s to PostScript" % locals() 70 psinputfile = open(outfname, "rb") 71 try : 72 (first, last) = self.parent.readFirstAndLastBlocks(psinputfile) 73 import postscript 74 return postscript.Parser(self.parent, 75 outfname, 76 (first, last)).getJobSize() 77 finally : 78 psinputfile.close() 79 finally : 80 workfile.close() 81 raise pdlparser.PDLParserError, "Impossible to count pages in %(infname)s" % locals() -
pkpgcounter/trunk/pkpgpdls/pdlparser.py
r527 r529 43 43 required = [] # Default list of required commands 44 44 openmode = "rb" # Default file opening mode 45 def __init__(self, parent, (firstblock, lastblock)) :45 def __init__(self, parent, filename, (firstblock, lastblock)) : 46 46 """Initialize the generic parser.""" 47 47 self.parent = parent 48 48 # We need some copies for later inclusion of parsers which 49 49 # would modify the parent's values 50 self.filename = parent.filename[:]50 self.filename = filename[:] 51 51 self.firstblock = firstblock[:] 52 52 self.lastblock = lastblock[:] -
pkpgcounter/trunk/pkpgpdls/version.py
r517 r529 22 22 23 23 24 __version__ = "3.40 alpha"24 __version__ = "3.40" 25 25 26 26 __doc__ = """pkpgcounter : a generic Page Description Languages parser."""