Index: /pkpgcounter/trunk/pkpgpdls/tiff.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/tiff.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/tiff.py (revision 522)
@@ -37,5 +37,5 @@
         littleendian = (chr(0x49)*2) + chr(0x2a) + chr(0)
         bigendian = (chr(0x4d)*2) + chr(0) + chr(0x2a)
-        if self.parent.firstblock[:4] in (littleendian, bigendian) :
+        if self.firstblock[:4] in (littleendian, bigendian) :
             self.logdebug("DEBUG: Input file is in the TIFF format.")
             return True
Index: /pkpgcounter/trunk/pkpgpdls/pdlparser.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/pdlparser.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/pdlparser.py (revision 522)
@@ -43,7 +43,12 @@
     totiffcommands = None        # Default command to convert to TIFF
     openmode = "rb"              # Default file opening mode
-    def __init__(self, parent) :
+    def __init__(self, parent, (firstblock, lastblock)) :
         """Initialize the generic parser."""
         self.parent = parent
+        # We need some copies for later inclusion of parsers which
+        # would modify the parent's values
+        self.filename = parent.filename[:]
+        self.firstblock = firstblock[:]
+        self.lastblock = lastblock[:]
         self.infile = None
         if not self.isValid() :
@@ -58,6 +63,6 @@
             # parsing will greatly benefit from this.
             psyco.bind(self.getJobSize)
-        self.infile = open(self.parent.filename, self.openmode)
-        # self.logdebug("Opened %s in '%s' mode." % (self.parent.filename, self.openmode))
+        self.infile = open(self.filename, self.openmode)
+        # self.logdebug("Opened %s in '%s' mode." % (self.filename, self.openmode))
             
     def __del__(self) :
@@ -84,5 +89,5 @@
         """   
         if self.totiffcommands :
-            infname = self.parent.filename
+            infname = self.filename
             for totiffcommand in self.totiffcommands :
                 error = False
Index: /pkpgcounter/trunk/pkpgpdls/ooo.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/ooo.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/ooo.py (revision 522)
@@ -32,5 +32,5 @@
     def isValid(self) :        
         """Returns True if data is OpenDocument, else False."""
-        if self.parent.firstblock[:2] == "PK" :
+        if self.firstblock[:2] == "PK" :
             try :
                 self.archive = zipfile.ZipFile(self.infile)
Index: /pkpgcounter/trunk/pkpgpdls/lidil.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/lidil.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/lidil.py (revision 522)
@@ -62,6 +62,6 @@
         # for simplicity's sake.
         EOFMarker = "$\x00\x10\x00\x08\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff$$\x00\x10\x00\x06\x00\x00\x00\x00\x00\xff\xff\xff\xff\xff$" 
-        if self.parent.firstblock.startswith(BOFMarker) \
-           and self.parent.lastblock.endswith(EOFMarker) :
+        if self.firstblock.startswith(BOFMarker) \
+           and self.lastblock.endswith(EOFMarker) :
             self.logdebug("DEBUG: Input file is in the Hewlett-Packard LIDIL format.")
             return True
Index: /pkpgcounter/trunk/pkpgpdls/escpages03.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/escpages03.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/escpages03.py (revision 522)
@@ -35,6 +35,6 @@
     def isValid(self) :        
         """Returns True if data is TIFF, else False."""
-        if self.parent.firstblock.startswith("\033\1@EJL") and \
-            (self.parent.firstblock.find("=ESC/PAGES03\n") != -1) :
+        if self.firstblock.startswith("\033\1@EJL") and \
+            (self.firstblock.find("=ESC/PAGES03\n") != -1) :
             self.logdebug("DEBUG: Input file is in the ESC/PageS03 format.")
             return True
Index: /pkpgcounter/trunk/pkpgpdls/zjstream.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/zjstream.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/zjstream.py (revision 522)
@@ -31,8 +31,8 @@
     def isValid(self) :    
         """Returns True if data is ZjStream, else False."""
-        if self.parent.firstblock[:4] == "ZJZJ" :
+        if self.firstblock[:4] == "ZJZJ" :
             self.logdebug("DEBUG: Input file is in the Zenographics ZjStream (little endian) format.")
             return self.littleEndian()
-        elif self.parent.firstblock[:4] == "JZJZ" :    
+        elif self.firstblock[:4] == "JZJZ" :    
             self.logdebug("DEBUG: Input file is in the Zenographics ZjStream (big endian) format.")
             return self.bigEndian()
Index: /pkpgcounter/trunk/pkpgpdls/qpdl.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/qpdl.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/qpdl.py (revision 522)
@@ -73,7 +73,7 @@
     def isValid(self) :    
         """Returns True if data is QPDL aka SPL2, else False."""
-        if ((self.parent.firstblock[:128].find("\033%-12345X") != -1) and \
-             ((self.parent.firstblock.find("LANGUAGE=QPDL") != -1) or \
-              (self.parent.firstblock.find("LANGUAGE = QPDL") != -1))) :
+        if ((self.firstblock[:128].find("\033%-12345X") != -1) and \
+             ((self.firstblock.find("LANGUAGE=QPDL") != -1) or \
+              (self.firstblock.find("LANGUAGE = QPDL") != -1))) :
             self.logdebug("DEBUG: Input file is in the QPDL (aka SPL2) format.")
             return True
Index: /pkpgcounter/trunk/pkpgpdls/plain.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/plain.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/plain.py (revision 522)
@@ -39,5 +39,5 @@
            If it's impossible to find one we consider it's not plain text.
         """   
-        lines = self.parent.firstblock.split("\r\n")
+        lines = self.firstblock.split("\r\n")
         if len(lines) == 1 :
             lines = lines[0].split("\r")
Index: /pkpgcounter/trunk/pkpgpdls/pdf.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/pdf.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/pdf.py (revision 522)
@@ -47,8 +47,8 @@
     def isValid(self) :    
         """Returns True if data is PDF, else False."""
-        if self.parent.firstblock.startswith("%PDF-") or \
-           self.parent.firstblock.startswith("\033%-12345X%PDF-") or \
-           ((self.parent.firstblock[:128].find("\033%-12345X") != -1) and (self.parent.firstblock.upper().find("LANGUAGE=PDF") != -1)) or \
-           (self.parent.firstblock.find("%PDF-") != -1) :
+        if self.firstblock.startswith("%PDF-") or \
+           self.firstblock.startswith("\033%-12345X%PDF-") or \
+           ((self.firstblock[:128].find("\033%-12345X") != -1) and (self.firstblock.upper().find("LANGUAGE=PDF") != -1)) or \
+           (self.firstblock.find("%PDF-") != -1) :
             self.logdebug("DEBUG: Input file is in the PDF format.")
             return True
Index: /pkpgcounter/trunk/pkpgpdls/hbp.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/hbp.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/hbp.py (revision 522)
@@ -34,5 +34,5 @@
     def isValid(self) :        
         """Returns True if data is HBP, else False."""
-        if self.parent.firstblock.find("@PJL ENTER LANGUAGE = HBP\n") != -1 :
+        if self.firstblock.find("@PJL ENTER LANGUAGE = HBP\n") != -1 :
             self.logdebug("DEBUG: Input file is in the HBP format.")
             return True
Index: /pkpgcounter/trunk/pkpgpdls/pcl345.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/pcl345.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/pcl345.py (revision 522)
@@ -92,11 +92,11 @@
     def isValid(self) :    
         """Returns True if data is PCL3/4/5, else False."""
-        if self.parent.firstblock.startswith("\033E\033") or \
-           (self.parent.firstblock.startswith("\033*rbC") and (not self.parent.lastblock[-3:] == "\f\033@")) or \
-           self.parent.firstblock.startswith("\033*rB\033") or \
-           self.parent.firstblock.startswith("\033%8\033") or \
-           (self.parent.firstblock.find("\033%-12345X") != -1) or \
-           (self.parent.firstblock.find("@PJL ENTER LANGUAGE=PCL\012\015\033") != -1) or \
-           (self.parent.firstblock.startswith(chr(0xcd)+chr(0xca)) and (self.parent.firstblock.find("\033E\033") != -1)) :
+        if self.firstblock.startswith("\033E\033") or \
+           (self.firstblock.startswith("\033*rbC") and (not self.lastblock[-3:] == "\f\033@")) or \
+           self.firstblock.startswith("\033*rB\033") or \
+           self.firstblock.startswith("\033%8\033") or \
+           (self.firstblock.find("\033%-12345X") != -1) or \
+           (self.firstblock.find("@PJL ENTER LANGUAGE=PCL\012\015\033") != -1) or \
+           (self.firstblock.startswith(chr(0xcd)+chr(0xca)) and (self.firstblock.find("\033E\033") != -1)) :
             self.logdebug("DEBUG: Input file is in the PCL3/4/5 format.")
             return True
Index: /pkpgcounter/trunk/pkpgpdls/postscript.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/postscript.py (revision 521)
+++ /pkpgcounter/trunk/pkpgpdls/postscript.py (revision 522)
@@ -37,12 +37,12 @@
     def isValid(self) :    
         """Returns True if data is PostScript, else False."""
-        if self.parent.firstblock.startswith("%!") or \
-           self.parent.firstblock.startswith("\004%!") or \
-           self.parent.firstblock.startswith("\033%-12345X%!PS") or \
-           ((self.parent.firstblock[:128].find("\033%-12345X") != -1) and \
-             ((self.parent.firstblock.find("LANGUAGE=POSTSCRIPT") != -1) or \
-              (self.parent.firstblock.find("LANGUAGE = POSTSCRIPT") != -1) or \
-              (self.parent.firstblock.find("LANGUAGE = Postscript") != -1))) or \
-              (self.parent.firstblock.find("%!PS-Adobe") != -1) :
+        if self.firstblock.startswith("%!") or \
+           self.firstblock.startswith("\004%!") or \
+           self.firstblock.startswith("\033%-12345X%!PS") or \
+           ((self.firstblock[:128].find("\033%-12345X") != -1) and \
+             ((self.firstblock.find("LANGUAGE=POSTSCRIPT") != -1) or \
+              (self.firstblock.find("LANGUAGE = POSTSCRIPT") != -1) or \
+              (self.firstblock.find("LANGUAGE = Postscript") != -1))) or \
+              (self.firstblock.find("%!PS-Adobe") != -1) :
             self.logdebug("DEBUG: Input file is in the PostScript format.")
             return True
@@ -53,5 +53,5 @@
         """Get the count through GhostScript, useful for non-DSC compliant PS files."""
         self.logdebug("Internal parser sucks, using GhostScript instead...")
-        infname = self.parent.filename
+        infname = self.filename
         command = 'gs -sDEVICE=bbox -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET "%(infname)s" 2>&1 | grep -c "%%HiResBoundingBox:" 2>/dev/null'
         pagecount = 0
Index: /pkpgcounter/trunk/pkpgpdls/escp2.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/escp2.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/escp2.py (revision 522)
@@ -31,8 +31,8 @@
     def isValid(self) :        
         """Returns True if data is ESC/P2, else False."""
-        if self.parent.firstblock.startswith("\033@") or \
-           self.parent.firstblock.startswith("\033*") or \
-           self.parent.firstblock.startswith("\n\033@") or \
-           self.parent.firstblock.startswith("\0\0\0\033\1@EJL") : # ESC/P Raster ??? Seen on Stylus Photo 1284
+        if self.firstblock.startswith("\033@") or \
+           self.firstblock.startswith("\033*") or \
+           self.firstblock.startswith("\n\033@") or \
+           self.firstblock.startswith("\0\0\0\033\1@EJL") : # ESC/P Raster ??? Seen on Stylus Photo 1284
             self.logdebug("DEBUG: Input file is in the ESC/P2 format.")
             return True
Index: /pkpgcounter/trunk/pkpgpdls/spl1.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/spl1.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/spl1.py (revision 522)
@@ -37,8 +37,8 @@
     def isValid(self) :    
         """Returns True if data is SPL1, else False."""
-        if ((self.parent.firstblock[:128].find("\033%-12345X") != -1) and \
-            (self.parent.firstblock.find("$PJL ") != -1) and \
-             ((self.parent.firstblock.find("LANGUAGE=SMART") != -1) or \
-              (self.parent.firstblock.find("LANGUAGE = SMART") != -1))) :
+        if ((self.firstblock[:128].find("\033%-12345X") != -1) and \
+            (self.firstblock.find("$PJL ") != -1) and \
+             ((self.firstblock.find("LANGUAGE=SMART") != -1) or \
+              (self.firstblock.find("LANGUAGE = SMART") != -1))) :
             self.logdebug("DEBUG: Input file is in the SPL1 format.")
             return True
Index: /pkpgcounter/trunk/pkpgpdls/mstrash.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/mstrash.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/mstrash.py (revision 522)
@@ -39,10 +39,10 @@
            IMPORTANT : seem to be specific to some particular i18n release.
         """   
-        if self.parent.firstblock.startswith("PO^Q`") \
-           or self.parent.firstblock.startswith("\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1") \
-           or self.parent.firstblock.startswith("\xfe7\x00#") \
-           or self.parent.firstblock.startswith("\xdb\xa5-\x00\x00\x00") \
-           or self.parent.firstblock.startswith("\x31\xbe\x00\x00") \
-           or self.parent.firstblock[2112:].startswith("MSWordDoc") :
+        if self.firstblock.startswith("PO^Q`") \
+           or self.firstblock.startswith("\xd0\xcf\x11\xe0\xa1\xb1\x1a\xe1") \
+           or self.firstblock.startswith("\xfe7\x00#") \
+           or self.firstblock.startswith("\xdb\xa5-\x00\x00\x00") \
+           or self.firstblock.startswith("\x31\xbe\x00\x00") \
+           or self.firstblock[2112:].startswith("MSWordDoc") :
             self.logdebug("DEBUG: Input file seems to be in a Microsoft shitty file format.")
             return True
Index: /pkpgcounter/trunk/pkpgpdls/pclxl.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/pclxl.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/pclxl.py (revision 522)
@@ -83,9 +83,9 @@
     def isValid(self) :    
         """Returns True if data is PCLXL aka PCL6, else False."""
-        if (((self.parent.firstblock[:128].find("\033%-12345X") != -1) and \
-             (self.parent.firstblock.find(" HP-PCL XL;") != -1) and \
-             ((self.parent.firstblock.find("LANGUAGE=PCLXL") != -1) or \
-              (self.parent.firstblock.find("LANGUAGE = PCLXL") != -1)))) \
-             or ((self.parent.firstblock.startswith(chr(0xcd)+chr(0xca)) and (self.parent.firstblock.find(" HP-PCL XL;") != -1))) :
+        if (((self.firstblock[:128].find("\033%-12345X") != -1) and \
+             (self.firstblock.find(" HP-PCL XL;") != -1) and \
+             ((self.firstblock.find("LANGUAGE=PCLXL") != -1) or \
+              (self.firstblock.find("LANGUAGE = PCLXL") != -1)))) \
+             or ((self.firstblock.startswith(chr(0xcd)+chr(0xca)) and (self.firstblock.find(" HP-PCL XL;") != -1))) :
             self.logdebug("DEBUG: Input file is in the PCLXL (aka PCL6) format.")
             return True
Index: /pkpgcounter/trunk/pkpgpdls/dvi.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/dvi.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/dvi.py (revision 522)
@@ -36,6 +36,6 @@
         """Returns True if data is DVI, else False."""
         try :
-            if (ord(self.parent.firstblock[0]) == 0xf7) \
-                and (ord(self.parent.lastblock[-1]) == 0xdf) :
+            if (ord(self.firstblock[0]) == 0xf7) \
+                and (ord(self.lastblock[-1]) == 0xdf) :
                 self.logdebug("DEBUG: Input file is in the DVI format.")
                 return True
Index: /pkpgcounter/trunk/pkpgpdls/pil.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/pil.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/pil.py (revision 522)
@@ -35,5 +35,5 @@
         """Returns True if data is an image format supported by PIL, else False."""   
         try :
-            image = Image.open(self.parent.filename)
+            image = Image.open(self.filename)
         except (IOError, OverflowError) :    
             return False
@@ -45,5 +45,5 @@
         """Counts pages in an image file."""
         index = 0
-        image = Image.open(self.parent.filename)
+        image = Image.open(self.filename)
         try :
             while True :
Index: /pkpgcounter/trunk/pkpgpdls/analyzer.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/analyzer.py (revision 520)
+++ /pkpgcounter/trunk/pkpgpdls/analyzer.py (revision 522)
@@ -56,6 +56,4 @@
         self.workfile = None 
         self.mustclose = None
-        self.firstblock = None
-        self.lastblock = None
         
     def getJobSize(self) :    
@@ -128,14 +126,15 @@
             self.workfile.close()    
         
-    def readFirstAndLastBlocks(self) :    
+    def readFirstAndLastBlocks(self, inputfile) :
         """Reads the first and last blocks of data."""
         # Now read first and last block of the input file
         # to be able to detect the real file format and the parser to use.
-        self.firstblock = self.workfile.read(pdlparser.FIRSTBLOCKSIZE)
-        try :
-            self.workfile.seek(-pdlparser.LASTBLOCKSIZE, 2)
-            self.lastblock = self.workfile.read(pdlparser.LASTBLOCKSIZE)
+        firstblock = inputfile.read(pdlparser.FIRSTBLOCKSIZE)
+        try :
+            inputfile.seek(-pdlparser.LASTBLOCKSIZE, 2)
+            lastblock = inputfile.read(pdlparser.LASTBLOCKSIZE)
         except IOError :    
-            self.lastblock = ""
+            lastblock = ""
+        return (firstblock, lastblock)     
             
     def detectPDLHandler(self) :    
@@ -146,5 +145,5 @@
         if not os.stat(self.filename).st_size :
             raise pdlparser.PDLParserError, "input file %s is empty !" % str(self.filename)
-        self.readFirstAndLastBlocks()
+        (firstblock, lastblock) = self.readFirstAndLastBlocks(self.workfile)
             
         # IMPORTANT : the order is important below. FIXME.
@@ -167,5 +166,5 @@
                        plain) :     # IMPORTANT : don't move this one up !
             try :               
-                return module.Parser(self)
+                return module.Parser(self, (firstblock, lastblock))
             except pdlparser.PDLParserError :
                 pass # try next parser
