From 40badefe9d12cd9f7640a0701769100cd43ea203 Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 27 Apr 2016 23:03:09 -0400 Subject: [PATCH 1/3] Use external spark now. --- .gitignore | 2 ++ README.rst | 1 + requirements.txt | 1 + uncompyle6/parser.py | 6 +++--- uncompyle6/parsers/astnode.py | 4 ++-- uncompyle6/parsers/parse2.py | 8 ++++++-- uncompyle6/parsers/parse3.py | 8 ++++++-- uncompyle6/semantics/fragments.py | 2 +- uncompyle6/semantics/pysource.py | 2 +- 9 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index ac430678..d7268703 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ /.cache /.eggs /.python-version +/.tox +/README /__pkginfo__.pyc /dist /how-to-make-a-release.txt diff --git a/README.rst b/README.rst index 713f5bb8..60c7b744 100644 --- a/README.rst +++ b/README.rst @@ -48,6 +48,7 @@ This uses setup.py, so it follows the standard Python routine: :: + pip install -r requirements.txt python setup.py install # may need sudo # or if you have pyenv: python setup.py develop diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..79137d10 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +spark_parser >= 1.0.1 diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 799646a9..a62e7977 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -3,7 +3,7 @@ # Copyright (c) 2000-2002 by hartmut Goebel # Copyright (c) 1999 John Aycock """ -Common spark parser routines Python. +Common uncompyle parser routines. """ from __future__ import print_function @@ -11,7 +11,7 @@ from __future__ import print_function import sys from uncompyle6.code import iscode -from uncompyle6.parsers.spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG +from spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG class ParserError(Exception): def __init__(self, token, offset): @@ -239,7 +239,7 @@ def python_parser(version, co, out=sys.stdout, showasm=False, if __name__ == '__main__': def parse_test(co): - from uncompyl6 import PYTHON_VERSION + from uncompyle6 import PYTHON_VERSION ast = python_parser(PYTHON_VERSION, co, showasm=True) print(ast) return diff --git a/uncompyle6/parsers/astnode.py b/uncompyle6/parsers/astnode.py index 7df4984d..f2999480 100644 --- a/uncompyle6/parsers/astnode.py +++ b/uncompyle6/parsers/astnode.py @@ -10,8 +10,8 @@ else: class AST(UserList): - def __init__(self, type, kids=[]): - self.type = intern(type) + def __init__(self, kind, kids=[]): + self.type = intern(kind) UserList.__init__(self, kids) def isNone(self): diff --git a/uncompyle6/parsers/parse2.py b/uncompyle6/parsers/parse2.py index c53b0150..c05edd61 100644 --- a/uncompyle6/parsers/parse2.py +++ b/uncompyle6/parsers/parse2.py @@ -19,12 +19,16 @@ from __future__ import print_function from uncompyle6.parser import PythonParser, nop_func from uncompyle6.parsers.astnode import AST -from uncompyle6.parsers.spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG +from spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG +from uncompyle6 import PYTHON3 class Python2Parser(PythonParser): def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG): - GenericASTBuilder.__init__(self, AST, 'stmts', debug=debug_parser) + if PYTHON3: + super().__init__(AST, 'stmts', debug=debug_parser) + else: + super(Python2Parser, self).__init__(AST, 'stmts', debug=debug_parser) self.customized = {} def p_list_comprehension(self, args): diff --git a/uncompyle6/parsers/parse3.py b/uncompyle6/parsers/parse3.py index 1488452c..db940cb3 100644 --- a/uncompyle6/parsers/parse3.py +++ b/uncompyle6/parsers/parse3.py @@ -19,13 +19,17 @@ from __future__ import print_function from uncompyle6.parser import PythonParser, nop_func from uncompyle6.parsers.astnode import AST -from uncompyle6.parsers.spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG +from spark import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG +from uncompyle6 import PYTHON3 class Python3Parser(PythonParser): def __init__(self, debug_parser=PARSER_DEFAULT_DEBUG): self.added_rules = set() - GenericASTBuilder.__init__(self, AST, 'stmts', debug=debug_parser) + if PYTHON3: + super().__init__(AST, 'stmts', debug=debug_parser) + else: + super(Python3Parser, self).__init__(AST, 'stmts', debug=debug_parser) self.new_rules = set() def add_unique_rule(self, rule, opname, count, customize): diff --git a/uncompyle6/semantics/fragments.py b/uncompyle6/semantics/fragments.py index 3fc0845e..2956f0ac 100644 --- a/uncompyle6/semantics/fragments.py +++ b/uncompyle6/semantics/fragments.py @@ -46,7 +46,7 @@ else: from StringIO import StringIO -from uncompyle6.parsers.spark import GenericASTTraversal, GenericASTTraversalPruningException, \ +from spark import GenericASTTraversal, GenericASTTraversalPruningException, \ DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG from types import CodeType diff --git a/uncompyle6/semantics/pysource.py b/uncompyle6/semantics/pysource.py index 5bf06dfb..493ae5c0 100644 --- a/uncompyle6/semantics/pysource.py +++ b/uncompyle6/semantics/pysource.py @@ -70,7 +70,7 @@ from uncompyle6 import PYTHON3 from uncompyle6.code import iscode from uncompyle6.parser import get_python_parser from uncompyle6.parsers.astnode import AST -from uncompyle6.parsers.spark import GenericASTTraversal, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG +from spark import GenericASTTraversal, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG from uncompyle6.scanner import Code, get_scanner from uncompyle6.scanners.tok import Token, NoneToken import uncompyle6.parser as python_parser From 2711c8d06f2230e8afa6fd17ea443ad258282783 Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 27 Apr 2016 23:09:30 -0400 Subject: [PATCH 2/3] Note dependencies on spark --- .travis.yml | 1 + circle.yml | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 114f20b9..7cceb6e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ python: - '3.5' install: +- pip install -r requirements.txt - pip install -r requirements-dev.txt script: diff --git a/circle.yml b/circle.yml index 832f2be5..b95c8a9b 100644 --- a/circle.yml +++ b/circle.yml @@ -6,7 +6,8 @@ machine: dependencies: override: - - pip install -r test-requirements.txt + - pip install -r requirements.txt + - pip install -r requirements-dev.txt test: override: - python ./setup.py develop && make check-2.7 From 34a582b64cf2d1f0703cf5706527bb026ed36faf Mon Sep 17 00:00:00 2001 From: rocky Date: Wed, 27 Apr 2016 23:26:31 -0400 Subject: [PATCH 3/3] Administrivia --- README.rst | 1 + requirements.txt | 2 +- test-requirements.txt | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 test-requirements.txt diff --git a/README.rst b/README.rst index 60c7b744..4987e183 100644 --- a/README.rst +++ b/README.rst @@ -49,6 +49,7 @@ This uses setup.py, so it follows the standard Python routine: :: pip install -r requirements.txt + pip install -r requirements-dev.txt python setup.py install # may need sudo # or if you have pyenv: python setup.py develop diff --git a/requirements.txt b/requirements.txt index 79137d10..af5fcddf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -spark_parser >= 1.0.1 +spark_parser >= 1.0.2 diff --git a/test-requirements.txt b/test-requirements.txt deleted file mode 100644 index e079f8a6..00000000 --- a/test-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pytest