You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Add "transfrormd_by" param to SyntaxTree
This aligns code more with decompyle3
This commit is contained in:
@@ -6,9 +6,9 @@ intern = sys.intern
|
|||||||
|
|
||||||
|
|
||||||
class SyntaxTree(spark_AST):
|
class SyntaxTree(spark_AST):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, transformed_by=None, **kwargs):
|
||||||
|
self.transformed_by = transformed_by
|
||||||
super(SyntaxTree, self).__init__(*args, **kwargs)
|
super(SyntaxTree, self).__init__(*args, **kwargs)
|
||||||
self.transformed_by = None
|
|
||||||
|
|
||||||
def isNone(self):
|
def isNone(self):
|
||||||
"""An SyntaxTree None token. We can't use regular list comparisons
|
"""An SyntaxTree None token. We can't use regular list comparisons
|
||||||
|
@@ -378,8 +378,9 @@ class TreeTransform(GenericASTTraversal, object):
|
|||||||
|
|
||||||
def n_import_from37(self, node):
|
def n_import_from37(self, node):
|
||||||
importlist37 = node[3]
|
importlist37 = node[3]
|
||||||
assert importlist37 == "importlist37"
|
if importlist37 != "importlist37":
|
||||||
if len(importlist37) == 1:
|
return node
|
||||||
|
if len(importlist37) == 1 and importlist37 == "importlist37":
|
||||||
alias37 = importlist37[0]
|
alias37 = importlist37[0]
|
||||||
store = alias37[1]
|
store = alias37[1]
|
||||||
assert store == "store"
|
assert store == "store"
|
||||||
@@ -394,9 +395,10 @@ class TreeTransform(GenericASTTraversal, object):
|
|||||||
# import_as37 ::= LOAD_CONST LOAD_CONST importlist37 store POP_TOP
|
# import_as37 ::= LOAD_CONST LOAD_CONST importlist37 store POP_TOP
|
||||||
# 'import_as37': ( '%|import %c as %c\n', 2, -2),
|
# 'import_as37': ( '%|import %c as %c\n', 2, -2),
|
||||||
node = SyntaxTree(
|
node = SyntaxTree(
|
||||||
"import_as37", [node[0], node[1], import_name_attr, store, node[-1]]
|
"import_as37",
|
||||||
|
[node[0], node[1], import_name_attr, store, node[-1]],
|
||||||
|
transformed_by="n_import_from37",
|
||||||
)
|
)
|
||||||
node.transformed_by = "n_import_from37"
|
|
||||||
pass
|
pass
|
||||||
pass
|
pass
|
||||||
return node
|
return node
|
||||||
|
Reference in New Issue
Block a user