def main(argv): op = OptionParser() op.add_option("-f", "--format", dest="format", choices=["txt", "html"], default="txt") (options, (input_filename, output_filename)) = op.parse_args(argv[1:]) title = re.sub(".txt$", "", input_filename) title = re.sub("^.*/", "", title) outfile = file(output_filename, "w") infile = file(input_filename, "r") if options.format == "html": printer = jim_html_printer.printer(outfile) elif options.format == "txt": printer = jim_printer.printer(outfile) else: assert False make_jim(infile, printer, title)
#!/usr/bin/python import parser import jim_printer import sys p = parser.parser() printer = jim_printer.printer(sys.stdout) m = file(sys.argv[1], "r") j = p.parse(m) for i in j: printer.print_comp(i) print "\n"