# Path: py3kwarn2to3/fixer_util.py
# def Comma():
#     """A comma leaf"""
#     return Leaf(token.COMMA, u",")
# 
# def Name(name, prefix=None):
#     """Return a NAME leaf"""
#     return Leaf(token.NAME, name, prefix=prefix)
# 
# def Call(func_name, args=None, prefix=None):
#     """A function call"""
#     node = Node(syms.power, [func_name, ArgList(args)])
#     if prefix is not None:
#         node.prefix = prefix
#     return node


from .. import fixer_base
from ..fixer_util import Comma, Name, Call

"""Fixer for exec.

This converts usages of the exec statement into calls to a built-in
exec() function.

exec code in ns1, ns2 -> exec(code, ns1, ns2)
"""

# Local imports


class FixExec(fixer_base.BaseFix):
    BM_compatible = True

    PATTERN = """
    exec_stmt< 'exec' a=any 'in' b=any [',' c=any] >
    |
    exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any >
    """

    def transform(self, node, results):
        assert results
        syms = self.syms
        a = results["a"]
        b = results.get("b")
        c = results.get("c")
        args = [a.clone()]
        args[0].prefix = ""
        if b is not None:

# Path: py3kwarn2to3/fixer_util.py
# def Comma():
#     """A comma leaf"""
#     return Leaf(token.COMMA, u",")
# 
# def Name(name, prefix=None):
#     """Return a NAME leaf"""
#     return Leaf(token.NAME, name, prefix=prefix)
# 
# def Call(func_name, args=None, prefix=None):
#     """A function call"""
#     node = Node(syms.power, [func_name, ArgList(args)])
#     if prefix is not None:
#         node.prefix = prefix
#     return node


# Path: py3kwarn2to3/fixes/fix_exec.py
from .. import fixer_base
from ..fixer_util import Comma, Name, Call


"""Fixer for exec.

This converts usages of the exec statement into calls to a built-in
exec() function.

exec code in ns1, ns2 -> exec(code, ns1, ns2)
"""

# Local imports


class FixExec(fixer_base.BaseFix):
    BM_compatible = True

    PATTERN = """
    exec_stmt< 'exec' a=any 'in' b=any [',' c=any] >
    |
    exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any >
    """

    def transform(self, node, results):
        assert results
        syms = self.syms
        a = results["a"]
        b = results.get("b")
        c = results.get("c")
        args = [a.clone()]
        args[0].prefix = ""
        if b is not None:

            args.extend([Comma(), b.clone()])