Show
Ignore:
Timestamp:
09/15/06 00:47:46 (18 years ago)
Author:
jerome
Message:

Moved the test() function elsewhere, so that it is present only
once in the code.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/pkpgpdls/oldpcl345.py

    r402 r415  
    486486        return pagecount 
    487487         
    488 def test() :         
    489     """Test function.""" 
    490     if (len(sys.argv) < 2) or ((not sys.stdin.isatty()) and ("-" not in sys.argv[1:])) : 
    491         sys.argv.append("-") 
    492     totalsize = 0     
    493     for arg in sys.argv[1:] : 
    494         if arg == "-" : 
    495             infile = sys.stdin 
    496             mustclose = 0 
    497         else :     
    498             infile = open(arg, "rb") 
    499             mustclose = 1 
    500         try : 
    501             parser = Parser(infile, debug=1) 
    502             totalsize += parser.getJobSize() 
    503         except pdlparser.PDLParserError, msg :     
    504             sys.stderr.write("ERROR: %s\n" % msg) 
    505             sys.stderr.flush() 
    506         if mustclose :     
    507             infile.close() 
    508     print "%s" % totalsize 
    509      
    510488if __name__ == "__main__" :     
    511     test() 
     489    pdlparser.test(Parser)