From ceb47aba9c80c975cb15b45377efb9951a784d71 Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 2 May 2016 04:03:04 -0400 Subject: [PATCH] Add -V | --version and simplfy changing it --- ChangeLog | 46 +++++++++++++++++++++++++++++++++++++++++- NEWS | 11 +++++++++- __pkginfo__.py | 1 - bin/pydisassemble | 18 +++++++++++------ bin/uncompyle6 | 39 +++++++++++++++++++++-------------- setup.py | 6 ++++-- uncompyle6/__init__.py | 2 ++ uncompyle6/version.py | 3 +++ 8 files changed, 100 insertions(+), 26 deletions(-) create mode 100644 uncompyle6/version.py diff --git a/ChangeLog b/ChangeLog index 59506e1c..21345a5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,50 @@ +2016-05-02 rocky + + * __pkginfo__.py, bin/pydisassemble, bin/uncompyle6, setup.py, + uncompyle6/__init__.py, uncompyle6/version.py: Add -V | --version + and simplfy changing it + +2016-05-01 rocky + + * uncompyle6/__init__.py: Expose uncompyle_file + +2016-05-01 rocky + + * test/Makefile, uncompyle6/semantics/pysource.py: Bug + +2016-05-01 rocky + + * test/Makefile, test/simple_source/expression/05_const_map.py: Add + test for last fix. Drop 2.5 test until we figure out what's wrong + +2016-05-01 rocky + + * uncompyle6/parsers/parse3.py, uncompyle6/scanners/scanner35.py, + uncompyle6/semantics/pysource.py: Bug in 3.5 constant map parsing + +2016-05-01 rocky + + * uncompyle6/__init__.py: Export module load and fns load_file, + load_module + +2016-05-01 rocky + + * __pkginfo__.py, setup.py, uncompyle6/marsh.py: License is MIT marsh.py: remove unused import + +2016-05-01 rocky + + * uncompyle6/parsers/parse3.py: Forgot to define Python3ParserSingle + +2016-05-01 rocky + + * uncompyle6/parser.py, uncompyle6/parsers/parse2.py, + uncompyle6/parsers/parse3.py: Start to DRY Python2 and Python3 + grammars Separate out 3.2, and 3.5+ specific grammar code + 2016-04-30 rocky - * README.rst, __pkginfo__.py: Get ready for release 2.3.0 + * ChangeLog, NEWS, README.rst, __pkginfo__.py: Get ready for release + 2.3.1 2016-04-30 rocky diff --git a/NEWS b/NEWS index 67369f99..0d1ccf8a 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,13 @@ -uncompyle6 2.2.1 2016-04-30 +uncompyle6 2.3.2 2016-05-1 + +- Add --version option standalone scripts +- Correct License information in package +- expose fns uncompyle_file, load_file, and load_module +- Start to DRY Python2 and Python3 grammars Separate out 3.2, and 3.5+ + specific grammar code +- Fix bug in 3.5+ constant map parsing + +uncompyle6 2.3.0, 2.3.1 2016-04-30 - Require spark_parser >= 1.1.0 diff --git a/__pkginfo__.py b/__pkginfo__.py index f74b9c18..357b4a58 100644 --- a/__pkginfo__.py +++ b/__pkginfo__.py @@ -50,7 +50,6 @@ def get_srcdir(): return os.path.realpath(filename) ns = {} -version = '2.3.1' web = 'https://github.com/rocky/python-uncompyle6/' # tracebacks in zip files are funky and not debuggable diff --git a/bin/pydisassemble b/bin/pydisassemble index 9a9ff649..d5fa59f6 100755 --- a/bin/pydisassemble +++ b/bin/pydisassemble @@ -1,7 +1,7 @@ #!/usr/bin/env python # Mode: -*- python -*- # -# Copyright (c) 2015 by Rocky Bernstein +# Copyright (c) 2015-2016 by Rocky Bernstein # from __future__ import print_function import sys, os, getopt @@ -9,11 +9,13 @@ import sys, os, getopt program = os.path.basename(__file__) __doc__ = """ -Usage: %s [OPTIONS]... FILE +Usage: + %s [OPTIONS]... FILE + %s [--help | -h | -V | --version] Examples: - %s foo.pyc - %s foo.py + %s foo.pyc + %s foo.py %s -o foo.pydis foo.pyc %s -o /tmp foo.pyc @@ -24,7 +26,7 @@ Options: --help show this message -""" % ((program,) * 5) +""" % ((program,) * 6) Usage_short = \ @@ -32,6 +34,7 @@ Usage_short = \ from uncompyle6 import check_python_version from uncompyle6.disas import disassemble_files +from uncompyle6.version import VERSION check_python_version(program) @@ -40,7 +43,7 @@ out_base = None try: - opts, files = getopt.getopt(sys.argv[1:], 'ho:', ['help']) + opts, files = getopt.getopt(sys.argv[1:], 'hVo:', ['help', 'version']) except getopt.GetoptError as e: print('%s: %s' % (os.path.basename(sys.argv[0]), e), file=sys.stderr) sys.exit(-1) @@ -48,6 +51,9 @@ except getopt.GetoptError as e: for opt, val in opts: if opt in ('-h', '--help'): print(__doc__) + sys.exit(1) + elif opt in ('-V', '--version'): + print("%s %s" % (program, VERSION)) sys.exit(0) elif opt == '-o': outfile = val diff --git a/bin/uncompyle6 b/bin/uncompyle6 index dc7f62fb..c78b20cd 100755 --- a/bin/uncompyle6 +++ b/bin/uncompyle6 @@ -1,16 +1,23 @@ #!/usr/bin/env python # Mode: -*- python -*- # +# Copyright (c) 2015-2016 by Rocky Bernstein # Copyright (c) 2000-2002 by hartmut Goebel -# Copyright (c) 2015 by Rocky Bernstein +# +from __future__ import print_function +import sys, os, getopt, time -""" -Usage: uncompyle6 [OPTIONS]... [ FILE | DIR]... +program = os.path.basename(__file__) + +__doc__ = """ +Usage: + %s [OPTIONS]... [ FILE | DIR]... + %s [--help | -h | --V | --version] Examples: - uncompyle6 foo.pyc bar.pyc # decompile foo.pyc, bar.pyc to stdout - uncompyle6 -o . foo.pyc bar.pyc # decompile to ./foo.pyc_dis and ./bar.pyc_dis - uncompyle6 -o /tmp /usr/lib/python1.5 # decompile whole library + %s foo.pyc bar.pyc # decompile foo.pyc, bar.pyc to stdout + %s -o . foo.pyc bar.pyc # decompile to ./foo.pyc_dis and ./bar.pyc_dis + %s -o /tmp /usr/lib/python1.5 # decompile whole library Options: -o output decompiled files to this path: @@ -34,26 +41,25 @@ Options: Debugging Options: --asm -a include byte-code (disables --verify) --grammar -g show matching grammar - --treee -t include syntax tree (disables --verify) + --tree -t include syntax tree (disables --verify) Extensions of generated files: '.pyc_dis' '.pyo_dis' successfully decompiled (and verified if --verify) + '_unverified' successfully decompile but --verify failed + '_failed' decompile failed (contact author for enhancement) -""" - -from __future__ import print_function -import sys, os, getopt, time +""" % ((program,) * 6 program = os.path.basename(__file__) from uncompyle6 import verify, check_python_version from uncompyle6.main import main, status_msg +from uncompyle6.version import VERSION def usage(): print("""usage: - %s [--help] [--verify] [--asm] [--tree] [--grammar] [-o ] FILE|DIR... -""" % program) + %s [--verify] [--asm] [--tree] [--grammar] [-o ] FILE|DIR... + %s [--help | -h | --version | -V] +""" % (program, program)) sys.exit(1) @@ -68,8 +74,8 @@ timestamp = False timestampfmt = "# %Y.%m.%d %H:%M:%S %Z" try: - opts, files = getopt.getopt(sys.argv[1:], 'hagtdro:c:p:', - 'help asm grammar recurse timestamp tree verify ' + opts, files = getopt.getopt(sys.argv[1:], 'hagtdrVo:c:p:', + 'help asm grammar recurse timestamp tree verify version ' 'showgrammar'.split(' ')) except getopt.GetoptError as e: print('%s: %s' % (os.path.basename(sys.argv[0]), e), file=sys.stderr) @@ -80,6 +86,9 @@ for opt, val in opts: if opt in ('-h', '--help'): print(__doc__) sys.exit(0) + elif opt in ('-V', '--version'): + print("%s %s" % (program, VERSION)) + sys.exit(0) elif opt == '--verify': options['do_verify'] = True elif opt in ('--asm', '-a'): diff --git a/setup.py b/setup.py index f3fcd962..964af559 100755 --- a/setup.py +++ b/setup.py @@ -6,11 +6,13 @@ from __pkginfo__ import \ author, author_email, \ license, long_description, \ modname, packages, py_modules, scripts, \ - short_desc, version, web, zip_safe + short_desc, web, zip_safe __import__('pkg_resources') from setuptools import setup +exec(open('uncompyle6/version.py').read()) + setup( author = author, author_email = author_email, @@ -26,5 +28,5 @@ setup( url = web, setup_requires = ['nose>=1.0'], scripts = scripts, - version = version, + version = VERSION, zip_safe = zip_safe) diff --git a/uncompyle6/__init__.py b/uncompyle6/__init__.py index 2ac9ceeb..b8765aae 100644 --- a/uncompyle6/__init__.py +++ b/uncompyle6/__init__.py @@ -30,6 +30,8 @@ from __future__ import print_function import sys +__docformat__ = 'restructuredtext' + PYTHON3 = (sys.version_info >= (3, 0)) # We do this crazy way to support Python 2.6 which diff --git a/uncompyle6/version.py b/uncompyle6/version.py new file mode 100644 index 00000000..3e2f77c3 --- /dev/null +++ b/uncompyle6/version.py @@ -0,0 +1,3 @@ +# This file is suitable for sourcing inside bash as +# well as importing into Python +VERSION='2.3.2'