You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
small changes
This commit is contained in:
@@ -50,7 +50,9 @@ class PythonParser(GenericASTBuilder):
|
||||
|
||||
if nt in collect and len(args) > 1:
|
||||
#
|
||||
# Collect iterated thingies together.
|
||||
# Collect iterated thingies together. That is rather than
|
||||
# stmts -> stmts stmt -> stmts stmt -> ...
|
||||
# stmms -> stmt stmt ...
|
||||
#
|
||||
rv = args[0]
|
||||
rv.append(args[1])
|
||||
|
@@ -35,7 +35,7 @@ class AST(UserList):
|
||||
rv = str(self.type)
|
||||
for k in self:
|
||||
child_text = str(k).replace('\n', '\n ')
|
||||
if hasattr(k, '__len__'):
|
||||
if hasattr(k, '__len__') and len(k) > 1:
|
||||
rv += '\n(%d) %s' % (len(k), child_text)
|
||||
else:
|
||||
rv += '\n' + child_text
|
||||
|
@@ -732,7 +732,7 @@ class FragmentsWalker(pysource.SourceWalker, object):
|
||||
self.prune()
|
||||
|
||||
def gen_source(self, ast, name, customize, isLambda=False, returnNone=False):
|
||||
"""convert AST to source code"""
|
||||
"""convert AST to Python source code"""
|
||||
|
||||
rn = self.return_none
|
||||
self.return_none = returnNone
|
||||
|
@@ -590,7 +590,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
def write(self, *data):
|
||||
if (len(data) == 0) or (len(data) == 1 and data[0] == ''):
|
||||
return
|
||||
# import pdb; pdb.set_trace()
|
||||
out = ''.join((str(j) for j in data))
|
||||
n = 0
|
||||
for i in out:
|
||||
@@ -812,10 +811,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
if node[-2][0][-1] != 'BUILD_TUPLE_0':
|
||||
node[-2][0].type = 'build_tuple2'
|
||||
self.default(node)
|
||||
# maybe_tuple = node[-2][-1]
|
||||
# if maybe_tuple.type.startswith('BUILD_TUPLE'):
|
||||
# maybe_tuple.type = 'build_tuple2'
|
||||
# self.default(node)
|
||||
|
||||
n_store_subscr = n_binary_subscr = n_delete_subscr
|
||||
|
||||
@@ -988,7 +983,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.prune() # stop recursing
|
||||
|
||||
def n_list_compr(self, node):
|
||||
"""List comprehensions the way they are done in Python2.
|
||||
"""List comprehensions the way they are done in Python 2.
|
||||
"""
|
||||
p = self.prec
|
||||
self.prec = 27
|
||||
@@ -1322,10 +1317,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
l = list(kv_node)
|
||||
i = 0
|
||||
while i < len(l):
|
||||
try:
|
||||
name = self.traverse(l[i+1], indent='')
|
||||
except:
|
||||
from trepan.api import debug; debug()
|
||||
name = self.traverse(l[i+1], indent='')
|
||||
value = self.traverse(l[i], indent=self.indent+(len(name)+2)*' ')
|
||||
self.write(sep, name, ': ', value)
|
||||
sep = line_seperator
|
||||
@@ -1504,7 +1496,6 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
elif typ == 'C':
|
||||
low, high, sep = entry[arg]
|
||||
remaining = len(node[low:high])
|
||||
# remaining = len(node[low:high])
|
||||
for subnode in node[low:high]:
|
||||
self.preorder(subnode)
|
||||
remaining -= 1
|
||||
@@ -1821,7 +1812,7 @@ class SourceWalker(GenericASTTraversal, object):
|
||||
self.classes.pop(-1)
|
||||
|
||||
def gen_source(self, ast, name, customize, isLambda=False, returnNone=False):
|
||||
"""convert AST to source code"""
|
||||
"""convert AST to Python source code"""
|
||||
|
||||
rn = self.return_none
|
||||
self.return_none = returnNone
|
||||
|
Reference in New Issue
Block a user