Index: pkpgcounter/trunk/pkpgpdls/qpdl.py
===================================================================
--- pkpgcounter/trunk/pkpgpdls/qpdl.py (revision 3410)
+++ pkpgcounter/trunk/pkpgpdls/qpdl.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/>.
@@ -33,5 +33,5 @@
     """A parser for QPDL (aka SPL2) documents."""
     format = "QPDL (aka SPL2)"
-    mediasizes = { 
+    mediasizes = {
                     # The first values are identical to that of PCLXL
                     0 : "Letter",
@@ -57,7 +57,7 @@
                     23 : "C6",
                     24 : "Folio",
-                 }   
-                 
-    mediasources = {             
+                 }
+
+    mediasources = {
                      # Again, values are identical to that of PCLXL
                      0 : "Default",
@@ -70,6 +70,6 @@
                      7 : "ThirdCassette",
                    }
-            
-    def isValid(self) :    
+
+    def isValid(self) :
         """Returns True if data is QPDL aka SPL2, else False."""
         if ((self.firstblock[:128].find("\033%-12345X") != -1) and \
@@ -77,24 +77,24 @@
               (self.firstblock.find("LANGUAGE = QPDL") != -1))) :
             return True
-        else :    
+        else :
             return False
-            
+
     def beginPage(self, nextpos) :
         """Indicates the beginning of a new page, and extracts media information."""
         self.pagecount += 1
-        
+
         copies = unpack(self.unpackShort, self.minfile[nextpos+1:nextpos+3])[0]
         mediasize = ord(self.minfile[nextpos+3])
         mediasource = ord(self.minfile[nextpos+8])
         duplexmode = unpack(self.unpackShort, self.minfile[nextpos+10:nextpos+12])[0]
-        
-        self.pages[self.pagecount] = { "copies" : copies, 
+
+        self.pages[self.pagecount] = { "copies" : copies,
                                        "mediasize" : self.mediasizes.get(mediasize, str(mediasize)),
                                        "mediasource" : self.mediasources.get(mediasource, str(mediasource)),
                                        "duplex" : duplexmode,
-                                     } 
+                                     }
         return 16       # Length of a page header
-        
-    def endPage(self, nextpos) :    
+
+    def endPage(self, nextpos) :
         """Indicates the end of a page."""
         epcopies = unpack(self.unpackShort, self.minfile[nextpos:nextpos+2])[0]
@@ -103,10 +103,10 @@
             self.logdebug("ERROR: discrepancy between beginPage (%i) and endPage (%i) copies" % (bpcopies, epcopies))
         return 2        # Length of a page footer
-        
+
     def beginBand(self, nextpos) :
         """Indicates the beginning of a new band."""
         bandlength = unpack(self.unpackLong, self.minfile[nextpos+6:nextpos+10])[0]
         return bandlength + 10 # Length of a band header - length of checksum
-        
+
     def littleEndian(self) :
         """Toggles to little endianness."""
@@ -115,5 +115,5 @@
         self.unpackLong = self.unpackType[4]
         return 0
-        
+
     def bigEndian(self) :
         """Toggles to big endianness."""
@@ -122,6 +122,6 @@
         self.unpackLong = self.unpackType[4]
         return 0
-    
-    def escape(self, nextpos) :    
+
+    def escape(self, nextpos) :
         """Handles the ESC code."""
         pos = endpos = nextpos
@@ -137,6 +137,6 @@
                     quotes += 1
                 endpos += 1
-                
-            # Store this in a per page mapping.    
+
+            # Store this in a per page mapping.
             # NB : First time will be at page 0 (i.e. **before** page 1) !
             stuff = self.escapedStuff.setdefault(self.pagecount, [])
@@ -144,19 +144,19 @@
             self.logdebug("Escaped datas : [%s]" % repr(minfile[pos : endpos]))
         return endpos - pos
-        
-    def maybeEOF(self, nextpos) :    
+
+    def maybeEOF(self, nextpos) :
         """Tries to detect the EOF marker."""
         if self.minfile[nextpos:nextpos+9] == self.eofmarker :
             return 9
-        else :    
+        else :
             return 0
-        
+
     def getJobSize(self) :
         """Counts pages in a QPDL (SPL2) document.
-        
+
            Algorithm by Jerome Alet.
-           
+
            The documentation used for this was :
-         
+
            Sp�fication Technique (documentation non officielle)
            Le Language SPL2
@@ -165,5 +165,5 @@
         """
         # Initialize table of tags
-        self.tags = [ lambda pos : 0 ] * 256    
+        self.tags = [ lambda pos : 0 ] * 256
         self.tags[0x00] = self.beginPage
         self.tags[0x01] = self.endPage
@@ -171,16 +171,16 @@
         self.tags[0x0c] = self.beginBand
         self.tags[0x1b] = self.escape # The escape code
-        
+
         self.eofmarker = "\033%-12345X"
-        
+
         infileno = self.infile.fileno()
-        self.pages = { 0 : { "copies" : 1, 
-                             "orientation" : "Default", 
-                             "mediatype" : "Plain", 
-                             "mediasize" : "Default", 
-                             "mediasource" : "Default", 
+        self.pages = { 0 : { "copies" : 1,
+                             "orientation" : "Default",
+                             "mediatype" : "Plain",
+                             "mediasize" : "Default",
+                             "mediasource" : "Default",
                              "duplex" : None,
-                           } 
-                     }      
+                           }
+                     }
         self.minfile = minfile = mmap.mmap(infileno, os.fstat(infileno)[6], prot=mmap.PROT_READ, flags=mmap.MAP_SHARED)
         self.pagecount = 0
@@ -195,12 +195,12 @@
                     pos += 1
                     pos += tags[tag](pos)
-            except IndexError : # EOF ?            
+            except IndexError : # EOF ?
                 pass
         finally :
             self.minfile.close()
-            
+
         defaultduplexmode = "Simplex"
         defaultpapersize = ""
-        defaultpjlcopies = 1    
+        defaultpjlcopies = 1
         oldpjlcopies = -1
         oldduplexmode = ""
@@ -208,5 +208,5 @@
         for pnum in range(1, self.pagecount + 1) :
             # NB : is number of copies is 0, the page won't be output
-            # but the formula below is still correct : we want 
+            # but the formula below is still correct : we want
             # to decrease the total number of pages in this case.
             page = self.pages.get(pnum, self.pages.get(1, { "copies" : 1, "mediasize" : "Default", "duplex" : None }))
@@ -227,16 +227,16 @@
                     pjlcopies = nbqty
                 else :
-                    if oldpjlcopies == -1 :    
+                    if oldpjlcopies == -1 :
                         pjlcopies = defaultpjlcopies
-                    else :    
-                        pjlcopies = oldpjlcopies    
-                if page["duplex"] :        
+                    else :
+                        pjlcopies = oldpjlcopies
+                if page["duplex"] :
                     duplexmode = page["duplex"]
-                else :    
+                else :
                     defaultdm = pjlparser.default_variables.get("DUPLEX", "")
                     if defaultdm :
                         if defaultdm.upper() == "ON" :
                             defaultduplexmode = "Duplex"
-                        else :    
+                        else :
                             defaultduplexmode = "Simplex"
                     envdm = pjlparser.environment_variables.get("DUPLEX", "")
@@ -244,10 +244,10 @@
                         if envdm.upper() == "ON" :
                             duplexmode = "Duplex"
-                        else :    
+                        else :
                             duplexmode = "Simplex"
-                    else :        
+                    else :
                         if not oldduplexmode :
                             duplexmode = defaultduplexmode
-                        else :    
+                        else :
                             duplexmode = oldduplexmode
                 defaultps = pjlparser.default_variables.get("PAPER", "")
@@ -257,21 +257,21 @@
                 if envps :
                     papersize = envps
-                else :    
+                else :
                     if not oldpapersize :
                         papersize = defaultpapersize
-                    else :    
+                    else :
                         papersize = oldpapersize
-            else :        
+            else :
                 if oldpjlcopies == -1 :
                     pjlcopies = defaultpjlcopies
-                else :    
+                else :
                     pjlcopies = oldpjlcopies
                 if not oldduplexmode :
                     duplexmode = defaultduplexmode
-                else :    
+                else :
                     duplexmode = oldduplexmode
-                if not oldpapersize :    
+                if not oldpapersize :
                     papersize = defaultpapersize
-                else :    
+                else :
                     papersize = oldpapersize
                 duplexmode = oldduplexmode
@@ -279,14 +279,14 @@
             if page["mediasize"] != "Default" :
                 papersize = page["mediasize"]
-            if not duplexmode :    
+            if not duplexmode :
                 duplexmode = oldduplexmode or defaultduplexmode
-            oldpjlcopies = pjlcopies    
+            oldpjlcopies = pjlcopies
             oldduplexmode = duplexmode
             oldpapersize = papersize
             copies = max(pjlcopies, page["copies"]) # Was : pjlcopies * page["copies"]
             self.pagecount += (copies - 1)
-            self.logdebug("%s*%s*%s*%s" % (copies, 
-                                           papersize, 
-                                           page["mediasource"], 
+            self.logdebug("%s*%s*%s*%s" % (copies,
+                                           papersize,
+                                           page["mediasource"],
                                            duplexmode))
         return self.pagecount
