]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/lib2to3/fixes/fix_exec.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / lib2to3 / fixes / fix_exec.py
CommitLineData
4710c53d 1# Copyright 2006 Google, Inc. All Rights Reserved.\r
2# Licensed to PSF under a Contributor Agreement.\r
3\r
4"""Fixer for exec.\r
5\r
6This converts usages of the exec statement into calls to a built-in\r
7exec() function.\r
8\r
9exec code in ns1, ns2 -> exec(code, ns1, ns2)\r
10"""\r
11\r
12# Local imports\r
13from .. import pytree\r
14from .. import fixer_base\r
15from ..fixer_util import Comma, Name, Call\r
16\r
17\r
18class FixExec(fixer_base.BaseFix):\r
19 BM_compatible = True\r
20\r
21 PATTERN = """\r
22 exec_stmt< 'exec' a=any 'in' b=any [',' c=any] >\r
23 |\r
24 exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any >\r
25 """\r
26\r
27 def transform(self, node, results):\r
28 assert results\r
29 syms = self.syms\r
30 a = results["a"]\r
31 b = results.get("b")\r
32 c = results.get("c")\r
33 args = [a.clone()]\r
34 args[0].prefix = ""\r
35 if b is not None:\r
36 args.extend([Comma(), b.clone()])\r
37 if c is not None:\r
38 args.extend([Comma(), c.clone()])\r
39\r
40 return Call(Name(u"exec"), args, prefix=node.prefix)\r