You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 08:49:51 +08:00
Merge branch 'master' of github.com:rocky/python-uncompyle6
This commit is contained in:
@@ -36,7 +36,7 @@ from uncompyle6 import parser
|
|||||||
from uncompyle6.scanner import Token, Code, get_scanner
|
from uncompyle6.scanner import Token, Code, get_scanner
|
||||||
|
|
||||||
from uncompyle6.semantics.pysource import AST, INDENT_PER_LEVEL, NONE, PRECEDENCE, \
|
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:
|
if PYTHON3:
|
||||||
from itertools import zip_longest
|
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),
|
'%|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):
|
class FragmentsWalker(pysource.SourceWalker, object):
|
||||||
|
|
||||||
stacked_params = ('f', 'indent', 'isLambda', '_globals')
|
stacked_params = ('f', 'indent', 'isLambda', '_globals')
|
||||||
|
|
||||||
def __init__(self, version, scanner, showast=False,
|
def __init__(self, version, scanner, showast=False,
|
||||||
@@ -95,9 +100,6 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
self.offsets = {}
|
self.offsets = {}
|
||||||
self.last_finish = -1
|
self.last_finish = -1
|
||||||
|
|
||||||
# Customize with our more-pervisive rules
|
|
||||||
TABLE_DIRECT.update(TABLE_DIRECT_FRAGMENT)
|
|
||||||
|
|
||||||
f = property(lambda s: s.params['f'],
|
f = property(lambda s: s.params['f'],
|
||||||
lambda s, x: s.params.__setitem__('f', x),
|
lambda s, x: s.params.__setitem__('f', x),
|
||||||
lambda s: s.params.__delitem__('f'),
|
lambda s: s.params.__delitem__('f'),
|
||||||
@@ -1442,6 +1444,10 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
|||||||
returnNone=rn)
|
returnNone=rn)
|
||||||
code._tokens = None; code._customize = None # save memory
|
code._tokens = None; code._customize = None # save memory
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _get_mapping(cls, node):
|
||||||
|
return MAP.get(node, MAP_DIRECT_FRAGMENT)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def deparse_code(version, co, out=StringIO(), showasm=False, showast=False,
|
def deparse_code(version, co, out=StringIO(), showasm=False, showast=False,
|
||||||
|
@@ -1526,7 +1526,7 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
self.write(fmt[i:])
|
self.write(fmt[i:])
|
||||||
|
|
||||||
def default(self, node):
|
def default(self, node):
|
||||||
mapping = MAP.get(node, MAP_DIRECT)
|
mapping = self._get_mapping(node)
|
||||||
table = mapping[0]
|
table = mapping[0]
|
||||||
key = node
|
key = node
|
||||||
|
|
||||||
@@ -1861,6 +1861,11 @@ class SourceWalker(GenericASTTraversal, object):
|
|||||||
|
|
||||||
return ast
|
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,
|
def deparse_code(version, co, out=sys.stdout, showasm=False, showast=False,
|
||||||
showgrammar=False, code_objects={}, compile_mode='exec'):
|
showgrammar=False, code_objects={}, compile_mode='exec'):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user