def cli(argv=sys.argv[1:]):
parser = argparse.ArgumentParser(
description="Convert an RS3 file into an HTML file containing the RST tree.")
parser.add_argument('rs3_file')
parser.add_argument('output_file', nargs='?')
parser.add_argument(
'-f', '--output-format', nargs='?', default='html',
help="output format: html (default), png")
parser.add_argument(
'-d', '--debug', action='store_true',
help="output format: html (default), png")
args = parser.parse_args(argv)
if args.debug:
import pudb; pudb.set_trace()
if args.output_format == 'png':
if args.output_file:
rs3topng(args.rs3_file, args.output_file)
sys.exit(0)
else:
sys.stderr.write("No PNG output file given.\n")
sys.exit(1)
if args.output_file:
with codecs.open(args.output_file, 'w', 'utf8') as outfile:
outfile.write(rs3tohtml(args.rs3_file))
else:
sys.stdout.write(rs3tohtml(args.rs3_file).encode('utf8'))
评论列表
文章目录