
    si                        S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
JrJr  \(       a  SSKJr  SS	KJr  SS
K	JrJr   " S S\
5      rg)a  
Handles plugin configuration functionality including:
  - Managing plugin-specific settings
  - Processing configuration data from various sources
  - Dynamically adding and removing plugin settings
  - Providing a standardized interface for plugins to access their configurations
    )annotations)defaultdict)Mapping)TYPE_CHECKING   )ConfigurationEnvRawParameterParameterLoader)Path)Any)	ParameterRawParameterc                     ^  \ rS rSr% SrSrS\S'   SrS\S'   \ S     SS jj5       r	\SS j5       r
S	 r\SS
 j5       r\SS j5       rSS jrSU 4S jjrSrU =r$ )PluginConfig   a  
Class used to hold settings for conda plugins.

The object created by this class should only be accessed via
:class:`conda.base.context.Context.plugins`.

When this class is updated via the :func:`add_plugin_setting` function it adds new setting
properties which can be accessed later via the context object.

We currently call that function in
:meth:`conda.plugins.manager.CondaPluginManager.load_settings`.
because ``CondaPluginManager`` has access to all registered plugin settings via the settings
plugin hook.
 tuple[str, ...]parameter_namesparameter_names_and_aliasesc                    / U R                   QUP7U l         [        X#S9nUR                  U5      n[        XU5        U R	                  5         g)z3
Adds a setting to the :class:`PluginConfig` class
)aliasesN)r   r
   	_set_namesetattr _set_parameter_names_and_aliases)clsname	parameterr   loaders        4lib/python3.13/site-packages/conda/plugins/config.pyadd_plugin_settingPluginConfig.add_plugin_setting1   sN     ; 3 3:T: <%6" 	,,.    c                    U R                    H  n [        X5        M     [        5       U l         g! [         a     M0  f = f)zD
Removes all attached settings from the :class:`PluginConfig` class
N)r   delattrAttributeErrortuple)r   r   s     r   remove_all_plugin_settings'PluginConfig.remove_all_plugin_settings@   sA    
 ''D" ( $g " s   0
>>c                    0 U l         Xl        g )N_cache__data)selfdatas     r   __init__PluginConfig.__init__M   s    
r"   c                   [        [        5      nU R                  R                  5        H  u  p#UR	                  S5      =n(       aJ  UR                  S5      n[        U[        5      (       d  ME  UR                  5        H  u  pgXqU   U'   M     Mg  U[        R                  :X  d  M}  UR                  5        H7  u  pUR                  S5      (       d  M  UR                  S5      u  pXqU   U'   M9     M     U$ )z
This is used to move everything under the key "plugins" from the provided dictionary
to the top level of the returned dictionary. The returned dictionary is then passed
to :class:`PluginConfig`.
pluginsNplugins_)r   dictr,   itemsgetvalue
isinstancer   r	   source
startswithsplit)
r-   new_datar9   configplugin_dataplugin_data_value
param_name	raw_paramenv_var_s
             r   raw_dataPluginConfig.raw_dataQ   s     t$"jj..0NF$jj33{3$/$5$5d$;!!"3W==->-D-D-F)J3<V$Z0 .G ?111*0,,.&G))*55(/j(A7@(4 +9 1  r"   c                    SU R                   0$ )Nz'Additional settings provided by plugins)r   )r-   s    r   category_mapPluginConfig.category_mapl   s    94;O;OPPr"   c                    SSK Jn  UR                  R                  5       R	                  5        VVs0 s H  u  p#X#R
                  _M     snn$ s  snnf )Nr   )context)base.contextrJ   plugin_managerget_settingsr5   description)r-   rJ   r   settings       r   get_descriptionsPluginConfig.get_descriptionsp   sO    * ")!7!7!D!D!F!L!L!N
!N %%%!N
 	
 
s   Ac                <   > [         TU ]  U5      nSUS    3US'   U$ )z
Returns the description of a parameter.

We add to this method in order to change the "name" key that is returned to prepend "plugins."
to it.
zplugins.r   )superdescribe_parameter)r-   parameter_namerN   	__class__s      r   rT   PluginConfig.describe_parameterx   s1     g0@ (V)<(=>Fr"   r*   )r   )r   strr   r   r   r   )returnNone)rY   z#dict[Path, dict[str, RawParameter]])rY   zdict[str, tuple[str, ...]])rY   zdict[str, str])rY   zdict[str, Any])__name__
__module____qualname____firstlineno____doc__r   __annotations__r   classmethodr    r'   r/   propertyrD   rG   rP   rT   __static_attributes____classcell__)rV   s   @r   r   r      s     (*O_)355IK//#,/7F/ / 
& 
&  4 Q Q

 
r"   r   N)r_   
__future__r   collectionsr   collections.abcr   typingr   common.configurationr   r	   r
   pathlibr   r   r   r   r   r   r"   r   <module>rk      s>    # # #    >d= dr"   