o
    û›h  ã                   @   sZ   d Z ddlZddlmZ ddlmZmZmZ ddlm	Z	 e 
d¡ZeG dd„ deƒƒZdS )	z9Implementation of configuration-related magic functions.
é    N)Ú
UsageError)ÚMagicsÚmagics_classÚ
line_magic)Úerrorz
^\w+\.\w+$c                       s(   e Zd Z‡ fdd„Zedd„ ƒZ‡  ZS )ÚConfigMagicsc                    s   t t| ƒ |¡ g | _d S ©N)Úsuperr   Ú__init__Úconfigurables)ÚselfÚshell©Ú	__class__© úPc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/core/magics/config.pyr
      s   
zConfigMagics.__init__c                 C   sˆ  ddl m} ttdd„ | jjD ƒƒdd„ d�}dd„ |D ƒ}| ¡ }|s4td	ƒ |D ]}td
|ƒ q*dS ||v rY|| |¡ }|j	}| 
|¡}	t t dtj¡d|	¡}	t|	ƒ dS t |¡ro| d¡\}}
t|| |¡ |
ƒS d|vr’d}| ¡ }|D ]}|| ¡ kr‹|d|  } nq{t|| ƒ‚|ƒ }td| | jjtƒ ƒ |D ]}z| |¡ W q¢ tyÁ } z
t|ƒ W Y d}~q¢d}~ww dS )aæ  configure IPython

            %config Class[.trait=value]

        This magic exposes most of the IPython config system. Any
        Configurable class should be able to be configured with the simple
        line::

            %config Class.trait=value

        Where `value` will be resolved in the user's namespace, if it is an
        expression or variable name.

        Examples
        --------

        To see what classes are available for config, pass no arguments::

            In [1]: %config
            Available objects for config:
                AliasManager
                DisplayFormatter
                HistoryManager
                IPCompleter
                LoggingMagics
                MagicsManager
                OSMagics
                PrefilterManager
                ScriptMagics
                TerminalInteractiveShell

        To view what is configurable on a given class, just pass the class
        name::

            In [2]: %config LoggingMagics
            LoggingMagics(Magics) options
            ---------------------------
            LoggingMagics.quiet=<Bool>
                Suppress output of log state when logging is enabled
                Current: False

        but the real use is in setting values::

            In [3]: %config LoggingMagics.quiet = True

        and these values are read from the user_ns if they are variables::

            In [4]: feeling_quiet=False

            In [5]: %config LoggingMagics.quiet = feeling_quiet

        r   )ÚConfigc                 S   s   g | ]}|j jd d�r|‘qS )T)Úconfig)r   Zclass_traits©Ú.0Úcr   r   r   Ú
<listcomp>]   s    
ÿz'ConfigMagics.config.<locals>.<listcomp>c                 S   s   | j jS r   ©r   Ú__name__)Úxr   r   r   Ú<lambda>_   s    z%ConfigMagics.config.<locals>.<lambda>)Úkeyc                 S   s   g | ]}|j j‘qS r   r   r   r   r   r   r   `   s    zAvailable objects for config:z   Nz^--Ú Ú.ú=z>Invalid config statement: %r, should be `Class.trait = value`.z!
Did you mean %s (note the case)?zcfg.)Ztraitlets.config.loaderr   ÚsortedÚsetr   r   ÚstripÚprintÚindexr   Zclass_get_helpÚreÚsubÚcompileÚ	MULTILINEÚregÚmatchÚsplitÚgetattrÚlowerr   ÚexecZuser_nsÚlocalsZupdate_configÚ	Exceptionr   )r   Úsr   r   Z
classnamesÚlineÚnamer   ÚclsÚhelpÚattrÚmsgÚllÚ	classnameÚcfgZconfigurableÚer   r   r   r   #   sP   6þ

þ€ÿýzConfigMagics.config)r   Ú
__module__Ú__qualname__r
   r   r   Ú__classcell__r   r   r   r   r      s    r   )Ú__doc__r%   ZIPython.core.errorr   ZIPython.core.magicr   r   r   Úloggingr   r'   r)   r   r   r   r   r   Ú<module>   s    
