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 x0ret's code a little bit.
This commit is contained in:
@@ -31,28 +31,31 @@ def customize_for_version26_27(self, version):
|
||||
if version > 2.6:
|
||||
TABLE_DIRECT.update({
|
||||
'except_cond2': ( '%|except %c as %c:\n', 1, 5 ),
|
||||
# When a generator is a single parameter of a function,
|
||||
# it doesn't need the surrounding parenethesis.
|
||||
'generator_no_parens': ('%c%P', 0, (1, -1, ', ', 100)),
|
||||
})
|
||||
else:
|
||||
TABLE_DIRECT.update({
|
||||
'testtrue_then': ( 'not %p', (0, 22) ),
|
||||
|
||||
})
|
||||
|
||||
def n_call(node):
|
||||
mapping = self._get_mapping(node)
|
||||
table = mapping[0]
|
||||
key = node
|
||||
for i in mapping[1:]:
|
||||
key = key[i]
|
||||
pass
|
||||
if key.kind == 'CALL_FUNCTION_1':
|
||||
# A function with one argument. If this is a generator,
|
||||
# no parenthesis is needed.
|
||||
args_node = node[-2]
|
||||
if args_node == 'expr':
|
||||
n = args_node[0]
|
||||
if n == 'generator_exp':
|
||||
template = ('%c%P', 0, (1, -1, ', ', 100))
|
||||
self.template_engine(template, node)
|
||||
self.prune()
|
||||
node.kind = 'generator_no_parens'
|
||||
pass
|
||||
pass
|
||||
|
||||
self.default(node)
|
||||
self.n_call = n_call
|
||||
|
Reference in New Issue
Block a user