# Path: coconut/icoconut/root.py
# class CoconutKernelApp(IPKernelApp, object):
#     """IPython kernel app that uses the Coconut kernel."""
#     name = "coconut-kernel"
#     classes = IPKernelApp.classes + [CoconutKernel, CoconutShell]
#     kernel_class = CoconutKernel
#     subcommands = {}
# 
# class CoconutShellEmbed(InteractiveShellEmbed, object):
#     """InteractiveShellEmbed for Coconut."""
#     exec(INTERACTIVE_SHELL_CODE.format(dict="{}", cls="CoconutShellEmbed"))


from coconut.root import *  # NOQA
from coconut.icoconut.root import CoconutKernelApp, CoconutShellEmbed
from IPython.utils.frame import extract_module_locals
from IPython.terminal.ipapp import load_default_config
from IPython.core.interactiveshell import InteractiveShell
import sys
    # save ps1/ps2 if defined
    ps1 = None
    ps2 = None
    try:
        ps1 = sys.ps1
        ps2 = sys.ps2
    except AttributeError:
        pass
    # save previous instance
    saved_shell_instance = InteractiveShell._instance
    if saved_shell_instance is not None:
        cls = type(saved_shell_instance)
        cls.clear_instance()
    frame = sys._getframe(1)
    shell = CoconutShellEmbed.instance(
        _init_location_id='%s:%s' % (
            frame.f_code.co_filename,
            frame.f_lineno,
        ),
        **kwargs
    )
    shell(
        header=header,
        stack_depth=stack_depth,
        compile_flags=compile_flags,
        _call_location_id='%s:%s' % (
            frame.f_code.co_filename,
            frame.f_lineno,
        ),
    )

# Path: coconut/icoconut/root.py
# class CoconutKernelApp(IPKernelApp, object):
#     """IPython kernel app that uses the Coconut kernel."""
#     name = "coconut-kernel"
#     classes = IPKernelApp.classes + [CoconutKernel, CoconutShell]
#     kernel_class = CoconutKernel
#     subcommands = {}
# 
# class CoconutShellEmbed(InteractiveShellEmbed, object):
#     """InteractiveShellEmbed for Coconut."""
#     exec(INTERACTIVE_SHELL_CODE.format(dict="{}", cls="CoconutShellEmbed"))


# Path: coconut/icoconut/embed.py
from coconut.root import *  # NOQA
from coconut.icoconut.root import CoconutKernelApp, CoconutShellEmbed
from IPython.utils.frame import extract_module_locals
from IPython.terminal.ipapp import load_default_config
from IPython.core.interactiveshell import InteractiveShell
import sys

    # save ps1/ps2 if defined
    ps1 = None
    ps2 = None
    try:
        ps1 = sys.ps1
        ps2 = sys.ps2
    except AttributeError:
        pass
    # save previous instance
    saved_shell_instance = InteractiveShell._instance
    if saved_shell_instance is not None:
        cls = type(saved_shell_instance)
        cls.clear_instance()
    frame = sys._getframe(1)
    shell = CoconutShellEmbed.instance(
        _init_location_id='%s:%s' % (
            frame.f_code.co_filename,
            frame.f_lineno,
        ),
        **kwargs
    )
    shell(
        header=header,
        stack_depth=stack_depth,
        compile_flags=compile_flags,
        _call_location_id='%s:%s' % (
            frame.f_code.co_filename,
            frame.f_lineno,
        ),
    )

    CoconutShellEmbed.clear_instance()