Mercurial > hg > MakeItSo
changeset 251:b4a3e8bbe095
py 3 + version bump
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 31 Mar 2017 18:16:36 -0700 |
parents | 3840a2c5bc4f |
children | 13de6f87c323 |
files | makeitso/python_package/{{package}}/{{main}}.py setup.py |
diffstat | 2 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/makeitso/python_package/{{package}}/{{main}}.py Fri Mar 31 18:12:09 2017 -0700 +++ b/makeitso/python_package/{{package}}/{{main}}.py Fri Mar 31 18:16:36 2017 -0700 @@ -27,7 +27,14 @@ # module globals __all__ = ['main', 'Parser'] here = os.path.dirname(os.path.realpath(__file__)) -string = (str, unicode) + +try: + # python 2 + string = (str, unicode) +except NameError: + # python 3 + string = (str, ) + def ensure_dir(directory): """ensure a directory exists""" @@ -41,6 +48,7 @@ class Parser(argparse.ArgumentParser): """CLI option parser""" + def __init__(self, **kwargs): kwargs.setdefault('formatter_class', argparse.RawTextHelpFormatter) kwargs.setdefault('description', __doc__) @@ -59,6 +67,7 @@ def validate(self, options): """validate options""" + def main(args=sys.argv[1:]): """CLI""" @@ -75,6 +84,7 @@ except KeyboardInterrupt: pass + if __name__ == '__main__': main()