# Path: picatrix/lib/state.py
# def state(refresh_state: bool = False):
#   """Property that returns a state object."""
#   # pylint: disable=global-statement
#   # Making sure we have only one state object.
#   global __state
# 
#   with _LOCK:
#     if refresh_state or __state is None:
#       __state = State()
# 
#     return __state
# 
# Path: picatrix/lib/utils.py
# def ask_question(question: Text, input_type: Optional[Any] = Text) -> Any:
# def clear_notebook_output():
# def ipython_bind_global(name: Text, value: Any) -> Any:
# def ipython_get_global(name: Text) -> Any:
# def ipython_remove_global(name: Text):


import functools
import pandas
from dataclasses import dataclass
from typing import Any, Callable, Dict, List, Optional, Text, Tuple, Union
from IPython import get_ipython
from picatrix.lib import state, utils
          magics to determine whether a magic should be registered or not, for
          instance basing that on whether the notebook is able to reach the
          required service, or whether a connection to a client can be achieved,
          etc. This is optional and if not provided a magic will be registered.

    Raises:
      KeyError: if the magic is already registered.
    """
    if conditional and not conditional():
      return

    magic_name = function.magic_name

    if magic_name in cls._magics:
      raise KeyError(f'The magic [{magic_name}] is already registered.')

    ip = get_ipython()
    if ip:
      ip.register_magic_function(
          function, magic_kind='line_cell', magic_name=magic_name)

    cls._magics[magic_name] = function
    function_name = f'{magic_name}_func'

    def capture_output(function, name):
      """A function that wraps around magic functions to capture output."""

      @functools.wraps(function)
      def wrapper(*args, **kwargs):
        function_output = function(*args, **kwargs)

# Path: picatrix/lib/state.py
# def state(refresh_state: bool = False):
#   """Property that returns a state object."""
#   # pylint: disable=global-statement
#   # Making sure we have only one state object.
#   global __state
# 
#   with _LOCK:
#     if refresh_state or __state is None:
#       __state = State()
# 
#     return __state
# 
# Path: picatrix/lib/utils.py
# def ask_question(question: Text, input_type: Optional[Any] = Text) -> Any:
# def clear_notebook_output():
# def ipython_bind_global(name: Text, value: Any) -> Any:
# def ipython_get_global(name: Text) -> Any:
# def ipython_remove_global(name: Text):


# Path: picatrix/lib/manager.py
import functools
import pandas
from dataclasses import dataclass
from typing import Any, Callable, Dict, List, Optional, Text, Tuple, Union
from IPython import get_ipython
from picatrix.lib import state, utils

          magics to determine whether a magic should be registered or not, for
          instance basing that on whether the notebook is able to reach the
          required service, or whether a connection to a client can be achieved,
          etc. This is optional and if not provided a magic will be registered.

    Raises:
      KeyError: if the magic is already registered.
    """
    if conditional and not conditional():
      return

    magic_name = function.magic_name

    if magic_name in cls._magics:
      raise KeyError(f'The magic [{magic_name}] is already registered.')

    ip = get_ipython()
    if ip:
      ip.register_magic_function(
          function, magic_kind='line_cell', magic_name=magic_name)

    cls._magics[magic_name] = function
    function_name = f'{magic_name}_func'

    def capture_output(function, name):
      """A function that wraps around magic functions to capture output."""

      @functools.wraps(function)
      def wrapper(*args, **kwargs):
        function_output = function(*args, **kwargs)

        state_obj = state.state()