You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 16:59:52 +08:00
More source-code line indention in make_function..
and remove Python 3 situations from make_function2()
This commit is contained in:
@@ -134,7 +134,6 @@ def make_function3_annotate(self, node, isLambda, nested=1,
|
|||||||
indent = ' ' * l
|
indent = ' ' * l
|
||||||
line_number = self.line_number
|
line_number = self.line_number
|
||||||
|
|
||||||
|
|
||||||
if 4 & code.co_flags: # flag 2 -> variable number of args
|
if 4 & code.co_flags: # flag 2 -> variable number of args
|
||||||
self.write('*%s' % code.co_varnames[argc + kw_pairs])
|
self.write('*%s' % code.co_varnames[argc + kw_pairs])
|
||||||
argc += 1
|
argc += 1
|
||||||
@@ -291,10 +290,7 @@ def make_function2(self, node, isLambda, nested=1, codeNode=None):
|
|||||||
params.reverse() # back to correct order
|
params.reverse() # back to correct order
|
||||||
|
|
||||||
if 4 & code.co_flags: # flag 2 -> variable number of args
|
if 4 & code.co_flags: # flag 2 -> variable number of args
|
||||||
if self.version > 3.0:
|
params.append('*%s' % code.co_varnames[argc])
|
||||||
params.append('*%s' % code.co_varnames[argc + kw_pairs])
|
|
||||||
else:
|
|
||||||
params.append('*%s' % code.co_varnames[argc])
|
|
||||||
argc += 1
|
argc += 1
|
||||||
|
|
||||||
# dump parameter list (with default values)
|
# dump parameter list (with default values)
|
||||||
@@ -302,7 +298,6 @@ def make_function2(self, node, isLambda, nested=1, codeNode=None):
|
|||||||
self.write("lambda ", ", ".join(params))
|
self.write("lambda ", ", ".join(params))
|
||||||
else:
|
else:
|
||||||
self.write("(", ", ".join(params))
|
self.write("(", ", ".join(params))
|
||||||
# self.println(indent, '#flags:\t', int(code.co_flags))
|
|
||||||
|
|
||||||
if kw_args > 0:
|
if kw_args > 0:
|
||||||
if not (4 & code.co_flags):
|
if not (4 & code.co_flags):
|
||||||
@@ -317,8 +312,6 @@ def make_function2(self, node, isLambda, nested=1, codeNode=None):
|
|||||||
for n in node:
|
for n in node:
|
||||||
if n == 'pos_arg':
|
if n == 'pos_arg':
|
||||||
continue
|
continue
|
||||||
elif self.version >= 3.4 and n.type != 'kwargs':
|
|
||||||
continue
|
|
||||||
else:
|
else:
|
||||||
self.preorder(n)
|
self.preorder(n)
|
||||||
break
|
break
|
||||||
@@ -452,6 +445,12 @@ def make_function3(self, node, isLambda, nested=1, codeNode=None):
|
|||||||
self.write("lambda ")
|
self.write("lambda ")
|
||||||
else:
|
else:
|
||||||
self.write("(")
|
self.write("(")
|
||||||
|
pass
|
||||||
|
|
||||||
|
last_line = self.f.getvalue().split("\n")[-1]
|
||||||
|
l = len(last_line)
|
||||||
|
indent = ' ' * l
|
||||||
|
line_number = self.line_number
|
||||||
|
|
||||||
if 4 & code.co_flags: # flag 2 -> variable number of args
|
if 4 & code.co_flags: # flag 2 -> variable number of args
|
||||||
self.write('*%s' % code.co_varnames[argc + kw_pairs])
|
self.write('*%s' % code.co_varnames[argc + kw_pairs])
|
||||||
@@ -466,7 +465,11 @@ def make_function3(self, node, isLambda, nested=1, codeNode=None):
|
|||||||
self.write(paramnames[i] + '=')
|
self.write(paramnames[i] + '=')
|
||||||
i += 1
|
i += 1
|
||||||
self.preorder(n)
|
self.preorder(n)
|
||||||
suffix = ', '
|
if (line_number != self.line_number):
|
||||||
|
suffix = ",\n" + indent
|
||||||
|
line_number = self.line_number
|
||||||
|
else:
|
||||||
|
suffix = ', '
|
||||||
|
|
||||||
if kw_args > 0:
|
if kw_args > 0:
|
||||||
if not (4 & code.co_flags):
|
if not (4 & code.co_flags):
|
||||||
|
Reference in New Issue
Block a user