Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../usr/lib64/python2..../lib2to3/fixes
File: fix_exec.py
# Copyright 2006 Google, Inc. All Rights Reserved.
[0] Fix | Delete
# Licensed to PSF under a Contributor Agreement.
[1] Fix | Delete
[2] Fix | Delete
"""Fixer for exec.
[3] Fix | Delete
[4] Fix | Delete
This converts usages of the exec statement into calls to a built-in
[5] Fix | Delete
exec() function.
[6] Fix | Delete
[7] Fix | Delete
exec code in ns1, ns2 -> exec(code, ns1, ns2)
[8] Fix | Delete
"""
[9] Fix | Delete
[10] Fix | Delete
# Local imports
[11] Fix | Delete
from .. import pytree
[12] Fix | Delete
from .. import fixer_base
[13] Fix | Delete
from ..fixer_util import Comma, Name, Call
[14] Fix | Delete
[15] Fix | Delete
[16] Fix | Delete
class FixExec(fixer_base.BaseFix):
[17] Fix | Delete
BM_compatible = True
[18] Fix | Delete
[19] Fix | Delete
PATTERN = """
[20] Fix | Delete
exec_stmt< 'exec' a=any 'in' b=any [',' c=any] >
[21] Fix | Delete
|
[22] Fix | Delete
exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any >
[23] Fix | Delete
"""
[24] Fix | Delete
[25] Fix | Delete
def transform(self, node, results):
[26] Fix | Delete
assert results
[27] Fix | Delete
syms = self.syms
[28] Fix | Delete
a = results["a"]
[29] Fix | Delete
b = results.get("b")
[30] Fix | Delete
c = results.get("c")
[31] Fix | Delete
args = [a.clone()]
[32] Fix | Delete
args[0].prefix = ""
[33] Fix | Delete
if b is not None:
[34] Fix | Delete
args.extend([Comma(), b.clone()])
[35] Fix | Delete
if c is not None:
[36] Fix | Delete
args.extend([Comma(), c.clone()])
[37] Fix | Delete
[38] Fix | Delete
return Call(Name(u"exec"), args, prefix=node.prefix)
[39] Fix | Delete
[40] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function