Show
Ignore:
Timestamp:
08/26/06 23:39:31 (18 years ago)
Author:
jerome
Message:

Refactored some duplicate code.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/pkpgpdls/postscript.py

    r363 r371  
    3434class Parser(pdlparser.PDLParser) : 
    3535    """A parser for PostScript documents.""" 
     36    totiffcommand = 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' 
    3637    def isValid(self) :     
    3738        """Returns 1 if data is PostScript, else 0.""" 
     
    177178        return self.natively() or self.throughGhostScript() 
    178179         
    179     def convertToTiffMultiPage24NC(self, fname, dpi) : 
    180         """Converts the input file to TIFF format, X dpi, 24 bits per pixel, uncompressed. 
    181            Writes TIFF datas to the outputfile file object. 
    182         """    
    183         command = 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%i -sOutputFile="%s" -' % (dpi, fname) 
    184         child = popen2.Popen4(command) 
    185         try : 
    186             data = self.infile.read(pdlparser.MEGABYTE)     
    187             while data : 
    188                 child.tochild.write(data) 
    189                 data = self.infile.read(pdlparser.MEGABYTE) 
    190             child.tochild.flush() 
    191             child.tochild.close()     
    192         except (IOError, OSError), msg :     
    193             raise pdlparser.PDLParserError, "Problem during conversion to TIFF : %s" % msg 
    194              
    195         child.fromchild.close() 
    196         try : 
    197             child.wait() 
    198         except OSError, msg :     
    199             raise pdlparser.PDLParserError, "Problem during conversion to TIFF : %s" % msg 
    200          
    201180def test() :         
    202181    """Test function."""