From ad6e1900480bee735cd5f49e3678148e1d5fbf81 Mon Sep 17 00:00:00 2001 From: Michael Murtaugh Date: Fri, 15 Jan 2016 14:08:09 +0100 Subject: [PATCH] html5tidy as proper tool --- bin/etherdump | 6 ++++-- etherdump/commands/html5tidy.py | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bin/etherdump b/bin/etherdump index 3a6cc11..04fda7b 100755 --- a/bin/etherdump +++ b/bin/etherdump @@ -6,15 +6,17 @@ usage = """Usage: etherdump CMD where CMD could be: - sync + pull + index + dumpcsv gettext gethtml creatediffhtml - dumpcsv list listauthors revisionscount showmeta + html5tidy For more information on each command try: etherdump CMD --help diff --git a/etherdump/commands/html5tidy.py b/etherdump/commands/html5tidy.py index b1fbd32..6f5a574 100644 --- a/etherdump/commands/html5tidy.py +++ b/etherdump/commands/html5tidy.py @@ -83,8 +83,7 @@ def html5tidy (doc, charset="utf-8", title=None, scripts=None, links=None, inden etree_indent(doc) return doc - -if __name__ == "__main__": +def main (args): p = ArgumentParser("") p.add_argument("input", nargs="?", default=None) p.add_argument("--indent", default=False, action="store_true") @@ -103,7 +102,7 @@ if __name__ == "__main__": p.add_argument("--rss", action="append", default=[], nargs="+", help="ensure/add alternate link of type application/rss+xml") p.add_argument("--atom", action="append", default=[], nargs="+", help="ensure/add alternate link of type application/atom+xml") - args = p.parse_args() + args = p.parse_args(args) links = [] def add_links (links, items, rel, _type=None): for href in items: @@ -164,3 +163,7 @@ if __name__ == "__main__": if tmppath: os.rename(args.input, args.input+"~") os.rename(tmppath, args.input) + + +if __name__ == "__main__": + main(sys.argv)