You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Add tree transformation phase...
if ... else if ... -> if ... elif .. if .. : raise AsssertionError -> assert Add options --tree=before --tree=after -T expanded to include this This code ported from decompyle3. x0ret did all the heavy lifting.
This commit is contained in:
@@ -7,6 +7,10 @@ if PYTHON3:
|
||||
intern = sys.intern
|
||||
|
||||
class SyntaxTree(spark_AST):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SyntaxTree, self).__init__(*args, **kwargs)
|
||||
self.transformed_by = None
|
||||
|
||||
def isNone(self):
|
||||
"""An SyntaxTree None token. We can't use regular list comparisons
|
||||
because SyntaxTree token offsets might be different"""
|
||||
@@ -23,6 +27,11 @@ class SyntaxTree(spark_AST):
|
||||
if len(self) > 1:
|
||||
rv += " (%d)" % (len(self))
|
||||
enumerate_children = True
|
||||
if self.transformed_by is not None:
|
||||
if self.transformed_by is True:
|
||||
rv += " (transformed)"
|
||||
else:
|
||||
rv += " (transformed by %s)" % self.transformed_by
|
||||
rv = indent + rv
|
||||
indent += ' '
|
||||
i = 0
|
||||
|
Reference in New Issue
Block a user