AlkantarClanX12

Your IP : 18.191.154.132


Current Path : /proc/self/root/usr/lib/python3.6/site-packages/dnf/conf/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3.6/site-packages/dnf/conf/__pycache__/config.cpython-36.pyc

3

�ft`�O�@s<ddlmZddlmZddlmZddlmZmZddlm	Z	m
Z
ddlZddlZ
ddlZ
ddlZ
ddlZ
ddlZ
ddlZddlZddlZddlZddlZddlZejjjZejjjZejjjZejjj Z!ejjj"Z#ejjj$Z%ejjj&Z'ejjj(Z)ejjj*Z+ej,d�Z-Gdd	�d	e.�Z/Gd
d�de/�Z0Gdd
�d
e/�Z1dS)�)�absolute_import)�unicode_literals)�misc)�ucd�_)�
basestring�urlparseN�dnfcs~eZdZdZddd�Zdd�Z�fdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
efdd�Ze
fdd�Zdd�Zedd��Z�ZS)�
BaseConfigzlBase class for storing configuration definitions.

       Subclass when creating your own definitions.

    NcCs||jd<||_dS)N�_config)�__dict__�_section)�self�config�section�parser�r�/usr/lib/python3.6/config.py�__init__<s
zBaseConfig.__init__cCszd|jkrtdj|j|���t|j|�}|dkr4dSy|�j�}Wn tk
rb}zdSd}~XnXt|t	�rvt
|�S|S)Nrz!'{}' object has no attribute '{}')r�AttributeError�format�	__class__�getattrr�getValue�	Exception�
isinstance�strr)r�name�option�valueZexrrr�__getattr__@s

zBaseConfig.__getattr__cs:t|j|d�}|dkr(tt|�j||�S|j||t�dS)N)rr�superr
�__setattr__�
_set_value�PRIO_RUNTIME)rrrr)rrrr"NszBaseConfig.__setattr__c
Cstg}|jd|j�|jrjxN|jj�D]@}y|jj�}Wntk
rPd}YnX|jd|j|f�q&Wdj|�S)Nz[%s]�z%s: %s�
)	�appendr
r�optBinds�second�getValueString�RuntimeError�first�join)r�out�optBindrrrr�__str__Us
zBaseConfig.__str__cCst|j|d�}|dk	S)N)rr)rr�methodrrr�_has_optionaszBaseConfig._has_optioncCs$t|j|d�}|dkrdS|�j�S)N)rrr)rrr1rrr�
_get_valueeszBaseConfig._get_valuecCs$t|j|d�}|dkrdS|�j�S)N)rrZgetPriority)rrr1rrr�
_get_prioritykszBaseConfig._get_prioritycCst|j|d�}|dkr&td|d��|�}|dkr\y|j||�Wntk
rXYnXn�yrt|t�srt|t�r�|j|tjj	|��nDt|tjj
�s�t|tjj�r�t|t�r�|j|t
|��n|j||�WnHtk
�r}z*tjjtd�|t|�ft|�d��WYdd}~XnXdS)zSSet option's value if priority is equal or higher
           than current priority.NzOption "z" does not existszError parsing '%s': %s)�	raw_error)rrr�setr�list�tuple�libdnf�conf�VectorStringZ
OptionBoolZOptionChildBool�int�boolr+r	�
exceptions�ConfigErrorrr)rrr�priorityr1r�errrr#qs*
zBaseConfig._set_valuecCs�|j|�r�x�|j|�D]�}|j||�}|s4|dkr8d}t|j|�r�y|jj�j|�j||�Wq�tk
r�}z,t	j
td�t|�t|�t|�t
|��WYdd}~Xq�Xq|dkr�t||�r�t|||�qt	jtd�t|�t|�t|��qWdS)z+Set option values from an INI file section.�Noner%z,Invalid configuration value: %s=%s in %s; %sN�archz+Unknown configuration option: %s = %s in %s)�
hasSectionZoptionsZgetSubstitutedValue�hasattrrr(�at�	newStringr+�logger�errorrrr�setattr�debug)rrr�filenamer@rrrArrr�	_populate�s 

0zBaseConfig._populatecCshd|jg}|jrZxF|jj�D]8}y|jd|j|jj�f�Wqtk
rTYqXqWdj|�dS)z]Return a string representing the values of all the
           configuration options.
        z[%s]z%s = %sr&)	r
rr(r'r,r)r*r+r-)r�outputr/rrr�dump�s
zBaseConfig.dumpcCs�tjj�}|j|�|j|�sHx(|j�D]}tjjj||�|kr(|}q(Wx6|j�D]*\}}t|t	�rndj
|�}|j|||�qRW|j|d�dS)z�
        filename   - name of config file (.conf or .repo)
        section_id - id of modified section (e.g. main, fedora, updates)
        substitutions - instance of base.conf.substitutions
        modify     - dict of modified options
        � FN)
r9r:�ConfigParser�readrDZgetData�
substitute�itemsrr7r-ZsetValue�write)rLZ
section_id�
substitutionsZmodifyrZsectrrrrr�write_raw_configfile�s	




zBaseConfig.write_raw_configfile)NNN)�__name__�
__module__�__qualname__�__doc__rr r"r0r2r3r4r$r#�PRIO_DEFAULTrMrO�staticmethodrW�
__classcell__rr)rrr
5s
r
cs�eZdZdZd%�fdd�	Zdd�Zedd	��Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zedd��Zejdd��Zedd��Zejdd��Zedd��Zejd d��Zdefd!d"�Zed#d$��Z�ZS)&�MainConfz?Configuration option definitions for dnf.conf's [main] section.�mainNcstjj�}tt|�j|||�|jdtjj	gt
�|jdtjjgt
�tjjj
�|_tj�|_|jj�jt
tjj�tjj�r�tjj}d}nVytj�}}WnDttfk
r�}z$td�jt|��}tjj|��WYdd}~XnX|jj �jt
|�|jj!�jt
|�g|_"dS)NZ
pluginpathZpluginconfpathz/var/logzCould not set cachedir: {})#r9r:�
ConfigMainr!r_rr#r	�constZ
PLUGINPATHr\ZPLUGINCONFPATHrVZ
Substitutions�hawkeyZdetect_archrCrZsystem_cachedirr6ZSYSTEM_CACHEDIR�utilZ	am_i_rootrZgetCacheDir�IOError�OSErrorrrrr>�Error�cachedir�logdir�	tempfiles)rrrrrhrirA�msg)rrrr�s$


zMainConf.__init__cCsx|jD]}tj|�qWdS)N)rj�os�unlink)r�	file_namerrr�__del__�szMainConf.__del__cCsLd}x$|jd�D]}tjj|�r|}PqW|sH|jd�d}tjj|�|S)zReturns the value of reposdirNZreposdirr)r3rl�path�existsr	rdZ
ensure_dir)rZ	myrepodirZrdirrrr�get_reposdir�szMainConf.get_reposdirc	Cs�|j|�}|j|�}t|t�r�tj|�}|ddkrF|j||j|�n�tjj	�}t
jdd�\}}|jj
|�zdy|jd||�Wn>tk
r�}z"tjjtd�j|t|����WYdd}~XnX|j|||�Wdtj|�XdS)	z�
        In case the option value is a remote URL, download it to the temporary location
        and use this temporary file instead.
        r�filer%zdnf-downloaded-config-)�prefixNz9Configuration file URL "{}" could not be downloaded:
  {})rsr%)r4r3rrrr#rpr9ZrepoZ
Downloader�tempfileZmkstemprjr'ZdownloadURLr+r	r>r?rrrrl�close)	r�optname�prio�val�locationZ
downloaderZtemp_fdZ	temp_pathrArrr�_check_remote_file�s"




 zMainConf._check_remote_filecs��jd���dkr�S�j|�}|tkr,�S�j|�}t|t�s�t�fdd�|D��r��j|tjj	�fdd�|D��|��Sn4t
jjt
jj
�|jd���r��j|�j|�|��SdS)z�
        Return root used as prefix for option (installroot or "/"). When specified from commandline
        it returns value from conf.installroot
        �installroot�/c3s*|]"}tjjtjj�|jd���VqdS)r}N)rlrprqr-�lstrip)�.0�p)r|rr�	<genexpr>*sz6MainConf._search_inside_installroot.<locals>.<genexpr>csg|]}�j|��qSr)�_prepend_installroot_path)rr�)rrr�
<listcomp>-sz7MainConf._search_inside_installroot.<locals>.<listcomp>)r3r4�PRIO_COMMANDLINErr�anyr#r9r:r;rlrprqr-r~r�)rrwrxryr)r|rr�_search_inside_installroots$



z#MainConf._search_inside_installrootcCs,|j|�}|j|j|��}|j|||�dS)N)r4r�r3r#)rrwrx�new_pathrrr�prepend_installroot6s
zMainConf.prepend_installrootcCs,tjj|jd�|jd��}tjjj||j	�S)Nr|r})
rlrpr-r3r~r9r:rQrSrV)rrpZ	root_pathrrrr�<sz"MainConf._prepend_installroot_pathcCs`ddddddddd	d
dddd
dddddddddddddg}�x|D�]}t||d�}|dk	ob|gkrB|j|��r$d}|jr�y|jj�j|�j�}Wntk
r�YnX|�rtjj	}||j
|�kr�|j
|�}xR|D]6}|r�|j||j|�|g|�q�|j|gtjj	�q�Wn|j||tjj	�qBt
||��r>t|||�qBtjtd�t|�t|��qBWt|dd�dk�r�|jddtjj	�t
|d��r\x�|jj�D]�\}}x�|D]�}	t
|j|��r"y|jj�j|�jt	|	�WnJtk
�r}
z,tjjtd �||	t|
�ft|
�d!��WYdd}
~
XnXn.t
||��r<t|||	�ntd"�}tj||��q�W�q�WdS)#z%Configure parts of CLI from the opts Zplugins�version�config_file_path�
debuglevelZ
errorlevelr|ZbestZ	assumeyesZassumenoZclean_requirements_on_remove�gpgcheckZshowdupesfromreposZ
ip_resolveZrpmverbosityZdisable_excludesZcolorZdownloadonly�exclude�excludepkgs�skip_brokenZtsflagsrC�basearchZ
ignorearchZ	cacheonlyZcommentNFz%Unknown configuration option: %s = %sZlocalpkg_gpgcheck�main_setoptsz4Error parsing --setopt with key '%s', value '%s': %s)r5z1Main config did not have a %s attr. before setopt)rr2rr(rFZgetAddValuer+r	r:r�r4r#r3rErJrH�warningrrr�rTrGr>r?r)r�optsZconfig_argsrrZappendValueZadd_priority�item�valuesryrArkrrr�_configure_from_options@s\




.z MainConf._configure_from_optionscCsPd}|dk	rL|gkrL|j|�r2|j||tjj�ntjtd�t|�t|��dS)Nr�z%Unknown configuration option: %s = %s)	r2r#r	r:r�rHr�rr)rZpkgsrrrr�exclude_pkgss

zMainConf.exclude_pkgscCs(|jd�}|r$|jd||jd��dS)z Adjust conf options interactionsr��strictN)r3r#r4)rZskip_broken_valrrr�_adjust_conf_options�s
zMainConf._adjust_conf_optionscCs|jjd�S)N�
releasever)rV�get)rrrrr��szMainConf.releasevercCs,|dkr|jjdd�dSt|�|jd<dS)Nr�)rV�popr)rryrrrr��scCs|jjd�S)NrC)rVr�)rrrrrC�sz
MainConf.archcCsb|dkr|jjdd�dS|tjjj�krFtd�}tjj|j	d|���||jd<tjj
|�|_
dS)NrCzIncorrect or unknown "{}": {})rVr�r	�rpm�
_BASEARCH_MAP�keysrr>rgrr�)rryrkrrrrC�s
cCs|jjd�S)Nr�)rVr�)rrrrr��szMainConf.basearchcCsT|dkr|jjdd�dS|tjjj�krFtd�}tjj|j	d|���||jd<dS)Nr�zIncorrect or unknown "{}": {})
rVr�r	r�r�r�rr>rgr)rryrkrrrr��scCs�|dkr|jd�}tjj�}y|j|�Wndtk
rd}ztjjt	d�||f��WYdd}~Xn,t
k
r�}ztj|�WYdd}~XnX|j
||j||�|jd||�dS)Nr�zParsing file "%s" failed: %s)r3r9r:rQrRr+r	r>r?rrerHr�rMr
r#)rrLr@rrArrrrR�s

(z
MainConf.readcCs|jd�tjjkS)Nr�)r3r	rbZ
VERBOSE_LEVEL)rrrr�verbose�szMainConf.verbose)r`N)rXrYrZr[rro�propertyrrr{r�r�r�r�r�r�r��setterrCr�r\rRr�r^rr)rrr_�s&?
r_cs*eZdZdZd�fdd�	Zdd�Z�ZS)�RepoConfz4Option definitions for repository INI file sections.NcsP|r
|jntjj�}tt|�jtjj|�||�||_|rL|jj	�j
t|�dS)N)rr9r:rar!r�rZ
ConfigRepoZ_mainConfigRefHolderrr6r\)r�parentrrZ
mainConfig)rrrr�s
zRepoConf.__init__cCst|dd�dkr0xd	D]}|j|dtjj�qWt|di�}x�|j�D]�\}}tj|j|�s^qFx�|j�D]�\}}x�|D]�}t|j	|�r�y|j	j
�j|�jt|�WnLt
k
r�}	z0tjjtd�|j||t|	�ft|	�d��WYdd}	~	XnXqvtd�}
tj|
|j|�qvWqhWqFWdS)
zConfigure repos from the opts. r�NF�
repo_gpgcheck�repo_setoptsz7Error parsing --setopt with key '%s.%s', value '%s': %s)r5z-Repo %s did not have a %s attr. before setopt)r�r�)rr#r	r:r�rT�fnmatchr
rErr(rFrGr+r>r?rrrHr�)rr�rwr�ZrepoidZsetoptsrr�ryrArkrrrr��s$

2z RepoConf._configure_from_options)NN)rXrYrZr[rr�r^rr)rrr��s	r�)2Z
__future__rrZdnf.yumrZdnf.i18nrrZ
dnf.pycomprrr�Zdnf.conf.substitutionsr	Z	dnf.constZdnf.exceptionsZdnf.utilrcZloggingrlZlibdnf.confr9Zlibdnf.reporur:ZOptionZPriority_EMPTYZ
PRIO_EMPTYZPriority_DEFAULTr\ZPriority_MAINCONFIGZPRIO_MAINCONFIGZPriority_AUTOMATICCONFIGZPRIO_AUTOMATICCONFIGZPriority_REPOCONFIGZPRIO_REPOCONFIGZPriority_PLUGINDEFAULTZPRIO_PLUGINDEFAULTZPriority_PLUGINCONFIGZPRIO_PLUGINCONFIGZPriority_COMMANDLINEr�ZPriority_RUNTIMEr$Z	getLoggerrH�objectr
r_r�rrrr�<module>s@