home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- '''Fixer that addes parentheses where they are required
-
- This converts ``[x for x in 1, 2]`` to ``[x for x in (1, 2)]``.'''
- from import fixer_base
- from fixer_util import LParen, RParen
-
- class FixParen(fixer_base.BaseFix):
- PATTERN = "\n atom< ('[' | '(')\n (listmaker< any\n comp_for<\n 'for' NAME 'in'\n target=testlist_safe< any (',' any)+ [',']\n >\n [any]\n >\n >\n |\n testlist_gexp< any\n comp_for<\n 'for' NAME 'in'\n target=testlist_safe< any (',' any)+ [',']\n >\n [any]\n >\n >)\n (']' | ')') >\n "
-
- def transform(self, node, results):
- target = results['target']
- lparen = LParen()
- lparen.set_prefix(target.get_prefix())
- target.set_prefix('')
- target.insert_child(0, lparen)
- target.append_child(RParen())
-
-
-