Changeset 529

Show
Ignore:
Timestamp:
11/28/07 20:48:45 (16 years ago)
Author:
jerome
Message:

Finalized support for MS documents.

Location:
pkpgcounter/trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/bin/pkpgcounter

    r528 r529  
    4545    * DVI 
    4646    * OpenDocument (ISO/IEC DIS 26300) 
     47    * Microsoft Word (c) (tm) (r) (etc...) 
    4748    * Plain text 
    4849    * TIFF 
  • pkpgcounter/trunk/man/pkpgcounter.1

    r528 r529  
    22.TH PKPGCOUNTER "1" "November 2007" "C@LL - Conseil Internet & Logiciels Libres" "User Commands" 
    33.SH NAME 
    4 pkpgcounter \- manual page for pkpgcounter 3.40alpha 
     4pkpgcounter \- count number of pages required to print various types of documents 
    55.SH DESCRIPTION 
    6 pkpgcounter v3.40alpha (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet 
     6pkpgcounter v3.40 (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet 
    77.PP 
    88pkpgcounter is a generic Page Description Language parser. 
     
    2222* DVI 
    2323* OpenDocument (ISO/IEC DIS 26300) 
     24* Microsoft Word (c) (tm) (r) (etc...) 
    2425* Plain text 
    2526* TIFF 
     
    7172needed to print all the documents specified. 
    7273.IP 
    73 \f(CW$ pkpgcounter --colorspace bw --resolution 150 file1.ps\fR 
     74\f(CW$ pkpgcounter \-\-colorspace bw \-\-resolution 150 file1.ps\fR 
    7475.IP 
    7576Will output the percent of black ink needed on each page of 
  • pkpgcounter/trunk/NEWS

    r514 r529  
    2121pkpgcounter News : 
    2222 
     23  * 3.40 : 
     24   
     25    - Fixed a major bug in the detection of OpenDocument (ISO/IEC DIS 26300) 
     26      files. 
     27       
     28    - Added support for page counting in Microsoft Word (c) (tm) (r) (etc...) 
     29      documents. 
     30       
     31    - Added support for ink accounting in Microsoft Word (c) (tm) (r) (etc...) 
     32      and OpenDocument (ISO/IEC DIS 26300) documents. 
     33       
     34    - Now automatically detects missing executable dependencies at runtime.   
     35       
    2336  * 3.30 : 
    2437   
  • pkpgcounter/trunk/pkpgpdls/analyzer.py

    r527 r529  
    166166                       plain) :     # IMPORTANT : don't move this one up ! 
    167167            try :                
    168                 return module.Parser(self, (firstblock, lastblock)) 
     168                return module.Parser(self, self.filename,  
     169                                           (firstblock, lastblock)) 
    169170            except pdlparser.PDLParserError : 
    170171                pass # try next parser 
  • pkpgcounter/trunk/pkpgpdls/mscrap.py

    r527 r529  
    2424 
    2525import os 
    26 import urllib2 
     26import tempfile 
    2727 
    2828import pdlparser 
     
    5656             
    5757    def getJobSize(self) : 
    58         """Counts pages in a Microsoft Word (r) (tm) (c) (etc...) document.""" 
    59         return 0 
     58        """Counts pages in a Microsoft Word (r) (tm) (c) (etc...) document. 
     59 
     60           First we convert from .doc to .ps, then we use the PostScript parser. 
     61        """ 
     62        doctops = 'xvfb-run -a abiword --import-extension=.doc --print="%(outfname)s" "%(infname)s"' 
     63        workfile = tempfile.NamedTemporaryFile(mode="w+b") 
     64        try : 
     65            outfname = workfile.name 
     66            infname = self.filename 
     67            status = os.system(doctops % locals()) 
     68            if status or not os.stat(outfname).st_size : 
     69                raise pdlparser.PDLParserError, "Impossible to convert input document %(infname)s to PostScript" % locals() 
     70            psinputfile = open(outfname, "rb") 
     71            try : 
     72                (first, last) = self.parent.readFirstAndLastBlocks(psinputfile) 
     73                import postscript 
     74                return postscript.Parser(self.parent,  
     75                                         outfname,  
     76                                         (first, last)).getJobSize() 
     77            finally : 
     78                psinputfile.close() 
     79        finally :     
     80            workfile.close() 
     81        raise pdlparser.PDLParserError, "Impossible to count pages in %(infname)s" % locals() 
  • pkpgcounter/trunk/pkpgpdls/pdlparser.py

    r527 r529  
    4343    required = []               # Default list of required commands 
    4444    openmode = "rb"             # Default file opening mode 
    45     def __init__(self, parent, (firstblock, lastblock)) : 
     45    def __init__(self, parent, filename, (firstblock, lastblock)) : 
    4646        """Initialize the generic parser.""" 
    4747        self.parent = parent 
    4848        # We need some copies for later inclusion of parsers which 
    4949        # would modify the parent's values 
    50         self.filename = parent.filename[:] 
     50        self.filename = filename[:] 
    5151        self.firstblock = firstblock[:] 
    5252        self.lastblock = lastblock[:] 
  • pkpgcounter/trunk/pkpgpdls/version.py

    r517 r529  
    2222 
    2323 
    24 __version__ = "3.40alpha" 
     24__version__ = "3.40" 
    2525 
    2626__doc__ = """pkpgcounter : a generic Page Description Languages parser.""" 
  • pkpgcounter/trunk/README

    r528 r529  
    3636         
    3737        - OpenDocument (ISO/IEC DIS 26300) 
     38         
     39        - Microsoft Word (c) (tm) (r) (etc...) 
    3840         
    3941        - Plain text