Changeset 1686

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

Improved the ESC/P2 analyzer so that more GhostScript? devices are supported

Location:
pykota/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/NEWS

    r1683 r1686  
    2222PyKota NEWS : 
    2323 
     24    - 1.20alpha4 : 
     25     
     26        - Added support for more ghostscript devices in ESC/P2 
     27          analyzer : stcolor, st800, escp, escpc are now supported. 
     28           
    2429    - 1.20alpha3 : 
    2530        
  • pykota/trunk/pykota/pdlanalyzer.py

    r1683 r1686  
    2222# 
    2323# $Log$ 
     24# Revision 1.35  2004/08/30 23:10:24  jalet 
     25# Improved the ESC/P2 analyzer so that more GhostScript devices are supported 
     26# 
    2427# Revision 1.34  2004/08/27 09:08:22  jalet 
    2528# Improvement in PostScript parser to avoid being fooled by clever "students" 
     
    237240    def getJobSize(self) :     
    238241        """Counts pages in an ESC/P2 document.""" 
    239         # with GhostScript, at least, for each page there 
     242        # with Gimpprint, at least, for each page there 
    240243        # are two Reset Printer sequences (ESC + @) 
    241         marker = "\033@" 
    242         pagecount = 0 
     244        marker1 = "\033@" 
     245        pagecount1 = 0 
     246         
     247        # with other software or printer driver, we 
     248        # may prefer to search for "\r\n\fESCAPE" 
     249        # or "\r\fESCAPE" 
     250        marker2r = "\r\f\033" 
     251        marker2rn = "\r\n\f\033" 
     252        pagecount2 = 0 
     253         
     254        # and ghostscript's stcolor for example seems to 
     255        # output ESC + @ + \f for each page plus one 
     256        marker3 = "\033@\f" 
     257        pagecount3 = 0 
     258         
     259        # while ghostscript's escp driver outputs instead 
     260        # \f + ESC + @ 
     261        marker4 = "\f\033@" 
     262        pagecount4 = 0 
     263         
    243264        for line in self.infile.xreadlines() :  
    244             pagecount += line.count(marker) 
    245         return int(pagecount / 2)        
     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) 
     272             
     273        if pagecount2 :     
     274            return pagecount2 
     275        elif pagecount3 > 1 :      
     276            return pagecount3 - 1 
     277        elif pagecount4 :     
     278            return pagecount4 
     279        else :     
     280            return int(pagecount1 / 2)        
     281         
    246282         
    247283class PCLAnalyzer : 
     
    613649            psyco.bind(PostScriptAnalyzer.getJobSize) 
    614650            psyco.bind(PDFAnalyzer.getJobSize) 
     651            psyco.bind(ESCP2Analyzer.getJobSize) 
    615652            psyco.bind(PCLAnalyzer.getJobSize) 
    616653            psyco.bind(PCLXLAnalyzer.getJobSize) 
     
    715752        """Returns 1 if data is ESC/P2, else 0.""" 
    716753        if data.startswith("\033@") or \ 
     754           data.startswith("\033*") or \ 
    717755           data.startswith("\n\033@") : 
    718             #data.startswith("\033*") or  
    719756            return 1 
    720757        else :     
  • pykota/trunk/pykota/version.py

    r1680 r1686  
    2222# 
    2323 
    24 __version__ = "1.20alpha3_unofficial" 
     24__version__ = "1.20alpha4_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" 
  • pykota/trunk/tests/runtest.sh

    r1676 r1686  
    44/bin/rm -f testsuite.* master2.ps 
    55gunzip <master.ps.gz >master2.ps 
    6 for device in laserjet ljet3 ljet4 lj5gray lj5mono pxlmono pxlcolor pdfwrite pswrite psgray psmono psrgb epson epsonc eps9mid eps9high ; do 
     6for device in laserjet ljet3 ljet4 lj5gray lj5mono pxlmono pxlcolor pdfwrite pswrite psgray psmono psrgb epson epsonc eps9mid eps9high stcolor st800 escp escpc ; do 
    77    gs -dQUIET -dBATCH -dNOPAUSE -sOutputFile="testsuite.$device" -sDEVICE="$device" master2.ps ; 
    88    done