Changeset 1690

Show
Ignore:
Timestamp:
09/02/04 00:31:49 (20 years ago)
Author:
jalet
Message:

Some more work on ESC/P2 analyzer to avoid missing \r\n sequences. Not
exactly optimal though...

Files:
1 modified

Legend:

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

    r1686 r1690  
    2222# 
    2323# $Log$ 
     24# Revision 1.36  2004/09/01 22:31:49  jalet 
     25# Some more work on ESC/P2 analyzer to avoid missing \r\n sequences. Not 
     26# exactly optimal though... 
     27# 
    2428# Revision 1.35  2004/08/30 23:10:24  jalet 
    2529# Improved the ESC/P2 analyzer so that more GhostScript devices are supported 
     
    243247        # are two Reset Printer sequences (ESC + @) 
    244248        marker1 = "\033@" 
    245         pagecount1 = 0 
    246249         
    247250        # with other software or printer driver, we 
     
    250253        marker2r = "\r\f\033" 
    251254        marker2rn = "\r\n\f\033" 
    252         pagecount2 = 0 
    253255         
    254256        # and ghostscript's stcolor for example seems to 
    255257        # output ESC + @ + \f for each page plus one 
    256258        marker3 = "\033@\f" 
    257         pagecount3 = 0 
    258259         
    259260        # while ghostscript's escp driver outputs instead 
    260261        # \f + ESC + @ 
    261262        marker4 = "\f\033@" 
    262         pagecount4 = 0 
    263          
    264         for line in self.infile.xreadlines() :  
    265             pagecount1 += line.count(marker1) 
    266             generic = line.count(marker2r) 
    267             if not generic : 
    268                 generic = line.count(marker2rn) 
    269             pagecount2 += generic     
    270             pagecount3 += line.count(marker3) 
    271             pagecount4 += line.count(marker4) 
     263         
     264        data = self.infile.read() 
     265        pagecount1 = data.count(marker1) 
     266        pagecount2 = max(data.count(marker2r), data.count(marker2rn)) 
     267        pagecount3 = data.count(marker3) 
     268        pagecount4 = data.count(marker4) 
    272269             
    273270        if pagecount2 :     
     
    279276        else :     
    280277            return int(pagecount1 / 2)        
    281          
    282278         
    283279class PCLAnalyzer :