| 112 | |
| 113 | def test(parserclass) : |
| 114 | """Test function.""" |
| 115 | if (len(sys.argv) < 2) or ((not sys.stdin.isatty()) and ("-" not in sys.argv[1:])) : |
| 116 | sys.argv.append("-") |
| 117 | totalsize = 0 |
| 118 | for arg in sys.argv[1:] : |
| 119 | if arg == "-" : |
| 120 | infile = sys.stdin |
| 121 | mustclose = 0 |
| 122 | else : |
| 123 | infile = open(arg, "rb") |
| 124 | mustclose = 1 |
| 125 | try : |
| 126 | parser = parserclass(infile, debug=1) |
| 127 | totalsize += parser.getJobSize() |
| 128 | except PDLParserError, msg : |
| 129 | sys.stderr.write("ERROR: %s\n" % msg) |
| 130 | sys.stderr.flush() |
| 131 | if mustclose : |
| 132 | infile.close() |
| 133 | print "%s" % totalsize |
| 134 | |