Show
Ignore:
Timestamp:
04/04/05 09:29:41 (19 years ago)
Author:
jerome
Message:

Added test functions

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/pdlanalyzer/pdf.py

    r193 r196  
    2525import re 
    2626 
    27 from pdlanalyzer.pdlparser import PDLParser 
     27from pdlanalyzer.pdlparser import PDLParser, PDLParserError 
    2828 
    2929class PDFParser(PDLParser) : 
     
    3939def test() :         
    4040    """Test function.""" 
    41     raise RuntimeError, "Not implemented !" 
     41    if (len(sys.argv) < 2) or ((not sys.stdin.isatty()) and ("-" not in sys.argv[1:])) : 
     42        sys.argv.append("-") 
     43    totalsize = 0     
     44    for arg in sys.argv[1:] : 
     45        if arg == "-" : 
     46            infile = sys.stdin 
     47            mustclose = 0 
     48        else :     
     49            infile = open(arg, "rb") 
     50            mustclose = 1 
     51        try : 
     52            parser = PDFParser(infile, debug=1) 
     53            totalsize += parser.getJobSize() 
     54        except PDLParserError, msg :     
     55            sys.stderr.write("ERROR: %s\n" % msg) 
     56            sys.stderr.flush() 
     57        if mustclose :     
     58            infile.close() 
     59    print "%s" % totalsize 
    4260     
    4361if __name__ == "__main__" :