Merge branch 'master' of github.com:rocky/python-uncompyle6

This commit is contained in:
rocky
2016-05-25 20:08:37 -04:00
2 changed files with 16 additions and 5 deletions

View File

@@ -36,7 +36,7 @@ from uncompyle6 import parser
from uncompyle6.scanner import Token, Code, get_scanner
from uncompyle6.semantics.pysource import AST, INDENT_PER_LEVEL, NONE, PRECEDENCE, \
ParserError, TABLE_DIRECT, escape, find_all_globals, find_globals, find_none, minint
ParserError, TABLE_DIRECT, escape, find_all_globals, find_globals, find_none, minint, MAP
if PYTHON3:
from itertools import zip_longest
@@ -67,7 +67,12 @@ TABLE_DIRECT_FRAGMENT = {
'%|for %c%x in %c:\n%+%c%-%|else:\n%+%c%-\n\n', 3, (3, (2,)), 1, 4, -2),
}
MAP_DIRECT_FRAGMENT = dict(TABLE_DIRECT, **TABLE_DIRECT_FRAGMENT),
class FragmentsWalker(pysource.SourceWalker, object):
stacked_params = ('f', 'indent', 'isLambda', '_globals')
def __init__(self, version, scanner, showast=False,
@@ -95,9 +100,6 @@ class FragmentsWalker(pysource.SourceWalker, object):
self.offsets = {}
self.last_finish = -1
# Customize with our more-pervisive rules
TABLE_DIRECT.update(TABLE_DIRECT_FRAGMENT)
f = property(lambda s: s.params['f'],
lambda s, x: s.params.__setitem__('f', x),
lambda s: s.params.__delitem__('f'),
@@ -1442,6 +1444,10 @@ class FragmentsWalker(pysource.SourceWalker, object):
returnNone=rn)
code._tokens = None; code._customize = None # save memory
@classmethod
def _get_mapping(cls, node):
return MAP.get(node, MAP_DIRECT_FRAGMENT)
pass
def deparse_code(version, co, out=StringIO(), showasm=False, showast=False,

View File

@@ -1526,7 +1526,7 @@ class SourceWalker(GenericASTTraversal, object):
self.write(fmt[i:])
def default(self, node):
mapping = MAP.get(node, MAP_DIRECT)
mapping = self._get_mapping(node)
table = mapping[0]
key = node
@@ -1861,6 +1861,11 @@ class SourceWalker(GenericASTTraversal, object):
return ast
@classmethod
def _get_mapping(cls, node):
return MAP.get(node, MAP_DIRECT)
def deparse_code(version, co, out=sys.stdout, showasm=False, showast=False,
showgrammar=False, code_objects={}, compile_mode='exec'):
"""