o
    ˷e.                     @   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__ Q/var/www/ideatree/venv/lib/python3.10/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rd}| }|D ]}|| kr|d|  } nq{t|| | }td| | jjt  |D ]}z|| W q ty } z
t| W Y d}~qd}~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 IPCompleter
            IPCompleter(Completer) options
            ----------------------------
            IPCompleter.backslash_combining_completions=<Bool>
                Enable unicode completions, e.g. \alpha<tab> . Includes completion of latex
                commands, unicode names, and expanding unicode characters back to latex
                commands.
                Current: True
            IPCompleter.debug=<Bool>
                Enable debug for the Completer. Mostly print extra information for
                experimental jedi integration.
                Current: False
            IPCompleter.greedy=<Bool>
                Activate greedy completion
                        PENDING DEPRECATION. this is now mostly taken care of with Jedi.
                        This will enable completion on elements of lists, results of function calls, etc.,
                        but can be unsafe because the code is actually evaluated on TAB.
                Current: False
            IPCompleter.jedi_compute_type_timeout=<Int>
                Experimental: restrict time (in milliseconds) during which Jedi can compute types.
                        Set to 0 to stop computing types. Non-zero value lower than 100ms may hurt
                        performance by preventing jedi to build its cache.
                Current: 400
            IPCompleter.limit_to__all__=<Bool>
                DEPRECATED as of version 5.0.
                Instruct the completer to use __all__ for the completion
                Specifically, when completing on ``object.<tab>``.
                When True: only those names in obj.__all__ will be included.
                When False [default]: the __all__ attribute is ignored
                Current: False
            IPCompleter.merge_completions=<Bool>
                Whether to merge completion results into a single list
                        If False, only the completion results from the first non-empty
                        completer will be returned.
                Current: True
            IPCompleter.omit__names=<Enum>
                Instruct the completer to omit private method names
                        Specifically, when completing on ``object.<tab>``.
                        When 2 [default]: all names that start with '_' will be excluded.
                        When 1: all 'magic' names (``__foo__``) will be excluded.
                        When 0: nothing will be excluded.
                Choices: any of [0, 1, 2]
                Current: 2
            IPCompleter.profile_completions=<Bool>
                If True, emit profiling data for completion subsystem using cProfile.
                Current: False
            IPCompleter.profiler_output_dir=<Unicode>
                Template for path at which to output profile data for completions.
                Current: '.completion_profiles'
            IPCompleter.use_jedi=<Bool>
                Experimental: Use Jedi to generate autocompletions. Default to True if jedi
                is installed.
                Current: True

        but the real use is in setting values::

            In [3]: %config IPCompleter.greedy = True

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

            In [4]: feeling_greedy=False

            In [5]: %config IPCompleter.greedy = feeling_greedy

        r   )Configc                 S   s   g | ]}|j jd dr|qS )T)config)r   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.)traitlets.config.loaderr   sortedsetr   r   stripprintindexr   class_get_helpresubcompile	MULTILINEregmatchsplitgetattrlowerr   execuser_nslocalsupdate_config	Exceptionr   )r   sr   r   
classnameslinenamer   clshelpattrmsgll	classnamecfgconfigurableer   r   r   r   #   sP   e

zConfigMagics.config)r   
__module____qualname__r
   r   r   __classcell__r   r   r   r   r      s    r   )__doc__r(   IPython.core.errorr   IPython.core.magicr   r   r   loggingr   r*   r,   r   r   r   r   r   <module>   s    
