Show
Ignore:
Timestamp:
10/06/08 00:22:07 (16 years ago)
Author:
jerome
Message:

Removed spaces at EOL.

Files:
1 modified

Legend:

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

    r3410 r3436  
    88# the Free Software Foundation, either version 3 of the License, or 
    99# (at your option) any later version. 
    10 #  
     10# 
    1111# This program is distributed in the hope that it will be useful, 
    1212# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1313# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1414# GNU General Public License for more details. 
    15 #  
     15# 
    1616# You should have received a copy of the GNU General Public License 
    1717# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     
    2525import os 
    2626 
    27 KILOBYTE = 1024     
    28 MEGABYTE = 1024 * KILOBYTE     
     27KILOBYTE = 1024 
     28MEGABYTE = 1024 * KILOBYTE 
    2929FIRSTBLOCKSIZE = 16 * KILOBYTE 
    3030LASTBLOCKSIZE = int(KILOBYTE / 4) 
     
    3838        return self.message 
    3939    __str__ = __repr__ 
    40          
     40 
    4141class PDLParser : 
    4242    """Generic PDL parser.""" 
     
    5656        if not self.isValid() : 
    5757            raise PDLParserError, "Invalid file format !" 
    58         else :     
     58        else : 
    5959            self.logdebug("Input file is in the '%s' file format." % self.format) 
    6060        try : 
    61             import psyco  
    62         except ImportError :     
     61            import psyco 
     62        except ImportError : 
    6363            pass # Psyco is not installed 
    64         else :     
     64        else : 
    6565            # Psyco is installed, tell it to compile 
    6666            # the CPU intensive methods : PCL and PCLXL 
     
    6969        self.infile = open(self.filename, self.openmode) 
    7070        # self.logdebug("Opened %s in '%s' mode." % (self.filename, self.openmode)) 
    71              
     71 
    7272    def __del__(self) : 
    7373        """Ensures the input file gets closed.""" 
    7474        if self.infile : 
    7575            self.infile.close() 
    76              
     76 
    7777    def findExecutable(self, command) : 
    7878        """Finds an executable in the PATH and returns True if found else False.""" 
     
    8383                    return True 
    8484        return False 
    85          
    86     def isMissing(self, commands) :     
    87         """Returns True if some required commands are missing, else False."""  
     85 
     86    def isMissing(self, commands) : 
     87        """Returns True if some required commands are missing, else False.""" 
    8888        howmanythere = 0 
    8989        for command in commands : 
     
    9191                sys.stderr.write("ERROR: %(command)s is missing or not executable. You MUST install it for pkpgcounter to be able to do what you want.\n" % locals()) 
    9292                sys.stderr.flush() 
    93             else :     
     93            else : 
    9494                howmanythere += 1 
    9595        if howmanythere == len(commands) : 
    9696            return False 
    97         else :    
     97        else : 
    9898            return True 
    99          
    100     def logdebug(self, message) :        
     99 
     100    def logdebug(self, message) : 
    101101        """Logs a debug message if needed.""" 
    102102        if self.parent.options.debug : 
    103103            sys.stderr.write("%s\n" % message) 
    104              
    105     def isValid(self) :     
     104 
     105    def isValid(self) : 
    106106        """Returns True if data is in the expected format, else False.""" 
    107107        raise RuntimeError, "Not implemented !" 
    108          
    109     def getJobSize(self) :     
     108 
     109    def getJobSize(self) : 
    110110        """Counts pages in a document.""" 
    111111        raise RuntimeError, "Not implemented !" 
    112          
     112 
    113113    def convertToTiffMultiPage24NC(self, outfname, dpi) : 
    114114        """Converts the input file to TIFF format, X dpi, 24 bits per pixel, uncompressed. 
    115115           Writes TIFF datas to the file named by outfname. 
    116         """    
     116        """ 
    117117        if self.totiffcommands : 
    118118            if self.isMissing(self.required) : 
     
    127127                    if os.WEXITSTATUS(status) : 
    128128                        error = True 
    129                 else :         
     129                else : 
    130130                    error = True 
    131131                if not os.path.exists(outfname) : 
     
    133133                elif not os.stat(outfname).st_size : 
    134134                    error = True 
    135                 else :         
     135                else : 
    136136                    break       # Conversion worked fine it seems. 
    137137                sys.stderr.write("Command failed : %s\n" % repr(commandline)) 
    138138            if error : 
    139139                raise PDLParserError, "Problem during conversion to TIFF." 
    140         else :         
     140        else : 
    141141            raise PDLParserError, "Impossible to compute ink coverage for this file format."