25 | | from pdlanalyzer import version, pdlparser, postscript, pdf, pcl345, pclxl, escp2, dvi |
| 25 | from pdlanalyzer import version, pdlparser, postscript, pdf, pcl345, pclxl, escp2, dvi, tiff |
183 | | sys.stderr.write("%s is an DVI file\n" % str(self.filename)) |
| 184 | sys.stderr.write("%s is a DVI file\n" % str(self.filename)) |
| 185 | return 1 |
| 186 | else : |
| 187 | return 0 |
| 188 | |
| 189 | def isTIFF(self, sdata, edata) : |
| 190 | """Returns 1 if data is TIFF, else 0.""" |
| 191 | littleendian = (chr(0x49)*2) + chr(0x2a) + chr(0) |
| 192 | bigendian = (chr(0x4d)*2) + chr(0) + chr(0x2a) |
| 193 | if sdata[:4] in (littleendian, bigendian) : |
| 194 | if self.debug : |
| 195 | sys.stderr.write("%s is a TIFF file\n" % str(self.filename)) |
202 | | if self.isPostScript(firstblock, lastblock) : |
203 | | return postscript.PostScriptParser |
204 | | elif self.isPCLXL(firstblock, lastblock) : |
205 | | return pclxl.PCLXLParser |
206 | | elif self.isPDF(firstblock, lastblock) : |
207 | | return pdf.PDFParser |
208 | | elif self.isPCL(firstblock, lastblock) : |
209 | | return pcl345.PCL345Parser |
210 | | elif self.isESCP2(firstblock, lastblock) : |
211 | | return escp2.ESCP2Parser |
212 | | elif self.isDVI(firstblock, lastblock) : |
213 | | return dvi.DVIParser |
214 | | else : |
215 | | raise pdlparser.PDLParserError, "Analysis of first data block failed." |
| 214 | if not firstblock : |
| 215 | sys.stderr.write("ERROR: input file %s is empty !\n" % str(self.filename)) |
| 216 | else : |
| 217 | if self.isPostScript(firstblock, lastblock) : |
| 218 | return postscript.PostScriptParser |
| 219 | elif self.isPCLXL(firstblock, lastblock) : |
| 220 | return pclxl.PCLXLParser |
| 221 | elif self.isPDF(firstblock, lastblock) : |
| 222 | return pdf.PDFParser |
| 223 | elif self.isPCL(firstblock, lastblock) : |
| 224 | return pcl345.PCL345Parser |
| 225 | elif self.isESCP2(firstblock, lastblock) : |
| 226 | return escp2.ESCP2Parser |
| 227 | elif self.isDVI(firstblock, lastblock) : |
| 228 | return dvi.DVIParser |
| 229 | elif self.isTIFF(firstblock, lastblock) : |
| 230 | return tiff.TIFFParser |
| 231 | raise pdlparser.PDLParserError, "Analysis of first data block failed." |