From d1c89c3245a2142de24a8697af98ace8b00d667e Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 14 Dec 2013 18:25:18 +0000 Subject: Add --styles argument to CLI --- scripts/mammoth | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mammoth b/scripts/mammoth index 4de4120..0aeb93d 100644 --- a/scripts/mammoth +++ b/scripts/mammoth @@ -10,9 +10,15 @@ import mammoth def main(): args = _parse_args() + if args.styles is None: + styles = None + else: + with open(args.styles) as styles_fileobj: + styles = styles_fileobj.read() + with _open_output(args.output) as output: with open(args.path, "rb") as docx_fileobj: - result = mammoth.convert_to_html(docx_fileobj) + result = mammoth.convert_to_html(docx_fileobj, styles=styles) for message in result.messages: sys.stderr.write(message.message) sys.stderr.write("\n") @@ -35,6 +41,7 @@ def _parse_args(): parser = argparse.ArgumentParser() parser.add_argument("path") parser.add_argument("output", nargs="?") + parser.add_argument("--styles", required=False) return parser.parse_args() -- cgit v1.2.3