# Path: picatrix/lib/framework.py
# class MagicProtocol(Protocol):
# class MagicArgument:
# class MagicArgumentParser(argparse.ArgumentParser):
# class _Magic:
#   def __call__(self, *args: Any) -> Any:
#   def __init__(self, *argc, **kwargs):
#   def __init__(self, *args, **kwargs):
#   def exit(self, status: Optional[int] = 0, message: Optional[Text] = ''):
#   def __init__(
#       self,
#       fn: MagicProtocol,
#       arguments: Optional[List[MagicArgument]] = None,
#       name_func: Optional[Callable[[Text], Text]] = None):
#   def __call__(self, line: Text, cell: Optional[Text] = None) -> Optional[Any]:
#   def __dir__(self):
#   def __getattribute__(self, name: Text):
# def _get_arguments_from_arg_lines(
#     arg_lines: List[Text]) -> List[Dict[Text, Text]]:
# def _get_argument_lines_from_docstring(lines: List[Text]) -> List[Text]:
# def _add_function_arguments_to_parser(
#     fn: MagicProtocol, parser: MagicArgumentParser):
# def _parse_docstring(function: MagicProtocol) -> List[Dict[Text, Text]]:
# def _parse_line_string(line: Text) -> List[Text]:
# def picatrix_helper(function: Callable[..., Any]) -> Callable[..., Any]:
# def picatrix_magic(
#     function: Optional[MagicProtocol] = None,
#     arguments: Optional[List[MagicArgument]] = None,
#     name_func: Optional[Callable[[Text], Text]] = None,
#     conditional: Optional[Callable[[None], bool]] = None) -> MagicProtocol:
#   def wrapper(func):
# 
# Path: picatrix/lib/manager.py
# class Helper:
# class MagicManager:
#   MAGICS_DF_COLUMNS = ['name', 'description', 'line', 'cell', 'function']
#   def clear_helpers(cls):
#   def clear_magics(cls):
#   def deregister_helper(cls, helper_name: Text):
#   def deregister_magic(cls, magic_name: Text):
#   def get_helper(cls, helper_name: Text) -> Optional[Callable[..., Any]]:
#   def get_magic(cls, magic_name: Text) -> Callable[[Text, Text], Text]:
#   def get_helper_info(
#       cls,
#       as_pandas: Optional[bool] = True
#   ) -> Union[pandas.DataFrame, List[Tuple[Text, Text]]]:
#   def get_magic_info(
#       cls,
#       as_pandas: Optional[bool] = True
#   ) -> Union[pandas.DataFrame, List[Tuple[Text, Text]]]:
#   def register_helper(
#       cls, name: Text, helper: Any, typing_help: Dict[Text, Any]):
#   def register_magic(
#       cls,
#       function: Callable[[Text, Text], Text],
#       conditional: Callable[[], bool] = None):
#     def capture_output(function, name):
#       def wrapper(*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


from typing import Any, Optional, Text
from picatrix.lib import framework, manager, state
import pandas
  Args:
    data (str): If empty an overview of all registered magics is provided,
        otherwise the help message of a particular magic is provided.

  Returns:
      A pandas DataFrame that contains the names and basic information about
      every registered magic or information about a single magic if
      the data string is provided.
  """
  if not data:
    return manager.MagicManager.get_magic_info(as_pandas=True)

  magic_obj = manager.MagicManager.get_magic(data)

  if not magic_obj:
    return pandas.DataFrame()

  description = magic_obj.__doc__.split('\n')[0]
  return pandas.DataFrame(
      [
          {
              'name': magic_obj.magic_name,
              'description': description,
              'function': '{0:s}_func'.format(magic_obj.magic_name),
              'help': magic_obj.argument_parser.format_help()
          }
      ])


# pylint: disable=unused-argument

# Path: picatrix/lib/framework.py
# class MagicProtocol(Protocol):
# class MagicArgument:
# class MagicArgumentParser(argparse.ArgumentParser):
# class _Magic:
#   def __call__(self, *args: Any) -> Any:
#   def __init__(self, *argc, **kwargs):
#   def __init__(self, *args, **kwargs):
#   def exit(self, status: Optional[int] = 0, message: Optional[Text] = ''):
#   def __init__(
#       self,
#       fn: MagicProtocol,
#       arguments: Optional[List[MagicArgument]] = None,
#       name_func: Optional[Callable[[Text], Text]] = None):
#   def __call__(self, line: Text, cell: Optional[Text] = None) -> Optional[Any]:
#   def __dir__(self):
#   def __getattribute__(self, name: Text):
# def _get_arguments_from_arg_lines(
#     arg_lines: List[Text]) -> List[Dict[Text, Text]]:
# def _get_argument_lines_from_docstring(lines: List[Text]) -> List[Text]:
# def _add_function_arguments_to_parser(
#     fn: MagicProtocol, parser: MagicArgumentParser):
# def _parse_docstring(function: MagicProtocol) -> List[Dict[Text, Text]]:
# def _parse_line_string(line: Text) -> List[Text]:
# def picatrix_helper(function: Callable[..., Any]) -> Callable[..., Any]:
# def picatrix_magic(
#     function: Optional[MagicProtocol] = None,
#     arguments: Optional[List[MagicArgument]] = None,
#     name_func: Optional[Callable[[Text], Text]] = None,
#     conditional: Optional[Callable[[None], bool]] = None) -> MagicProtocol:
#   def wrapper(func):
# 
# Path: picatrix/lib/manager.py
# class Helper:
# class MagicManager:
#   MAGICS_DF_COLUMNS = ['name', 'description', 'line', 'cell', 'function']
#   def clear_helpers(cls):
#   def clear_magics(cls):
#   def deregister_helper(cls, helper_name: Text):
#   def deregister_magic(cls, magic_name: Text):
#   def get_helper(cls, helper_name: Text) -> Optional[Callable[..., Any]]:
#   def get_magic(cls, magic_name: Text) -> Callable[[Text, Text], Text]:
#   def get_helper_info(
#       cls,
#       as_pandas: Optional[bool] = True
#   ) -> Union[pandas.DataFrame, List[Tuple[Text, Text]]]:
#   def get_magic_info(
#       cls,
#       as_pandas: Optional[bool] = True
#   ) -> Union[pandas.DataFrame, List[Tuple[Text, Text]]]:
#   def register_helper(
#       cls, name: Text, helper: Any, typing_help: Dict[Text, Any]):
#   def register_magic(
#       cls,
#       function: Callable[[Text, Text], Text],
#       conditional: Callable[[], bool] = None):
#     def capture_output(function, name):
#       def wrapper(*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/magics/common.py
from typing import Any, Optional, Text
from picatrix.lib import framework, manager, state
import pandas

  Args:
    data (str): If empty an overview of all registered magics is provided,
        otherwise the help message of a particular magic is provided.

  Returns:
      A pandas DataFrame that contains the names and basic information about
      every registered magic or information about a single magic if
      the data string is provided.
  """
  if not data:
    return manager.MagicManager.get_magic_info(as_pandas=True)

  magic_obj = manager.MagicManager.get_magic(data)

  if not magic_obj:
    return pandas.DataFrame()

  description = magic_obj.__doc__.split('\n')[0]
  return pandas.DataFrame(
      [
          {
              'name': magic_obj.magic_name,
              'description': description,
              'function': '{0:s}_func'.format(magic_obj.magic_name),
              'help': magic_obj.argument_parser.format_help()
          }
      ])


# pylint: disable=unused-argument

@framework.picatrix_magic