From 9df2ce0fbeb7d3163bcd08937e6f21f7c1e86149 Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Mon, 27 Jun 2016 14:46:42 -0500 Subject: [PATCH] convert command-line executables to entry_points console_scripts, best practice according to Python Packaging Authority (eases testing, etc) --- bin/warcprox | 7 ---- setup.py | 12 ++++-- bin/dump-anydbm => warcprox/dump_anydbm.py | 45 +++++++++++----------- 3 files changed, 32 insertions(+), 32 deletions(-) delete mode 100755 bin/warcprox rename bin/dump-anydbm => warcprox/dump_anydbm.py (67%) diff --git a/bin/warcprox b/bin/warcprox deleted file mode 100755 index d236cf6..0000000 --- a/bin/warcprox +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python - -from __future__ import absolute_import - -import warcprox.main - -warcprox.main.main() diff --git a/setup.py b/setup.py index 571521e..9b760f5 100755 --- a/setup.py +++ b/setup.py @@ -49,8 +49,9 @@ try: except: deps.append('futures') -setuptools.setup(name='warcprox', - version='2.0.dev12', +setuptools.setup( + name='warcprox', + version='2.0.dev13', description='WARC writing MITM HTTP/S proxy', url='https://github.com/internetarchive/warcprox', author='Noah Levitt', @@ -62,7 +63,12 @@ setuptools.setup(name='warcprox', tests_require=['requests>=2.0.1', 'pytest'], # >=2.0.1 for https://github.com/kennethreitz/requests/pull/1636 cmdclass = {'test': PyTest}, test_suite='warcprox.tests', - scripts=['bin/dump-anydbm', 'bin/warcprox'], + entry_points={ + 'console_scripts': [ + 'warcprox=warprox.main:main', + 'dump-anydbm=warcprox.dump_anydbm:main', + ], + }, zip_safe=False, classifiers=[ 'Development Status :: 5 - Production/Stable', diff --git a/bin/dump-anydbm b/warcprox/dump_anydbm.py similarity index 67% rename from bin/dump-anydbm rename to warcprox/dump_anydbm.py index b9200bc..6de00c6 100755 --- a/bin/dump-anydbm +++ b/warcprox/dump_anydbm.py @@ -1,30 +1,28 @@ #!/usr/bin/env python -# -# dump-anydbm - dumps contents of dbm file to stdout -# -# Copyright (C) 2013-2016 Internet Archive -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. -# +''' +dump-anydbm - dumps contents of dbm file to stdout -""" Dump contents of database to stdout. Database can be any file that the anydbm module can read. Included with warcprox because it's useful for inspecting a deduplication database or a playback index database, but it is a generic tool. -""" + +Copyright (C) 2013-2016 Internet Archive + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +USA. +''' try: import dbm @@ -40,6 +38,9 @@ import sys import os.path if __name__ == "__main__": + main() + +def main(): if len(sys.argv) != 2: sys.stderr.write("usage: {} DBM_FILE\n".format(sys.argv[0])) exit(1)