
    Ioj@                         S SK r S SKrS SKJr  SSKJr  SSKJr  S SKrS SKJ	r	  S SK
Jr  S SKJr  / S	QrSS
 jrSS jr " S S\5      r " S S\5      rg)    N)ClassVar   )Command)_cfg_read_utf8_with_fallback)log)DistutilsOptionError)convert_path)config_fileedit_configoption_basesetoptc                 x   U S:X  a  gU S:X  aK  [         R                  R                  [         R                  R                  [        R
                  5      S5      $ U S:X  aQ  [         R                  S:H  =(       a    S=(       d    Sn[         R                  R                  [        S	U S
35      5      $ [        SU 5      e)zyGet the filename of the distutils, local, global, or per-user config

`kind` must be one of "local", "global", or "user"
localz	setup.cfgglobalzdistutils.cfguserposix. z~/zpydistutils.cfgz7config_file() type must be 'local', 'global', or 'user')
ospathjoindirname	distutils__file__name
expanduserr	   
ValueError)kinddots     S/mnt/workspace/venv-train/lib/python3.13/site-packages/setuptools/command/setopt.pyr
   r
      s    
 wxww||BGGOOI,>,>?QQv~gg (S.Bww!!,C5/H"IJJ
NPT
UU    c           	         [         R                  " SU 5        [        R                  " 5       nS Ul        [        X 5        UR                  5        GH"  u  p4Uc*  [         R                  " SX05        UR                  U5        M3  UR                  U5      (       d(  [         R                  " SX05        UR                  U5        UR                  5        H  u  pVUck  [         R                  " SX5U 5        UR                  X55        UR                  U5      (       d*  [         R                  " SX05        UR                  U5        Mq  Ms  [         R                  " SX5X`5        UR                  X5U5        M     GM%     [         R                  " S	U 5        [        U S
SS9 nUR                  U5        SSS5        g! , (       d  f       g= f)aE  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                     U $ N )	optionstrs    r    <lambda>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optssectionr5   optionvaluefs           r    r   r      sZ    II-x8'')D2D 0$NN,?HH4gH(##G,,		97M  )!(=II6R&&w7<<00A7 ++G4	 1 II3We HHWe4 "1 -. HH\8$	hg	.!

1 
/	.	.s   F44
Gc                       \ rS rSr% Sr/ SQr\\\\	\	\	4      \\\	\	S-  \	4      -     \
S'   SS/r\\\	      \
S'   S	 rSS
 jrSrg)r   H   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)Nuser_optionsrB   rD   boolean_optionsc                 .    S U l         S U l        S U l        g r$   )global_configuser_configr9   selfs    r    initialize_optionsoption_base.initialize_optionsX   s    !r!   c                    / nU R                   (       a  UR                  [        S5      5        U R                  (       a  UR                  [        S5      5        U R                  b  UR                  U R                  5        U(       d  UR                  [        S5      5        [        U5      S:  a  [        SU5      eUu  U l        g )Nr   r   r      z/Must specify only one configuration file option)rI   appendr
   rJ   r9   lenr   )rL   	filenamess     r    finalize_optionsoption_base.finalize_options]   s    	[23[01==$T]]+[12y>A&A9  %r!   )r9   rI   rJ   returnN)__name__
__module____qualname____firstlineno____doc__rF   r   listtuplestr__annotations__rG   rM   rT   __static_attributes__r%   r!   r    r   r   H   sq    F	 (U3S=!"T%S4Z0D*E%FF  	,OXd3i( 

%r!   r   c                   x    \ rS rSrSrSr/ SQ\R                  -   r\R                  S/-   rS r	SS jr
SS	 jrS
rg)r   n   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 valuerg   c                 f    [         R                  U 5        S U l        S U l        S U l        S U l        g r$   )r   rM   commandr=   	set_valuerg   rK   s    r    rM   setopt.initialize_options|   s,    &&t,r!   Nc                     [         R                  U 5        U R                  b  U R                  c  [	        S5      eU R
                  c  U R                  (       d  [	        S5      eg g )Nz%Must specify --command *and* --optionz$Must specify --set-value or --remove)r   rT   rj   r=   r   rk   rg   rK   s    r    rT   setopt.finalize_options   sS    $$T*<<4;;#6&'NOO>>!$++&'MNN +6!r!   c                     [        U R                  U R                  U R                  R	                  SS5      U R
                  005        g )N-_)r   r9   rj   r=   replacerk   rK   s    r    run
setopt.run   s7    MM\\DKK//S94>>JK	
r!   )rj   r=   rg   rk   rV   )rX   rY   rZ   r[   r\   descriptionr   rF   rG   rM   rT   rs   ra   r%   r!   r    r   r   n   sE    -EK
 	  !L "11XJ>OO
r!   r   )r   rV   )r,   r   typingr   r   r   unicode_utilsr   r   r   distutils.errorsr   distutils.utilr	   __all__r
   r   r   r   r%   r!   r    <module>r{      sJ     	   8   1 '
AV&R#%' #%L 
[  
r!   