From ff24bab2601665e59b1547b847dfd1ad42695a09 Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Sun, 20 Nov 2011 20:39:39 +1100 Subject: [PATCH] Moved __main__ code into main() function that can be referenced as an entry point script, and added a reference to it in setup.py --- html2text.py | 6 +++++- setup.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/html2text.py b/html2text.py index ee2db9af..6db81a28 100644 --- a/html2text.py +++ b/html2text.py @@ -714,7 +714,7 @@ def html2text(html, baseurl=''): h = HTML2Text(baseurl=baseurl) return h.handle(html) -if __name__ == "__main__": +def main(): baseurl = '' p = optparse.OptionParser('%prog [(filename|url) [encoding]]', @@ -782,3 +782,7 @@ def html2text(html, baseurl=''): h.hide_strikethrough = options.hide_strikethrough wrapwrite(h.handle(data)) + + +if __name__ == "__main__": + main() diff --git a/setup.py b/setup.py index 2999bfdf..63b2541c 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,10 @@ 'Programming Language :: Python :: 3.1', 'Programming Language :: Python :: 3.2' ], + entry_points=""" + [console_scripts] + html2text=html2text:main + """, license='GNU GPL 3', packages=find_packages(), py_modules=['html2text'],