
    ϶vg                         d dl Z d dlZddlmZ ddlmZ d dlZd dlmZ d dlm	Z	 d dl
mZ g dZdd
ZddZ G d de          Z G d de          ZdS )    N   )Command)_cfg_read_utf8_with_fallback)log)DistutilsOptionError)convert_path)config_fileedit_configoption_basesetoptlocalc                 ^   | dk    rdS | dk    rGt           j                            t           j                            t          j                  d          S | dk    rCt           j        dk    rdpd}t           j                            t          d	|z                      S t          d
|           )zGet the filename of the distutils, local, global, or per-user config

    `kind` must be one of "local", "global", or "user"
    r   z	setup.cfgglobalzdistutils.cfguserposix. z~/%spydistutils.cfgz7config_file() type must be 'local', 'global', or 'user')
ospathjoindirname	distutils__file__name
expanduserr   
ValueError)kinddots     V/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/setuptools/command/setopt.pyr	   r	      s    
 w{xw||BGOOI,>??QQQv~~g (S.Bw!!,/Ds/J"K"KLLL
NPT
U
UU    Fc           	         t          j        d|            t          j                    }d |_        t          ||            |                                D ]-\  }}|,t          j        d||            |                    |           4|	                    |          s+t          j        d||            |
                    |           |                                D ]\  }}|nt          j        d|||            |                    ||           |                    |          s+t          j        d||            |                    |           ut          j        d||||            |                    |||           /t          j        d	|            |sBt          | d
d          5 }|                    |           ddd           dS # 1 swxY w Y   dS dS )aY  Edit a configuration file to include `settings`

    `settings` is a dictionary of dictionaries or ``None`` values, keyed by
    command/section name.  A ``None`` value means to delete the entire section,
    while a dictionary lists settings to be changed or deleted in that section.
    A setting of ``None`` means to delete that setting.
    zReading configuration from %sc                     | S N )	optionstrs    r   <lambda>zedit_config.<locals>.<lambda>(   s     r    NzDeleting section [%s] from %szAdding new section [%s] to %szDeleting %s.%s from %sz#Deleting empty [%s] section from %szSetting %s.%s to %r in %sz
Writing %swzutf-8)encoding)r   debugconfigparserRawConfigParseroptionxformr   itemsinforemove_sectionhas_sectionadd_sectionremove_optionoptionssetopenwrite)	filenamesettingsdry_runoptssectionr3   optionvaluefs	            r   r
   r
      sK    I-x888'))D22D x000$NN,, 5 5?H4gxHHH((((##G,, *	97HMMM  )))!( 5 5=I6RRR&&w777<<00 5A7H   ++G444I3WfeX   HHWfe44445 H\8$$$ (C'222 	aJJqMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 s   -GGGc                   .    e Zd ZdZg dZddgZd Zd ZdS )r   z<Abstract base class for commands that mess with config files))global-configgz0save options to the site-wide distutils.cfg file)user-configuz7save options to the current user's pydistutils.cfg file)z	filename=r>   z-configuration file to use (default=setup.cfg)r@   rB   c                 0    d | _         d | _        d | _        d S r#   )global_configuser_configr7   selfs    r   initialize_optionszoption_base.initialize_optionsV   s    !r    c                    g }| j         r"|                    t          d                     | j        r"|                    t          d                     | j        |                    | j                   |s"|                    t          d                     t          |          dk    rt          d|          |\  | _        d S )Nr   r   r      z/Must specify only one configuration file option)rE   appendr	   rF   r7   lenr   )rH   	filenamess     r   finalize_optionszoption_base.finalize_options[   s    	 	4[22333 	2[00111=$T]+++ 	3[11222y>>A&A9   %r    N)__name__
__module____qualname____doc__user_optionsboolean_optionsrI   rO   r$   r    r   r   r   H   sX        FF  L 	O
  
% % % % %r    r   c                   Z    e Zd ZdZdZg dej        z   Zej        dgz   Zd Zd
dZ	d
d	Z
dS )r   z#Save command-line options to a filez1set an option in setup.cfg or another config file))zcommand=czcommand to set an option for)zoption=ozoption to set)z
set-value=szvalue of the option)removerzremove (unset) the valuerZ   c                 r    t                               |            d | _        d | _        d | _        d | _        d S r#   )r   rI   commandr<   	set_valuerZ   rG   s    r   rI   zsetopt.initialize_optionsz   s6    &&t,,,r    returnNc                     t                               |            | j        | j        t	          d          | j        | j        st	          d          d S d S )Nz%Must specify --command *and* --optionz$Must specify --set-value or --remove)r   rO   r]   r<   r   r^   rZ   rG   s    r   rO   zsetopt.finalize_options   s`    $$T***<4;#6&'NOOO>!$+!&'MNNN "!!!r    c                     t          | j        | j        | j                            dd          | j        ii| j                   d S )N-_)r
   r7   r]   r<   replacer^   r9   rG   s    r   runz
setopt.run   sK    M\DK//S994>JKL	
 	
 	
 	
 	
r    )r_   N)rP   rQ   rR   rS   descriptionr   rT   rU   rI   rO   re   r$   r    r   r   r   l   s        --EK  
 	 !L "1XJ>O  O O O O
 
 
 
 
 
r    r   )r   )F)r*   r   r   r   unicode_utilsr   r   r   distutils.errorsr   distutils.utilr   __all__r	   r
   r   r   r$   r    r   <module>rk      s       				       8 8 8 8 8 8           1 1 1 1 1 1 ' ' ' ' ' '
A
A
AV V V V' ' ' 'T!% !% !% !% !%' !% !% !%H!
 !
 !
 !
 !
[ !
 !
 !
 !
 !
r    