Changeset 220 for pkpgcounter/trunk/pdlanalyzer/postscript.py
- Timestamp:
- 07/02/05 15:41:30 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pdlanalyzer/postscript.py
r211 r220 27 27 from pdlanalyzer import pdlparser 28 28 29 class P ostScriptParser(pdlparser.PDLParser) :29 class Parser(pdlparser.PDLParser) : 30 30 """A parser for PostScript documents.""" 31 def isValid(self) : 32 """Returns 1 if data is PostScript, else 0.""" 33 if self.firstblock.startswith("%!") or \ 34 self.firstblock.startswith("\004%!") or \ 35 self.firstblock.startswith("\033%-12345X%!PS") or \ 36 ((self.firstblock[:128].find("\033%-12345X") != -1) and \ 37 ((self.firstblock.find("LANGUAGE=POSTSCRIPT") != -1) or \ 38 (self.firstblock.find("LANGUAGE = POSTSCRIPT") != -1) or \ 39 (self.firstblock.find("LANGUAGE = Postscript") != -1))) or \ 40 (self.firstblock.find("%!PS-Adobe") != -1) : 41 if self.debug : 42 sys.stderr.write("DEBUG: Input file is in the PostScript format.\n") 43 return 1 44 else : 45 return 0 46 31 47 def throughGhostScript(self) : 32 48 """Get the count through GhostScript, useful for non-DSC compliant PS files.""" … … 112 128 mustclose = 1 113 129 try : 114 parser = P ostScriptParser(infile, debug=1)130 parser = Parser(infile, debug=1) 115 131 totalsize += parser.getJobSize() 116 132 except pdlparser.PDLParserError, msg :