You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
DRY code; localize 3.{5,6} grammar rules..
helper.py, pysource: has code to flatten list used in n_list and n_build_tuple_unpack_with_call parse3{5,6}.py: localize grammar rules with BEFORE_ASYNC_WITH
This commit is contained in:
@@ -127,6 +127,28 @@ def print_docstring(self, indent, docstring):
|
||||
self.println(indent, trimmed[-1], quote)
|
||||
return True
|
||||
|
||||
|
||||
def flatten_list(node):
|
||||
"""
|
||||
List of expressions may be nested in groups of 32 and 1024
|
||||
items. flatten that out and return the list
|
||||
"""
|
||||
flat_elems = []
|
||||
for elem in node:
|
||||
if elem == 'expr1024':
|
||||
for subelem in elem:
|
||||
for subsubelem in subelem:
|
||||
flat_elems.append(subsubelem)
|
||||
elif elem == 'expr32':
|
||||
for subelem in elem:
|
||||
flat_elems.append(subelem)
|
||||
else:
|
||||
flat_elems.append(elem)
|
||||
pass
|
||||
pass
|
||||
return flat_elems
|
||||
|
||||
|
||||
# if __name__ == '__main__':
|
||||
# if PYTHON3:
|
||||
# from io import StringIO
|
||||
|
Reference in New Issue
Block a user