Index: pkpgcounter/trunk/tests/runtest.sh
===================================================================
--- pkpgcounter/trunk/tests/runtest.sh (revision 197)
+++ pkpgcounter/trunk/tests/runtest.sh (revision 200)
@@ -11,8 +11,8 @@
 
 echo -n "File master.ps should be 16 pages long, result is : "
-python ../pdlanalyzer/pdlanalyzer.py master2.ps
+python ../pdlanalyzer/pdlparser.py master2.ps
 
 echo "Analyzing testsuite..."
 for file in testsuite.* ; do
-    echo -n "$file ===> " && python ../pdlanalyzer/pdlanalyzer.py "$file" ;
+    echo -n "$file ===> " && python ../pdlanalyzer/pdlparser.py "$file" ;
 done    
Index: pkpgcounter/trunk/pdlanalyzer/pdf.py
===================================================================
--- pkpgcounter/trunk/pdlanalyzer/pdf.py (revision 196)
+++ pkpgcounter/trunk/pdlanalyzer/pdf.py (revision 200)
@@ -25,7 +25,7 @@
 import re
 
-from pdlanalyzer.pdlparser import PDLParser, PDLParserError
+from pdlanalyzer import pdlparser
 
-class PDFParser(PDLParser) :
+class PDFParser(pdlparser.PDLParser) :
     """A parser for PDF documents."""
     def getJobSize(self) :    
@@ -52,5 +52,5 @@
             parser = PDFParser(infile, debug=1)
             totalsize += parser.getJobSize()
-        except PDLParserError, msg :    
+        except pdlparser.PDLParserError, msg :    
             sys.stderr.write("ERROR: %s\n" % msg)
             sys.stderr.flush()
Index: pkpgcounter/trunk/pdlanalyzer/pcl345.py
===================================================================
--- pkpgcounter/trunk/pdlanalyzer/pcl345.py (revision 196)
+++ pkpgcounter/trunk/pdlanalyzer/pcl345.py (revision 200)
@@ -25,7 +25,7 @@
 import mmap
 
-from pdlanalyzer.pdlparser import PDLParser, PDLParserError
+from pdlanalyzer import pdlparser
 
-class PCLParser(PDLParser) :
+class PCL345Parser(pdlparser.PDLParser) :
     """A parser for PCL3, PCL4, PCL5 documents."""
     mediasizes = {  # ESC&l####A
@@ -345,5 +345,5 @@
             parser = PCL345Parser(infile, debug=1)
             totalsize += parser.getJobSize()
-        except PDLParserError, msg :    
+        except pdlparser.PDLParserError, msg :    
             sys.stderr.write("ERROR: %s\n" % msg)
             sys.stderr.flush()
Index: pkpgcounter/trunk/pdlanalyzer/postscript.py
===================================================================
--- pkpgcounter/trunk/pdlanalyzer/postscript.py (revision 196)
+++ pkpgcounter/trunk/pdlanalyzer/postscript.py (revision 200)
@@ -25,7 +25,7 @@
 import popen2
 
-from pdlanalyzer.pdlparser import PDLParser, PDLParserError
+from pdlanalyzer import pdlparser
 
-class PostScriptParser(PDLParser) :
+class PostScriptParser(pdlparser.PDLParser) :
     """A parser for PostScript documents."""
     def throughGhostScript(self) :
@@ -44,5 +44,5 @@
             child.tochild.close()    
         except (IOError, OSError), msg :    
-            raise PDLParserError, "Problem during analysis of Binary PostScript document : %s" % msg
+            raise pdlparser.PDLParserError, "Problem during analysis of Binary PostScript document : %s" % msg
             
         pagecount = 0
@@ -50,5 +50,5 @@
             pagecount = int(child.fromchild.readline().strip())
         except (IOError, OSError, AttributeError, ValueError), msg :
-            raise PDLParserError, "Problem during analysis of Binary PostScript document : %s" % msg
+            raise pdlparser.PDLParserError, "Problem during analysis of Binary PostScript document : %s" % msg
         child.fromchild.close()
         
@@ -56,5 +56,5 @@
             child.wait()
         except OSError, msg :    
-            raise PDLParserError, "Problem during analysis of Binary PostScript document : %s" % msg
+            raise pdlparser.PDLParserError, "Problem during analysis of Binary PostScript document : %s" % msg
         return pagecount * self.copies
         
@@ -113,5 +113,5 @@
             parser = PostScriptParser(infile, debug=1)
             totalsize += parser.getJobSize()
-        except PDLParserError, msg :    
+        except pdlparser.PDLParserError, msg :    
             sys.stderr.write("ERROR: %s\n" % msg)
             sys.stderr.flush()
Index: pkpgcounter/trunk/pdlanalyzer/escp2.py
===================================================================
--- pkpgcounter/trunk/pdlanalyzer/escp2.py (revision 196)
+++ pkpgcounter/trunk/pdlanalyzer/escp2.py (revision 200)
@@ -24,7 +24,7 @@
 import sys
 
-from pdlanalyzer.pdlparser import PDLParser, PDLParserError
+from pdlanalyzer import pdlparser
 
-class ESCP2Parser(PDLParser) :
+class ESCP2Parser(pdlparser.PDLParser) :
     """A parser for ESC/P2 documents."""
     def getJobSize(self) :    
@@ -78,5 +78,5 @@
             parser = ESCP2Parser(infile, debug=1)
             totalsize += parser.getJobSize()
-        except PDLParserError, msg :    
+        except pdlparser.PDLParserError, msg :    
             sys.stderr.write("ERROR: %s\n" % msg)
             sys.stderr.flush()
Index: pkpgcounter/trunk/pdlanalyzer/pdlparser.py
===================================================================
--- pkpgcounter/trunk/pdlanalyzer/pdlparser.py (revision 199)
+++ pkpgcounter/trunk/pdlanalyzer/pdlparser.py (revision 200)
@@ -21,15 +21,4 @@
 
 import sys
-import tempfile
-
-from pdlanalyzer.postscript import PostScriptParser
-from pdlanalyzer.pdf import PDFParser
-from pdlanalyzer.pcl345 import PCL345Parser
-from pdlanalyzer.pclxl import PCLXLParser
-from pdlanalyzer.escp2 import ESCP2Parser
-
-KILOBYTE = 1024    
-MEGABYTE = 1024 * KILOBYTE    
-LASTBLOCKSIZE = int(KILOBYTE / 4)
 
 class PDLParserError(Exception):
@@ -52,204 +41,2 @@
         """Counts pages in the document."""
         raise RuntimeError, "Not implemented !"
-        
-class PDLAnalyzer :    
-    """Class for PDL autodetection."""
-    def __init__(self, filename, debug=0) :
-        """Initializes the PDL analyzer.
-        
-           filename is the name of the file or '-' for stdin.
-           filename can also be a file-like object which 
-           supports read() and seek().
-        """
-        self.debug = debug
-        self.filename = filename
-        try :
-            import psyco 
-        except ImportError :    
-            sys.stderr.write("pkpgcounter : you should install psyco if possible, this would greatly speedup parsing.\n")
-            pass # Psyco is not installed
-        else :    
-            # Psyco is installed, tell it to compile
-            # the CPU intensive methods : PCL and PCLXL
-            # parsing will greatly benefit from this, 
-            # for PostScript and PDF the difference is
-            # barely noticeable since they are already
-            # almost optimal, and much more speedy anyway.
-            psyco.bind(PostScriptParser.getJobSize)
-            psyco.bind(PDFParser.getJobSize)
-            psyco.bind(ESCP2Parser.getJobSize)
-            psyco.bind(PCLParser.getJobSize)
-            psyco.bind(PCLXLParser.getJobSize)
-        
-    def getJobSize(self) :    
-        """Returns the job's size."""
-        self.openFile()
-        try :
-            pdlhandler = self.detectPDLHandler()
-        except PDLParserError, msg :    
-            self.closeFile()
-            raise PDLParserError, "ERROR : Unknown file format for %s (%s)" % (self.filename, msg)
-        else :
-            try :
-                size = pdlhandler(self.infile, self.debug).getJobSize()
-            finally :    
-                self.closeFile()
-            return size
-        
-    def openFile(self) :    
-        """Opens the job's data stream for reading."""
-        self.mustclose = 0  # 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 
-            infile = self.filename
-        elif self.filename == "-" :
-            # we must read from stdin
-            infile = sys.stdin
-        else :    
-            # normal file
-            self.infile = open(self.filename, "rb")
-            self.mustclose = 1
-            return
-            
-        # Use a temporary file, always seekable contrary to standard input.
-        self.infile = tempfile.TemporaryFile(mode="w+b")
-        while 1 :
-            data = infile.read(MEGABYTE) 
-            if not data :
-                break
-            self.infile.write(data)
-        self.infile.flush()    
-        self.infile.seek(0)
-            
-    def closeFile(self) :        
-        """Closes the job's data stream if we can close it."""
-        if self.mustclose :
-            self.infile.close()    
-        else :    
-            # if we don't have to close the file, then
-            # ensure the file pointer is reset to the 
-            # start of the file in case the process wants
-            # to read the file again.
-            try :
-                self.infile.seek(0)
-            except :    
-                pass    # probably stdin, which is not seekable
-        
-    def isPostScript(self, sdata, edata) :    
-        """Returns 1 if data is PostScript, else 0."""
-        if sdata.startswith("%!") or \
-           sdata.startswith("\004%!") or \
-           sdata.startswith("\033%-12345X%!PS") or \
-           ((sdata[:128].find("\033%-12345X") != -1) and \
-             ((sdata.find("LANGUAGE=POSTSCRIPT") != -1) or \
-              (sdata.find("LANGUAGE = POSTSCRIPT") != -1) or \
-              (sdata.find("LANGUAGE = Postscript") != -1))) or \
-              (sdata.find("%!PS-Adobe") != -1) :
-            if self.debug :  
-                sys.stderr.write("%s is a PostScript file\n" % str(self.filename))
-            return 1
-        else :    
-            return 0
-        
-    def isPDF(self, sdata, edata) :    
-        """Returns 1 if data is PDF, else 0."""
-        if sdata.startswith("%PDF-") or \
-           sdata.startswith("\033%-12345X%PDF-") or \
-           ((sdata[:128].find("\033%-12345X") != -1) and (sdata.upper().find("LANGUAGE=PDF") != -1)) or \
-           (sdata.find("%PDF-") != -1) :
-            if self.debug :  
-                sys.stderr.write("%s is a PDF file\n" % str(self.filename))
-            return 1
-        else :    
-            return 0
-        
-    def isPCL(self, sdata, edata) :    
-        """Returns 1 if data is PCL, else 0."""
-        if sdata.startswith("\033E\033") or \
-           (sdata.startswith("\033*rbC") and (not edata[-3:] == "\f\033@")) or \
-           sdata.startswith("\033%8\033") or \
-           (sdata.find("\033%-12345X") != -1) :
-            if self.debug :  
-                sys.stderr.write("%s is a PCL3/4/5 file\n" % str(self.filename))
-            return 1
-        else :    
-            return 0
-        
-    def isPCLXL(self, sdata, edata) :    
-        """Returns 1 if data is PCLXL aka PCL6, else 0."""
-        if ((sdata[:128].find("\033%-12345X") != -1) and \
-             (sdata.find(" HP-PCL XL;") != -1) and \
-             ((sdata.find("LANGUAGE=PCLXL") != -1) or \
-              (sdata.find("LANGUAGE = PCLXL") != -1))) :
-            if self.debug :  
-                sys.stderr.write("%s is a PCLXL (aka PCL6) file\n" % str(self.filename))
-            return 1
-        else :    
-            return 0
-            
-    def isESCP2(self, sdata, edata) :        
-        """Returns 1 if data is ESC/P2, else 0."""
-        if sdata.startswith("\033@") or \
-           sdata.startswith("\033*") or \
-           sdata.startswith("\n\033@") or \
-           sdata.startswith("\0\0\0\033\1@EJL") : # ESC/P Raster ??? Seen on Stylus Photo 1284
-            if self.debug :  
-                sys.stderr.write("%s is an ESC/P2 file\n" % str(self.filename))
-            return 1
-        else :    
-            return 0
-    
-    def detectPDLHandler(self) :    
-        """Tries to autodetect the document format.
-        
-           Returns the correct PDL handler class or None if format is unknown
-        """   
-        # Try to detect file type by reading first block of datas    
-        self.infile.seek(0)
-        firstblock = self.infile.read(4 * KILOBYTE)
-        try :
-            self.infile.seek(-LASTBLOCKSIZE, 2)
-            lastblock = self.infile.read(LASTBLOCKSIZE)
-        except IOError :    
-            lastblock = ""
-        self.infile.seek(0)
-        if self.isPostScript(firstblock, lastblock) :
-            return PostScriptParser
-        elif self.isPCLXL(firstblock, lastblock) :    
-            return PCLXLParser
-        elif self.isPDF(firstblock, lastblock) :    
-            return PDFParser
-        elif self.isPCL(firstblock, lastblock) :    
-            return PCLParser
-        elif self.isESCP2(firstblock, lastblock) :    
-            return ESCP2Parser
-        else :    
-            raise PDLParserError, "Analysis of first data block failed."
-            
-def main() :    
-    """Entry point for PDL Analyzer."""
-    if (len(sys.argv) < 2) or ((not sys.stdin.isatty()) and ("-" not in sys.argv[1:])) :
-        sys.argv.append("-")
-        
-    if ("-h" in sys.argv[1:]) or ("--help" in sys.argv[1:]) :
-        print "usage : pkpgcounter file1 file2 ... fileN"
-    elif ("-v" in sys.argv[1:]) or ("--version" in sys.argv[1:]) :
-        print "%s" % version.__version__
-    else :
-        totalsize = 0    
-        debug = 0
-        minindex = 1
-        if sys.argv[1] == "--debug" :
-            minindex = 2
-            debug = 1
-        for arg in sys.argv[minindex:] :
-            try :
-                parser = PDLAnalyzer(arg, debug)
-                totalsize += parser.getJobSize()
-            except PDLParserError, msg :    
-                sys.stderr.write("ERROR: %s\n" % msg)
-                sys.stderr.flush()
-        print "%s" % totalsize
-    
-if __name__ == "__main__" :    
-    main()
Index: pkpgcounter/trunk/pdlanalyzer/pclxl.py
===================================================================
--- pkpgcounter/trunk/pdlanalyzer/pclxl.py (revision 196)
+++ pkpgcounter/trunk/pdlanalyzer/pclxl.py (revision 200)
@@ -26,7 +26,7 @@
 from struct import unpack
 
-from pdlanalyzer.pdlparser import PDLParser, PDLParserError
+from pdlanalyzer import pdlparser
 
-class PCLXLParser(PDLParser) :
+class PCLXLParser(pdlparser.PDLParser) :
     """A parser for PCLXL (aka PCL6) documents."""
     mediasizes = { 
@@ -150,5 +150,5 @@
             return unpack(self.endianness + "I", self.minfile[pos:posl])[0]
         else :    
-            raise PDLParserError, "Error on array size at %s" % self.pos
+            raise pdlparser.PDLParserError, "Error on array size at %s" % self.pos
         
     def array_16(self) :    
@@ -171,5 +171,5 @@
             return 2 * unpack(self.endianness + "I", self.minfile[pos:posl])[0]
         else :    
-            raise PDLParserError, "Error on array size at %s" % self.pos
+            raise pdlparser.PDLParserError, "Error on array size at %s" % self.pos
         
     def array_32(self) :    
@@ -192,5 +192,5 @@
             return 4 * unpack(self.endianness + "I", self.minfile[pos:posl])[0]
         else :    
-            raise PDLParserError, "Error on array size at %s" % self.pos
+            raise pdlparser.PDLParserError, "Error on array size at %s" % self.pos
         
     def embeddedDataSmall(self) :
@@ -245,7 +245,7 @@
                 # 
                 else :    
-                    raise PDLParserError, "Unknown endianness marker 0x%02x at start !" % endian
+                    raise pdlparser.PDLParserError, "Unknown endianness marker 0x%02x at start !" % endian
         if not found :
-            raise PDLParserError, "This file doesn't seem to be PCLXL (aka PCL6)"
+            raise pdlparser.PDLParserError, "This file doesn't seem to be PCLXL (aka PCL6)"
             
         # Initialize table of tags
@@ -345,5 +345,5 @@
             parser = PCLXLParser(infile, debug=1)
             totalsize += parser.getJobSize()
-        except PDLParserError, msg :    
+        except pdlparser.PDLParserError, msg :    
             sys.stderr.write("ERROR: %s\n" % msg)
             sys.stderr.flush()
Index: pkpgcounter/trunk/pdlanalyzer/analyzer.py
===================================================================
--- pkpgcounter/trunk/pdlanalyzer/analyzer.py (revision 200)
+++ pkpgcounter/trunk/pdlanalyzer/analyzer.py (revision 200)
@@ -0,0 +1,231 @@
+#
+# pkpgcounter : a generic Page Description Language parser
+#
+# (c) 2003,2004,2005 Jerome Alet <alet@librelogiciel.com>
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 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, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+#
+
+import sys
+import tempfile
+
+from pdlanalyzer import pdlparser, postscript, pdf, pcl345, pclxl, escp2
+
+KILOBYTE = 1024    
+MEGABYTE = 1024 * KILOBYTE    
+LASTBLOCKSIZE = int(KILOBYTE / 4)
+
+class PDLAnalyzer :    
+    """Class for PDL autodetection."""
+    def __init__(self, filename, debug=0) :
+        """Initializes the PDL analyzer.
+        
+           filename is the name of the file or '-' for stdin.
+           filename can also be a file-like object which 
+           supports read() and seek().
+        """
+        self.debug = debug
+        self.filename = filename
+        try :
+            import psyco 
+        except ImportError :    
+            sys.stderr.write("pkpgcounter : you should install psyco if possible, this would greatly speedup parsing.\n")
+            pass # Psyco is not installed
+        else :    
+            # Psyco is installed, tell it to compile
+            # the CPU intensive methods : PCL and PCLXL
+            # parsing will greatly benefit from this, 
+            # for PostScript and PDF the difference is
+            # barely noticeable since they are already
+            # almost optimal, and much more speedy anyway.
+            psyco.bind(postscript.PostScriptParser.getJobSize)
+            psyco.bind(pdf.PDFParser.getJobSize)
+            psyco.bind(escp2.ESCP2Parser.getJobSize)
+            psyco.bind(pcl345.PCL345Parser.getJobSize)
+            psyco.bind(pclxl.PCLXLParser.getJobSize)
+        
+    def getJobSize(self) :    
+        """Returns the job's size."""
+        self.openFile()
+        try :
+            pdlhandler = self.detectPDLHandler()
+        except pdlparser.PDLParserError, msg :    
+            self.closeFile()
+            raise pdlparser.PDLParserError, "ERROR : Unknown file format for %s (%s)" % (self.filename, msg)
+        else :
+            try :
+                size = pdlhandler(self.infile, self.debug).getJobSize()
+            finally :    
+                self.closeFile()
+            return size
+        
+    def openFile(self) :    
+        """Opens the job's data stream for reading."""
+        self.mustclose = 0  # 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 
+            infile = self.filename
+        elif self.filename == "-" :
+            # we must read from stdin
+            infile = sys.stdin
+        else :    
+            # normal file
+            self.infile = open(self.filename, "rb")
+            self.mustclose = 1
+            return
+            
+        # Use a temporary file, always seekable contrary to standard input.
+        self.infile = tempfile.TemporaryFile(mode="w+b")
+        while 1 :
+            data = infile.read(MEGABYTE) 
+            if not data :
+                break
+            self.infile.write(data)
+        self.infile.flush()    
+        self.infile.seek(0)
+            
+    def closeFile(self) :        
+        """Closes the job's data stream if we can close it."""
+        if self.mustclose :
+            self.infile.close()    
+        else :    
+            # if we don't have to close the file, then
+            # ensure the file pointer is reset to the 
+            # start of the file in case the process wants
+            # to read the file again.
+            try :
+                self.infile.seek(0)
+            except :    
+                pass    # probably stdin, which is not seekable
+        
+    def isPostScript(self, sdata, edata) :    
+        """Returns 1 if data is PostScript, else 0."""
+        if sdata.startswith("%!") or \
+           sdata.startswith("\004%!") or \
+           sdata.startswith("\033%-12345X%!PS") or \
+           ((sdata[:128].find("\033%-12345X") != -1) and \
+             ((sdata.find("LANGUAGE=POSTSCRIPT") != -1) or \
+              (sdata.find("LANGUAGE = POSTSCRIPT") != -1) or \
+              (sdata.find("LANGUAGE = Postscript") != -1))) or \
+              (sdata.find("%!PS-Adobe") != -1) :
+            if self.debug :  
+                sys.stderr.write("%s is a PostScript file\n" % str(self.filename))
+            return 1
+        else :    
+            return 0
+        
+    def isPDF(self, sdata, edata) :    
+        """Returns 1 if data is PDF, else 0."""
+        if sdata.startswith("%PDF-") or \
+           sdata.startswith("\033%-12345X%PDF-") or \
+           ((sdata[:128].find("\033%-12345X") != -1) and (sdata.upper().find("LANGUAGE=PDF") != -1)) or \
+           (sdata.find("%PDF-") != -1) :
+            if self.debug :  
+                sys.stderr.write("%s is a PDF file\n" % str(self.filename))
+            return 1
+        else :    
+            return 0
+        
+    def isPCL(self, sdata, edata) :    
+        """Returns 1 if data is PCL, else 0."""
+        if sdata.startswith("\033E\033") or \
+           (sdata.startswith("\033*rbC") and (not edata[-3:] == "\f\033@")) or \
+           sdata.startswith("\033%8\033") or \
+           (sdata.find("\033%-12345X") != -1) :
+            if self.debug :  
+                sys.stderr.write("%s is a PCL3/4/5 file\n" % str(self.filename))
+            return 1
+        else :    
+            return 0
+        
+    def isPCLXL(self, sdata, edata) :    
+        """Returns 1 if data is PCLXL aka PCL6, else 0."""
+        if ((sdata[:128].find("\033%-12345X") != -1) and \
+             (sdata.find(" HP-PCL XL;") != -1) and \
+             ((sdata.find("LANGUAGE=PCLXL") != -1) or \
+              (sdata.find("LANGUAGE = PCLXL") != -1))) :
+            if self.debug :  
+                sys.stderr.write("%s is a PCLXL (aka PCL6) file\n" % str(self.filename))
+            return 1
+        else :    
+            return 0
+            
+    def isESCP2(self, sdata, edata) :        
+        """Returns 1 if data is ESC/P2, else 0."""
+        if sdata.startswith("\033@") or \
+           sdata.startswith("\033*") or \
+           sdata.startswith("\n\033@") or \
+           sdata.startswith("\0\0\0\033\1@EJL") : # ESC/P Raster ??? Seen on Stylus Photo 1284
+            if self.debug :  
+                sys.stderr.write("%s is an ESC/P2 file\n" % str(self.filename))
+            return 1
+        else :    
+            return 0
+    
+    def detectPDLHandler(self) :    
+        """Tries to autodetect the document format.
+        
+           Returns the correct PDL handler class or None if format is unknown
+        """   
+        # Try to detect file type by reading first block of datas    
+        self.infile.seek(0)
+        firstblock = self.infile.read(4 * KILOBYTE)
+        try :
+            self.infile.seek(-LASTBLOCKSIZE, 2)
+            lastblock = self.infile.read(LASTBLOCKSIZE)
+        except IOError :    
+            lastblock = ""
+        self.infile.seek(0)
+        if self.isPostScript(firstblock, lastblock) :
+            return postscript.PostScriptParser
+        elif self.isPCLXL(firstblock, lastblock) :    
+            return pclxl.PCLXLParser
+        elif self.isPDF(firstblock, lastblock) :    
+            return pdf.PDFParser
+        elif self.isPCL(firstblock, lastblock) :    
+            return pcl345.PCL345Parser
+        elif self.isESCP2(firstblock, lastblock) :    
+            return escp2.ESCP2Parser
+        else :    
+            raise pdlparser.PDLParserError, "Analysis of first data block failed."
+            
+def main() :    
+    """Entry point for PDL Analyzer."""
+    if (len(sys.argv) < 2) or ((not sys.stdin.isatty()) and ("-" not in sys.argv[1:])) :
+        sys.argv.append("-")
+        
+    if ("-h" in sys.argv[1:]) or ("--help" in sys.argv[1:]) :
+        print "usage : pkpgcounter file1 file2 ... fileN"
+    elif ("-v" in sys.argv[1:]) or ("--version" in sys.argv[1:]) :
+        print "%s" % version.__version__
+    else :
+        totalsize = 0    
+        debug = 0
+        minindex = 1
+        if sys.argv[1] == "--debug" :
+            minindex = 2
+            debug = 1
+        for arg in sys.argv[minindex:] :
+            try :
+                parser = PDLAnalyzer(arg, debug)
+                totalsize += parser.getJobSize()
+            except pdlparser.PDLParserError, msg :    
+                sys.stderr.write("ERROR: %s\n" % msg)
+                sys.stderr.flush()
+        print "%s" % totalsize
+    
+if __name__ == "__main__" :    
+    main()
