]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.2/Lib/lib2to3/fixes/fix_paren.py
a954d7cb1995dc2a86faaa6f2d098d11c36145d5
1 """Fixer that addes parentheses where they are required
3 This converts ``[x for x in 1, 2]`` to ``[x for x in (1, 2)]``."""
5 # By Taek Joo Kim and Benjamin Peterson
8 from .. import fixer_base
9 from ..fixer_util
import LParen
, RParen
11 # XXX This doesn't support nested for loops like [x for x in 1, 2 for x in 1, 2]
12 class FixParen(fixer_base
.BaseFix
):
20 target=testlist_safe< any (',' any)+ [',']
29 target=testlist_safe< any (',' any)+ [',']
37 def transform(self
, node
, results
):
38 target
= results
["target"]
41 lparen
.prefix
= target
.prefix
42 target
.prefix
= u
"" # Make it hug the parentheses
43 target
.insert_child(0, lparen
)
44 target
.append_child(RParen())