Changeset 1567 for pykota

Show
Ignore:
Timestamp:
06/25/04 10:10:08 (20 years ago)
Author:
jalet
Message:

Another fix for PCL5 parser

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/pdlanalyzer.py

    r1566 r1567  
    2222# 
    2323# $Log$ 
     24# Revision 1.13  2004/06/25 08:10:08  jalet 
     25# Another fix for PCL5 parser 
     26# 
    2427# Revision 1.12  2004/06/24 23:09:53  jalet 
    2528# Fix for number of copies in PCL5 parser 
     
    173176        self.data = []              
    174177        self.pos = self.len = 0 
    175         pagecount = resets = 0 
     178        pagecount = resets = ejects = backsides = 0 
    176179        tag = None 
    177180        copies = {} 
     
    223226                            copies[pagecount] = size 
    224227                        elif (tag == "&l") and (char == "H") and (size == 0) :     
    225                             pagecount += 1      # Eject if NumPlanes > 1 
     228                            ejects += 1         # Eject  
    226229                        elif (tag == "&a") and (size == 2) : 
    227                             pagecount += 1      # Back side in duplex mode 
     230                            backsides += 1      # Back side in duplex mode 
    228231                        else :     
    229232                            # doing a read will prevent the seek  
     
    236239                            self.skip(size) 
    237240                             
    238         # if pagecount is still 0, we will return the number 
     241        # if pagecount is still 0, we will use the number 
    239242        # of resets instead of the number of form feed characters. 
    240243        # but the number of resets is always at least 2 with a valid 
     
    244247        # 1 more, we finally substract 3, and will test several 
    245248        # PCL files with this. If resets < 2, then the file is 
    246         # probably not a valid PCL file, so we return 0 
    247         # TODO : this code is probably not needed anymore 
    248         # TODO : since we added more page ejections detections 
    249         pagecount = (pagecount or ((resets - 3) * (resets > 2))) 
     249        # probably not a valid PCL file, so we use 0 
     250        if not pagecount : 
     251            pagecount = (pagecount or ((resets - 3) * (resets > 2))) 
     252        else :     
     253            # here we add counters for other ways new pages may have 
     254            # been printed and ejected by the printer 
     255            pagecount += ejects + backsides 
    250256         
    251257        # now handle number of copies for each page (may differ).