class_docstr: Base class for implementing magic functions.
  
  Shell functions which can be reached as %function_name. All magic
  functions should accept a string, which they can parse for their own
  needs. This can make some functions easier to type, eg `%cd ../`
  vs. `%cd("../")`
  
  Classes providing magic functions need to subclass this class, and they
  MUST:
  
  - Use the method decorators `@line_magic` and `@cell_magic` to decorate
    individual methods as magic functions, AND
  
  - Use the class decorator `@magics_class` to ensure that the magic
    methods are properly registered at the instance level upon instance
    initialization.
  
  See :mod:`magic_functions` for examples of actual implementation classes.
class_docstr_tok: ["Base","class","for","implementing","magic","functions",".","Shell","functions","which","can","be","reached","as","%","function_name",".","All","magic","functions","should","accept","a","string",",","which","they","can","parse","for","their","own","needs",".","This","can","make","some","functions","easier","to","type",",","eg","`","%","cd","..","\/","`","vs.","`","%","cd","(","``","..","\/","''",")","`","Classes","providing","magic","functions","need","to","subclass","this","class",",","and","they","MUST",":","-","Use","the","method","decorators","`","@","line_magic","`","and","`","@","cell_magic","`","to","decorate","individual","methods","as","magic","functions",",","AND","-","Use","the","class","decorator","`","@","magics_class","`","to","ensure","that","the","magic","methods","are","properly","registered","at","the","instance","level","upon","instance","initialization",".","See",":","mod",":","`","magic_functions","`","for","examples","of","actual","implementation","classes","."]
code: def __init__(self, shell=None, **kwargs):
      if not (self.__class__.registered):
          raise ValueError(
              "Magics subclass without registration - "
              "did you forget to apply @magics_class?"
          )
      if shell is not None:
          if hasattr(shell, "configurables"):
              shell.configurables.append(self)
          if hasattr(shell, "config"):
              kwargs.setdefault("parent", shell)
  
      self.shell = shell
      self.options_table = {}
      # The method decorators are run when the instance doesn't exist yet, so
      # they can only record the names of the methods they are supposed to
      # grab.  Only now, that the instance exists, can we create the proper
      # mapping to bound methods.  So we read the info off the original names
      # table and replace each method name by the actual bound method.
      # But we mustn't clobber the *class* mapping, in case of multiple instances.
      class_magics = self.magics
      self.magics = {}
      for mtype in magic_kinds:
          tab = self.magics[mtype] = {}
          cls_tab = class_magics[mtype]
          for magic_name, meth_name in cls_tab.items():
              if isinstance(meth_name, str):
                  # it's a method name, grab it
                  tab[magic_name] = getattr(self, meth_name)
              else:
                  # it's the real thing
                  tab[magic_name] = meth_name
      # Configurable **needs** to be initiated at the end or the config
      # magics get screwed up.
      super(Magics, self).__init__(**kwargs)
  
imports: import os
  import re
  import sys
  from getopt import getopt, GetoptError
  from traitlets.config.configurable import Configurable
  from .None import oinspect
  from .error import UsageError
  from .inputtransformer2 import ESC_MAGIC, ESC_MAGIC2
  from ..utils.ipstruct import Struct
  from ..utils.process import arg_split
  from ..utils.text import dedent
  from traitlets import Bool, Dict, Instance, observe
  from logging import error
label_desc: Use image node_id 1 to create a new Magics object from inherited base classes: Configurable with example: obj = Magics(shell)