Index: /pkpgcounter/trunk/pkpgpdls/lidil.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/lidil.py (revision 522)
+++ /pkpgcounter/trunk/pkpgpdls/lidil.py (revision 532)
@@ -73,12 +73,12 @@
         unpack = struct.unpack
         ejectpage = loadpage = 0
-        while True :
-            header = self.infile.read(HEADERSIZE)
-            if not header :
-                break
-            if (len(header) != HEADERSIZE) or (header[0] != "$") :
-                # Invalid header or no Frame Sync byte.
-                raise pdlparser.PDLParserError, "This file doesn't seem to be valid Hewlett-Packard LIDIL datas."
-            try :    
+        try :
+            while True :
+                header = self.infile.read(HEADERSIZE)
+                if not header :
+                    break
+                if (len(header) != HEADERSIZE) or (header[0] != "$") :
+                    # Invalid header or no Frame Sync byte.
+                    raise pdlparser.PDLParserError, "This file doesn't seem to be valid Hewlett-Packard LIDIL datas."
                 (framesync,     
                  cmdlength,
@@ -88,12 +88,12 @@
                  referencenumber,
                  datalength) = unpack(">BHBBBHH", header)
-            except struct.error :    
-                raise pdlparser.PDLParserError, "This file doesn't seem to be valid Hewlett-Packard LIDIL datas."
-            if packettype == PACKET_TYPE_COMMAND :
-                if commandnumber == LDL_LOAD_PAGE :
-                    loadpage += 1
-                elif commandnumber == LDL_EJECT_PAGE :
-                    ejectpage += 1
-            self.infile.seek(cmdlength + datalength - len(header), 1) # relative seek
+                if packettype == PACKET_TYPE_COMMAND :
+                    if commandnumber == LDL_LOAD_PAGE :
+                        loadpage += 1
+                    elif commandnumber == LDL_EJECT_PAGE :
+                        ejectpage += 1
+                self.infile.seek(cmdlength + datalength - len(header), 1) # relative seek
+        except struct.error :    
+            raise pdlparser.PDLParserError, "This file doesn't seem to be valid Hewlett-Packard LIDIL datas."
             
         # Number of page eject commands should be sufficient,
Index: /pkpgcounter/trunk/pkpgpdls/zjstream.py
===================================================================
--- /pkpgcounter/trunk/pkpgpdls/zjstream.py (revision 522)
+++ /pkpgcounter/trunk/pkpgpdls/zjstream.py (revision 532)
@@ -52,37 +52,38 @@
     def getJobSize(self) :
         """Computes the number of pages in a ZjStream document."""
-        unpack = struct.unpack
         self.infile.seek(4, 0) # Skip ZJZJ/JZJZ header
         startpagecount = endpagecount = 0
-        while True :
-            header = self.infile.read(16)
-            if not header :
-                break
-            try :    
+        unpackHeader = self.unpackHeader
+        unpack = struct.unpack
+        try :
+            while True :
+                header = self.infile.read(16)
+                if not header :
+                    break
                 (totalChunkSize,
                  chunkType,
                  numberOfItems,
                  reserved,
-                 signature) = unpack(self.unpackHeader, header)
-            except struct.error :
-                raise pdlparser.PDLParserError, "This file doesn't seem to be valid ZjStream datas."
-            self.infile.seek(totalChunkSize - len(header), 1)
-            if chunkType == 2 :    
-                #self.logdebug("startPage")
-                startpagecount += 1
-            elif chunkType == 3 :
-                #self.logdebug("endPage")
-                endpagecount += 1
-            #elif chunkType == 0 :
-            #    self.logdebug("startDoc")
-            #elif chunkType == 1 :    
-            #    self.logdebug("endDoc")
-                
-            #self.logdebug("Chunk size : %s" % totalChunkSize)
-            #self.logdebug("Chunk type : 0x%08x" % chunkType)
-            #self.logdebug("# items : %s" % numberOfItems)
-            #self.logdebug("reserved : 0x%04x" % reserved)
-            #self.logdebug("signature : 0x%04x" % signature)
-            #self.logdebug("\n")
+                 signature) = unpack(unpackHeader, header)
+                self.infile.seek(totalChunkSize - len(header), 1)
+                if chunkType == 2 :    
+                    #self.logdebug("startPage")
+                    startpagecount += 1
+                elif chunkType == 3 :
+                    #self.logdebug("endPage")
+                    endpagecount += 1
+                #elif chunkType == 0 :
+                #    self.logdebug("startDoc")
+                #elif chunkType == 1 :    
+                #    self.logdebug("endDoc")
+                #    
+                #self.logdebug("Chunk size : %s" % totalChunkSize)
+                #self.logdebug("Chunk type : 0x%08x" % chunkType)
+                #self.logdebug("# items : %s" % numberOfItems)
+                #self.logdebug("reserved : 0x%04x" % reserved)
+                #self.logdebug("signature : 0x%04x" % signature)
+                #self.logdebug("\n")
+        except struct.error :
+            raise pdlparser.PDLParserError, "This file doesn't seem to be valid ZjStream datas."
             
         # Number of endpage commands should be sufficient,
