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/.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/README.rst b/README.rst index 713f5bb8..4987e183 100644 --- a/README.rst +++ b/README.rst @@ -48,6 +48,8 @@ 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/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 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..af5fcddf --- /dev/null +++ b/requirements.txt @@ -0,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 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