
    ,h                         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y)    N   )Command)_cfg_read_utf8_with_fallback)log)DistutilsOptionError)convert_path)config_fileedit_configoption_basesetoptc                 ^   | dk(  ry| dk(  rKt         j                  j                  t         j                  j                  t        j
                        d      S | dk(  rGt         j                  dk(  xr dxs d}t         j                  j                  t        d	| d
            S t        d|       )zGet 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     [/var/www/html/Resume-Scraper/venv/lib/python3.12/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           	      l   t        j                  d|        t        j                         }d |_        t        ||        |j                         D ]  \  }}|)t        j                  d||        |j                  |       2|j                  |      s(t        j                  d||        |j                  |       |j                         D ]  \  }}|et        j                  d|||        |j                  ||       |j                  |      rDt        j                  d||        |j                  |       mt        j                  d||||        |j                  |||         t        j                  d	|        |s)t        | d
d      5 }|j                  |       ddd       yy# 1 sw Y   yxY w)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
      s    II-x8'')D2D x0$NN, 5?HH4gxH(##G,		97HM  )!( 5=II6R&&w7<<0A7H ++G4II3WfeX HHWfe455. HH\8$(C'2 	aJJqM	 	 	 	s   F**F3c                   ,    e Zd ZdZg dZddgZd Zd Zy)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                 .    d | _         d | _        d | _        y r#   )global_configuser_configr7   selfs    r   initialize_optionszoption_base.initialize_optionsV   s    !r    c                 l   g }| j                   r|j                  t        d             | j                  r|j                  t        d             | j                  |j                  | j                         |s|j                  t        d             t        |      dkD  rt        d|      |\  | _        y )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    	[23[01==$T]]+[12y>A&A9  %r    N)__name__
__module____qualname____doc__user_optionsboolean_optionsrI   rO   r$   r    r   r   r   H   s%    FL 	O

%r    r   c                   l    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
y)
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                 f    t         j                  |        d | _        d | _        d | _        d | _        y r#   )r   rI   commandr<   	set_valuerZ   rG   s    r   rI   zsetopt.initialize_optionsz   s,    &&t,r    Nc                     t         j                  |        | j                  | j                  t	        d      | j
                  | j                  st	        d      y y )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   sS    $$T*<<4;;#6&'NOO>>!$++&'MNN +6!r    c                     t        | j                  | j                  | j                  j	                  dd      | j
                  ii| j                         y )N-_)r
   r7   r]   r<   replacer^   r9   rG   s    r   runz
setopt.run   s>    MM\\DKK//S94>>JKLL	
r    )returnN)rP   rQ   rR   rS   descriptionr   rT   rU   rI   rO   rd   r$   r    r   r   r   l   sE    -EK
 	  !L "11XJ>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      sG     	  8   1 '
AV'T!%' !%H!
[ !
r    