Index: pkpgcounter/trunk/pkpgpdls/analyzer.py
===================================================================
--- pkpgcounter/trunk/pkpgpdls/analyzer.py (revision 3410)
+++ pkpgcounter/trunk/pkpgpdls/analyzer.py (revision 3436)
@@ -8,10 +8,10 @@
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
-# 
+#
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
-# 
+#
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
@@ -43,21 +43,21 @@
         self.colorspace = colorspace
         self.resolution = resolution
-    
-    
-class PDLAnalyzer :    
+
+
+class PDLAnalyzer :
     """Class for PDL autodetection."""
     def __init__(self, filename, options=AnalyzerOptions()) :
         """Initializes the PDL analyzer.
-        
+
            filename is the name of the file or '-' for stdin.
-           filename can also be a file-like object which 
+           filename can also be a file-like object which
            supports read() and seek().
         """
         self.options = options
         self.filename = filename
-        self.workfile = None 
+        self.workfile = None
         self.mustclose = None
-        
-    def getJobSize(self) :    
+
+    def getJobSize(self) :
         """Returns the job's size."""
         size = 0
@@ -67,10 +67,10 @@
                 pdlhandler = self.detectPDLHandler()
                 size = pdlhandler.getJobSize()
-            except pdlparser.PDLParserError, msg :    
+            except pdlparser.PDLParserError, msg :
                 raise pdlparser.PDLParserError, "Unsupported file format for %s (%s)" % (self.filename, msg)
-        finally :    
+        finally :
             self.closeFile()
         return size
-            
+
     def getInkCoverage(self, colorspace=None, resolution=None) :
         """Extracts the percents of ink coverage from the input file."""
@@ -89,43 +89,43 @@
                     pdlhandler.convertToTiffMultiPage24NC(filename, self.options.resolution)
                     result = inkcoverage.getInkCoverage(filename, cspace)
-                finally :    
+                finally :
                     dummyfile.close()
-            except pdlparser.PDLParserError, msg :    
+            except pdlparser.PDLParserError, msg :
                 raise pdlparser.PDLParserError, "Unsupported file format for %s (%s)" % (self.filename, msg)
         finally :
             self.closeFile()
         return result
-        
-    def openFile(self) :    
+
+    def openFile(self) :
         """Opens the job's data stream for reading."""
         self.mustclose = False  # by default we don't want to close the file when finished
         if hasattr(self.filename, "read") and hasattr(self.filename, "seek") :
-            # filename is in fact a file-like object 
+            # filename is in fact a file-like object
             infile = self.filename
         elif self.filename == "-" :
             # we must read from stdin
             infile = sys.stdin
-        else :    
+        else :
             # normal file
             self.workfile = open(self.filename, "rb")
             self.mustclose = True
             return
-            
+
         # Use a temporary file, always seekable contrary to standard input.
         self.workfile = tempfile.NamedTemporaryFile(mode="w+b")
         self.filename = self.workfile.name
         while True :
-            data = infile.read(pdlparser.MEGABYTE) 
+            data = infile.read(pdlparser.MEGABYTE)
             if not data :
                 break
             self.workfile.write(data)
-        self.workfile.flush()    
+        self.workfile.flush()
         self.workfile.seek(0)
-            
-    def closeFile(self) :        
+
+    def closeFile(self) :
         """Closes the job's data stream if we have to."""
         if self.mustclose :
-            self.workfile.close()    
-        
+            self.workfile.close()
+
     def readFirstAndLastBlocks(self, inputfile) :
         """Reads the first and last blocks of data."""
@@ -136,17 +136,17 @@
             inputfile.seek(-pdlparser.LASTBLOCKSIZE, 2)
             lastblock = inputfile.read(pdlparser.LASTBLOCKSIZE)
-        except IOError :    
+        except IOError :
             lastblock = ""
-        return (firstblock, lastblock)     
-            
-    def detectPDLHandler(self) :    
+        return (firstblock, lastblock)
+
+    def detectPDLHandler(self) :
         """Tries to autodetect the document format.
-        
+
            Returns the correct PDL handler class or None if format is unknown
-        """   
+        """
         if not os.stat(self.filename).st_size :
             raise pdlparser.PDLParserError, "input file %s is empty !" % str(self.filename)
         (firstblock, lastblock) = self.readFirstAndLastBlocks(self.workfile)
-            
+
         # IMPORTANT : the order is important below. FIXME.
         for module in (postscript, \
@@ -170,16 +170,16 @@
                        mscrap, \
                        plain) :     # IMPORTANT : don't move this one up !
-            try :               
-                return module.Parser(self, self.filename, 
+            try :
+                return module.Parser(self, self.filename,
                                            (firstblock, lastblock))
             except pdlparser.PDLParserError :
                 pass # try next parser
         raise pdlparser.PDLParserError, "Analysis of first data block failed."
-            
-def main() :    
+
+def main() :
     """Entry point for PDL Analyzer."""
     import optparse
     from copy import copy
-    
+
     def check_cichoice(option, opt, value) :
         """To add a CaseIgnore Choice option type."""
@@ -187,10 +187,10 @@
         if valower in [v.lower() for v in option.cichoices] :
             return valower
-        else :    
+        else :
             choices = ", ".join([repr(o) for o in option.cichoices])
             raise optparse.OptionValueError(
                 "option %s: invalid choice: %r (choose from %s)"
                 % (opt, value, choices))
-    
+
     class MyOption(optparse.Option) :
         """New Option class, with CaseIgnore Choice type."""
@@ -199,23 +199,23 @@
         TYPE_CHECKER = copy(optparse.Option.TYPE_CHECKER)
         TYPE_CHECKER["cichoice"] = check_cichoice
-        
-    parser = optparse.OptionParser(option_class=MyOption, 
+
+    parser = optparse.OptionParser(option_class=MyOption,
                                    usage="python analyzer.py [options] file1 [file2 ...]")
-    parser.add_option("-v", "--version", 
-                            action="store_true", 
+    parser.add_option("-v", "--version",
+                            action="store_true",
                             dest="version",
                             help="Show pkpgcounter's version number and exit.")
-    parser.add_option("-d", "--debug", 
-                            action="store_true", 
+    parser.add_option("-d", "--debug",
+                            action="store_true",
                             dest="debug",
                             help="Activate debug mode.")
-    parser.add_option("-c", "--colorspace", 
+    parser.add_option("-c", "--colorspace",
                             dest="colorspace",
                             type="cichoice",
                             cichoices=["bw", "rgb", "cmyk", "cmy", "gc"],
                             help="Activate the computation of ink usage, and defines the colorspace to use. Supported values are 'BW', 'RGB', 'CMYK', 'CMY', and 'GC'.")
-    parser.add_option("-r", "--resolution", 
-                            type="int", 
-                            default=72, 
+    parser.add_option("-r", "--resolution",
+                            type="int",
+                            default=72,
                             dest="resolution",
                             help="The resolution in DPI to use when checking ink usage. Lower resolution is faster but less accurate. Default is 72 dpi.")
@@ -223,5 +223,5 @@
     if options.version :
         print "%s" % version.__version__
-    elif not (72 <= options.resolution <= 1200) :    
+    elif not (72 <= options.resolution <= 1200) :
         sys.stderr.write("ERROR: the argument to the --resolution command line option must be between 72 and 1200.\n")
         sys.stderr.flush()
@@ -229,5 +229,5 @@
         if (not arguments) or ((not sys.stdin.isatty()) and ("-" not in arguments)) :
             arguments.append("-")
-        totalsize = 0    
+        totalsize = 0
         lines = []
         try :
@@ -246,16 +246,16 @@
                                 except KeyError :
                                     pass
-                            lines.append("      ".join(lineparts))     
-                except (IOError, pdlparser.PDLParserError), msg :    
+                            lines.append("      ".join(lineparts))
+                except (IOError, pdlparser.PDLParserError), msg :
                     sys.stderr.write("ERROR: %s\n" % msg)
                     sys.stderr.flush()
-        except KeyboardInterrupt :            
+        except KeyboardInterrupt :
             sys.stderr.write("WARN: Aborted at user's request.\n")
             sys.stderr.flush()
-        if not options.colorspace :    
+        if not options.colorspace :
             print "%i" % totalsize
-        else :    
+        else :
             print "\n".join(lines)
-    
-if __name__ == "__main__" :    
+
+if __name__ == "__main__" :
     main()
