Changeset 485 for pkpgcounter

Show
Ignore:
Timestamp:
11/17/07 14:43:40 (17 years ago)
Author:
jerome
Message:

Almost ok for release.

Location:
pkpgcounter/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/bin/pkpgcounter

    r480 r485  
    5353    * ESC/PageS03 
    5454    * Brother HBP 
     55    * Hewlett-Packard LIDIL (hpijs) 
    5556 
    56 The seven latter ones, as well as some TIFF documents, are currently  
     57The eight latter ones, as well as some TIFF documents, are currently  
    5758only supported in page counting mode.  
    5859 
  • pkpgcounter/trunk/NEWS

    r480 r485  
    2121pkpgcounter News : 
    2222 
     23  * 3.30 : 
     24   
     25    - Added a minimal parser for Hewlett-Packard LIDIL documents, as  
     26      produced by the hpijs driver. 
     27       
    2328  * 3.20 : 
    2429    
  • pkpgcounter/trunk/pkpgpdls/analyzer.py

    r480 r485  
    2929 
    3030import version, pdlparser, postscript, pdf, pcl345, pclxl, hbp, \ 
    31        escp2, dvi, tiff, ooo, zjstream, qpdl, spl1, escpages03, plain 
     31       lidil, escp2, dvi, tiff, ooo, zjstream, qpdl, spl1, escpages03, plain 
    3232import inkcoverage 
    3333 
     
    166166                           ooo, \ 
    167167                           hbp, \ 
     168                           lidil, \ 
    168169                           pcl345, \ 
    169170                           escp2, \ 
  • pkpgcounter/trunk/pkpgpdls/lidil.py

    r484 r485  
    3636import pdlparser 
    3737 
     38# Packet types taken from hplip-2.7.10/prnt/ldl.py 
     39PACKET_TYPE_COMMAND = 0 
     40PACKET_TYPE_DISABLE_PACING = 1 
     41PACKET_TYPE_ENABLE_PACING = 2 
     42PACKET_TYPE_RESUME_NORMAL_OPERATION = 3 
     43PACKET_TYPE_DISABLE_RESPONSES = 4 
     44PACKET_TYPE_ENABLE_RESPONSES = 5 
     45PACKET_TYPE_RESET_LIDIL = 6 
     46PACKET_TYPE_SYNC = 7 
     47PACKET_TYPE_SYNC_COMPLETE = 8 
     48 
     49# Command codes we are interested in. 
     50LDL_LOAD_PAGE = 1 
     51LDL_EJECT_PAGE = 2 
     52 
    3853class Parser(pdlparser.PDLParser) : 
    3954    """A parser for HP LIDIL documents.""" 
     
    5772    def getJobSize(self) : 
    5873        """Computes the number of pages in a HP LIDIL document.""" 
    59         ejectpagemarker = "$\x00\x01\x00\x00\x02" # ensure it's a complete packet (ends with '$') 
    60         return 0 
     74        pagecount = 0 
     75        infileno = self.infile.fileno() 
     76        minfile = mmap.mmap(infileno, os.fstat(infileno)[6], prot=mmap.PROT_READ, flags=mmap.MAP_SHARED) 
     77        pos = 0 
     78        try : 
     79            try : 
     80                while 1 : 
     81                    if minfile[pos] != "$" :    # Frame Sync 
     82                        raise pdlparser.PDLParserError, "This file doesn't seem to be valid Hewlett-Packard LIDIL datas" 
     83                    try :     
     84                        (framesync,      
     85                         cmdlength, 
     86                         dummy, 
     87                         packettype, 
     88                         commandnumber, 
     89                         referencenumber, 
     90                         datalength) = unpack(">BHBBBHH", minfile[pos:pos+10]) 
     91                    except struct.error :     
     92                        raise pdlparser.PDLParserError, "This file doesn't seem to be valid Hewlett-Packard LIDIL datas" 
     93                    if (packettype == PACKET_TYPE_COMMAND) \ 
     94                        and (commandnumber == LDL_EJECT_PAGE) : 
     95                        pagecount += 1 
     96                    pos += (cmdlength + datalength) 
     97            except IndexError : # EOF ? 
     98                pass  
     99        finally :         
     100            minfile.close() 
     101        return pagecount 
    61102 
    62103if __name__ == "__main__" :     
  • pkpgcounter/trunk/pkpgpdls/version.py

    r480 r485  
    2222 
    2323 
    24 __version__ = "3.20" 
     24__version__ = "3.30" 
    2525 
    2626__doc__ = """pkpgcounter : a generic Page Description Languages parser.""" 
  • pkpgcounter/trunk/README

    r480 r485  
    5353        - Brother HBP 
    5454         
    55 The seven latter ones, as well as some TIFF documents, are currently  
     55        - Hewlett-Packard Lightweight Imaging Device Interface Language 
     56         
     57The eight latter ones, as well as some TIFF documents, are currently  
    5658only supported in page counting mode.  
    5759