Your IP : 3.144.9.183


Current Path : /usr/lib/python3.6/site-packages/dnf/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dnf/__pycache__/comps.cpython-36.pyc

3

��f�`�@s�ddlmZddlmZddlmZddlZddlmZddlm	Z	m
Z
ddlmZddlZ
ddlZ
ddlZddlZddlZddlZddlZddlZddlZddlZddlZejd�ZejjZejjZejjZ ejj!Z"eeBe Be"BZ#d	d
�Z$dd�Z%d
d�Z&dd�Z'd*dd�Z(Gdd�de)�Z*Gdd�de)�Z+Gdd�de)�Z,Gdd�de,�Z-Gdd�de,�Z.Gdd�de,�Z/Gd d!�d!e,�Z0Gd"d#�d#e)�Z1Gd$d%�d%e)�Z2Gd&d'�d'e)�Z3Gd(d)�d)e)�Z4dS)+�)�absolute_import)�print_function)�unicode_literalsN)�
CompsError)�_�ucd)�reduce�dnfcCs"|j|j|jf}ttjtt|��S)N)�
categories�groups�environmentsr�operator�__add__�map�len)�comps�collections�r�/usr/lib/python3.6/comps.py�_internal_comps_length6srcCs|dkrdStjj|�S)N)r	�util�first)�seqrrr�_first_if_iterable;srcs�tjj����fdd�|D�}|r&|S|r>tjtj���j}ntjtj��tjd�j}t	�}x`|D]X}||j
�r||j|�qb|jdk	r�||j�r�|j|�qb|j
dk	rb||j
�rb|j|�qbW|S)z;Return items from sqn matching either exactly or glob-wise.cs$h|]}|j�ks|j�kr|�qSr)�name�id)�.0�g)�patternrr�	<setcomp>Esz_by_pattern.<locals>.<setcomp>)�flagsN)r	Zi18nr�re�compile�fnmatch�	translate�match�I�setr�addr�ui_name)r�case_sensitiveZsqn�exactr%�retrr)rr�_by_patternAs 

r-cCs|jdkrtjS|jS)N)Z
display_order�sys�maxsize)�grouprrr�_fn_display_orderZsr1TcCs||||||�S)aF
    Installs a group or an environment identified by grp_or_env_id.
    This method is preserved for API compatibility. It used to catch an
    exception thrown when a gorup or env was already installed, which is no
    longer thrown.
    `install_fnc` has to be Solver._group_install or
    Solver._environment_install.
    r)Zinstall_fncZ
grp_or_env_id�types�exclude�strict�exclude_groupsrrr�install_or_skip^s
r6c@s,eZdZdZdd�Zedd��Zdd�ZdS)	�_Langsz6Get all usable abbreviations for the current language.cCsd|_d|_dS)N)�last_locale�cache)�selfrrr�__init__osz_Langs.__init__cCs"tjtj�}|dkrdSdj|�S)N�C�.)NN)�localeZ	getlocale�LC_MESSAGES�join)Zlclrrr�_dotted_locale_strssz_Langs._dotted_locale_strcCsz|j�}|j|kr|jSg|_|g}|dkr6|jd�x6|D].}x(tj|�D]}||jkrL|jj|�qLWq<W||_|jS)Nr<)rAr8r9�append�gettextZ_expand_lang)r:Zcurrent_localeZlocales�lZnlangrrr�getzs



z
_Langs.getN)�__name__�
__module__�__qualname__�__doc__r;�staticmethodrArErrrrr7ksr7c@s<eZdZdZdZdZdZdd�Zdd�Zdd�Z	d	d
�Z
dS)�
CompsQuery��cCs||_||_||_||_dS)N)r�history�kinds�status)r:rrNrOrPrrrr;�szCompsQuery.__init__cCs`t�}|j|j@r&|jdd�|D��|j|j@r\x(|D] }|j�}|sJq8|j|j��q8W|S)NcSsh|]
}|j�qSr)r)r�irrrr�sz)CompsQuery._get_groups.<locals>.<setcomp>)r'rP�	AVAILABLE�update�	INSTALLEDZgetCompsGroupItemr(�
getGroupId)r:�	available�	installed�resultrQr0rrr�_get_groups�s
zCompsQuery._get_groupscCs`t�}|j|j@r&|jdd�|D��|j|j@r\x(|D] }|j�}|sJq8|j|j��q8W|S)NcSsh|]
}|j�qSr)r)rrQrrrr�sz'CompsQuery._get_envs.<locals>.<setcomp>)r'rPrRrSrTZgetCompsEnvironmentItemr(ZgetEnvironmentId)r:rVrWrXrQ�envrrr�	_get_envs�s
zCompsQuery._get_envsc	Gstjj�}g|_g|_x�|D]�}g}}|j|j@rf|jj|�}|j	j
j|�}|j||�}|jj
|�|j|j@r�|jj|�}|j	jj|�}|j||�}|jj
|�|o�|r|j|jkr�td�t|�}n.|j|jkr�td�t|�}ntd�t|�}t|��qW|S)Nz&Module or Group '%s' is not installed.z&Module or Group '%s' is not available.z$Module or Group '%s' does not exist.)r	rZBunchrrrO�ENVIRONMENTSr�environments_by_patternrNrZZsearch_by_patternr[�extend�GROUPS�groups_by_patternr0rYrPrTrrrRr)	r:Zpatterns�resZpat�envs�grpsrVrW�msgrrrrE�s.

zCompsQuery.getN)rFrGrHrRrTr\r_r;rYr[rErrrrrK�srKc@s<eZdZdd�Zdd�Zdd�Zedd��Zed	d
��ZdS)�	ForwardercCs||_||_dS)N)�_i�_langs)r:�iobj�langsrrrr;�szForwarder.__init__cCst|j|�S)N)�getattrrf)r:rrrr�__getattr__�szForwarder.__getattr__cCs.x(|jj�D]}|j|�}|dk	r|SqW|S)N)rgrE)r:�defaultZdctrD�trrr�_ui_text�s

zForwarder._ui_textcCs|j|j|j�S)N)rnZdescZdesc_by_lang)r:rrr�ui_description�szForwarder.ui_descriptioncCs|j|j|j�S)N)rnrZname_by_lang)r:rrrr)�szForwarder.ui_nameN)	rFrGrHr;rkrn�propertyror)rrrrre�s
recs8eZdZ�fdd�Zdd�Zdd�Zedd��Z�ZS)	�Categorycstt|�j||�||_dS)N)�superrqr;�_group_factory)r:rhri�
group_factory)�	__class__rrr;�szCategory.__init__cCs0|j|j�}|dkr,d}t||j|jf��|S)Nz no group '%s' from category '%s')rsr�
ValueErrorr)r:�grp_id�grprdrrr�_build_group�s
zCategory._build_groupccs x|jD]}|j|�VqWdS)N)�	group_idsry)r:rwrrr�groups_iter�szCategory.groups_itercCst|j��S)N)�listr{)r:rrrr�szCategory.groups)	rFrGrHr;ryr{rpr�
__classcell__rr)rurrq�srqcsLeZdZ�fdd�Zdd�Zdd�Zdd�Zed	d
��Zedd��Z	�Z
S)
�Environmentcstt|�j||�||_dS)N)rrr~r;rs)r:rhrirt)rurrr;�szEnvironment.__init__cCs0|j|j�}|dkr,d}t||j|jf��|S)Nz#no group '%s' from environment '%s')rsrrvr)r:rwrxrdrrrrys
zEnvironment._build_groupcCsXg}xN|D]F}y|j|j|��Wq
tk
rN}ztj|�WYdd}~Xq
Xq
W|S)N)rBryrv�logger�error)r:ZidsrZgi�errr�
_build_groupss
 zEnvironment._build_groupsccs\xVtj|j|j�D]B}y|j|�VWqtk
rR}ztj|�WYdd}~XqXqWdS)N)�	itertools�chainrz�
option_idsryrvrr�)r:rwr�rrrr{s
zEnvironment.groups_itercCs|j|j�S)N)r�rz)r:rrr�mandatory_groupsszEnvironment.mandatory_groupscCs|j|j�S)N)r�r�)r:rrr�optional_groupsszEnvironment.optional_groups)rFrGrHr;ryr�r{rpr�r�r}rr)rurr~�s
r~csheZdZ�fdd�Zdd�Zedd��Zedd��Zd	d
�Zedd��Z	ed
d��Z
edd��Z�ZS)�Groupcs$tt|�j||�||_|j|_dS)N)rrr�r;�_pkg_factoryrlZselected)r:rhriZpkg_factory)rurrr;"szGroup.__init__cs�fdd�|jD�S)Ncsg|]}|j�kr|�qSr)�type)r�pkg)�type_rr�
<listcomp>(sz+Group._packages_of_type.<locals>.<listcomp>)�packages)r:r�r)r�r�_packages_of_type'szGroup._packages_of_typecCs|jtj�S)N)r��libcomps�PACKAGE_TYPE_CONDITIONAL)r:rrr�conditional_packages*szGroup.conditional_packagescCs|jtj�S)N)r�r��PACKAGE_TYPE_DEFAULT)r:rrr�default_packages.szGroup.default_packagescCst|j|j�S)N)rr�r�)r:rrr�
packages_iter2szGroup.packages_itercCs|jtj�S)N)r�r��PACKAGE_TYPE_MANDATORY)r:rrr�mandatory_packages6szGroup.mandatory_packagescCs|jtj�S)N)r�r��PACKAGE_TYPE_OPTIONAL)r:rrr�optional_packages:szGroup.optional_packagescCs|jjS)N)rfZuservisible)r:rrr�visible>sz
Group.visible)
rFrGrHr;r�rpr�r�r�r�r�r�r}rr)rurr� sr�c@sLeZdZdZejeejeej	e
ejeiZ
dd�Zedd��Zedd��ZdS)	�Packagez#Represents comps package data. :apicCs
||_dS)N)rf)r:�ipkgrrrr;LszPackage.__init__cCs|jjS)N)rfr)r:rrrrOszPackage.namecCs|j|jS)N)�_OPT_MAPr�)r:rrr�option_typeTszPackage.option_typeN)rFrGrHrIr�r��CONDITIONALr��DEFAULTr��	MANDATORYr��OPTIONALr�r;rprr�rrrrr�Bs
r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
dd��Zd-dd�Zd.dd�Z
dd�Ze
dd��Zdd�Zd/dd�Zd0dd�Zd d!�Ze
d"d#��Zd$d%�Zd1d&d'�Zd2d(d)�Zd*d+�Zd,S)3�CompscCstj�|_t�|_dS)N)r�r�rfr7rg)r:rrrr;\s
zComps.__init__cCs
t|j�S)N)rrf)r:rrr�__len__`sz
Comps.__len__cCst||j|j�S)N)rqrg�_group_by_id)r:Z	icategoryrrr�_build_categorycszComps._build_categorycCst||j|j�S)N)r~rgr�)r:Zienvironmentrrr�_build_environmentfszComps._build_environmentcCst||j|j�S)N)r�rg�_build_package)r:ZigrouprrrryiszComps._build_groupcCst|�S)N)r�)r:r�rrrr�lszComps._build_packagecCsVtj�}y|j|�Wn,tjk
rB|j�}tdj|���YnX|j|7_dS)N� )r�r�Z	fromxml_fZParserErrorZget_last_errorsrr@rf)r:�fnr�errorsrrr�_add_from_xml_filenameoszComps._add_from_xml_filenamecCst|j��S)N)r|�categories_iter)r:rrrr
xszComps.categoriesFcCs$tjj|�st�|j||�}t|�S)N)r	r�is_string_type�AssertionError�categories_by_patternr)r:rr*Zcatsrrr�category_by_pattern}szComps.category_by_patterncCstjj|�st�t|||j�S)N)r	rr�r�r-r
)r:rr*rrrr��szComps.categories_by_patterncs�fdd��jjD�S)Nc3s|]}�j|�VqdS)N)r�)r�c)r:rr�	<genexpr>�sz(Comps.categories_iter.<locals>.<genexpr>)rfr
)r:r)r:rr��szComps.categories_itercCst|j�td�S)N)�key)�sorted�environments_iterr1)r:rrrr�szComps.environmentscs.tjj��st�tjj�fdd�|j�D��S)Nc3s|]}|j�kr|VqdS)N)r)rr)rrrr��sz+Comps._environment_by_id.<locals>.<genexpr>)r	rr�r�rr�)r:rr)rr�_environment_by_id�szComps._environment_by_idcCs$tjj|�st�|j||�}t|�S)N)r	rr�r�r]r)r:rr*rbrrr�environment_by_pattern�szComps.environment_by_patterncCs4tjj|�st�t|j��}t|||�}t|td�S)N)r�)	r	rr�r�r|r�r-r�r1)r:rr*rbZ
found_envsrrrr]�szComps.environments_by_patterncs�fdd��jjD�S)Nc3s|]}�j|�VqdS)N)r�)rr�)r:rrr��sz*Comps.environments_iter.<locals>.<genexpr>)rfr)r:r)r:rr��szComps.environments_itercCst|j�td�S)N)r�)r�r{r1)r:rrrr�szComps.groupscs.tjj��st�tjj�fdd�|j�D��S)Nc3s|]}|j�kr|VqdS)N)r)rr)�id_rrr��sz%Comps._group_by_id.<locals>.<genexpr>)r	rr�r�rr{)r:r�r)r�rr��szComps._group_by_idcCs$tjj|�st�|j||�}t|�S)N)r	rr�r�r`r)r:rr*rcrrr�group_by_pattern�szComps.group_by_patterncCs0tjj|�st�t||t|j���}t|td�S)N)r�)	r	rr�r�r-r|r{r�r1)r:rr*rcrrrr`�szComps.groups_by_patterncs�fdd��jjD�S)Nc3s|]}�j|�VqdS)N)ry)rr)r:rrr��sz$Comps.groups_iter.<locals>.<genexpr>)rfr)r:r)r:rr{�szComps.groups_iterN)F)F)F)F)F)F)rFrGrHr;r�r�r�ryr�r�rpr
r�r�r�rr�r�r]r�rr�r�r`r{rrrrr�Ys*	





r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
CompsTransPkgcCs�tjj|�r&d|_||_d|_d|_n\t|tj	j
�r\d|_|j�|_|j�t
j@|_d|_n&|j|_|j|_|jt
j@|_|j|_dS)NFT)r	rr��basearchonlyr�optional�requires�
isinstance�libdnf�transactionZCompsGroupPackage�getNameZgetPackageTyper�r�r�)r:Zpkg_or_namerrrr;�s
zCompsTransPkg.__init__cCs0|j|jko.|j|jko.|j|jko.|j|jkS)N)rr�r�r�)r:�otherrrr�__eq__�szCompsTransPkg.__eq__cCs|jS)N)r)r:rrr�__str__�szCompsTransPkg.__str__cCst|j|j|j|jf�S)N)�hashrr�r�r�)r:rrr�__hash__�szCompsTransPkg.__hash__N)rFrGrHr;r�r�r�rrrrr��sr�c@s�eZdZdd�Zdd�Zdd�Zedd��Zed	d
��Z	e	j
dd
��Z	edd
��Zej
dd
��Zedd��Zej
dd��Zedd��Z
e
j
dd��Z
dS)�TransactionBunchcCs$t�|_t�|_t�|_t�|_dS)N)r'�_install�_install_opt�_remove�_upgrade)r:rrrr;�szTransactionBunch.__init__cCsN|jj|j�|jj|j�|jj|j�|j|jB|j|j|j|_|S)N)r�rSr�r�r�)r:r�rrr�__iadd__�s
 zTransactionBunch.__iadd__cCs(t|j�t|j�t|j�t|j�S)N)r�install�install_opt�upgrade�remove)r:rrrr��szTransactionBunch.__len__cCs6x0|D](}t|t�r |j|�q|jt|��qWdS)N)r�r�r()Zparam�val�itemrrr�
_set_value�s

zTransactionBunch._set_valuecCs|jS)z�
        Packages to be installed with strict=True - transaction will
        fail if they cannot be installed due to dependency errors etc.
        )r�)r:rrrr�szTransactionBunch.installcCs|j|j|�dS)N)r�r�)r:�valuerrrr�	scCs|jS)zw
        Packages to be installed with strict=False - they will be
        skipped if they cannot be installed
        )r�)r:rrrr�
szTransactionBunch.install_optcCs|j|j|�dS)N)r�r�)r:r�rrrr�scCs|jS)N)r�)r:rrrr�szTransactionBunch.removecCs|j|j|�dS)N)r�r�)r:r�rrrr�scCs|jS)N)r�)r:rrrr�!szTransactionBunch.upgradecCs|j|j|�dS)N)r�r�)r:r�rrrr�%sN)rFrGrHr;r�r�rJr�rpr��setterr�r�r�rrrrr��sr�c@s�eZdZdd�Zedd��Zedd��Zegfdd��Zd	d
�Zdd�Z	ddd�Z
dd�Zdd�Zddd�Z
dd�Zdd�Zdd�Zd
S)�SolvercCs||_||_||_dS)N)rNrZ
_reason_fn)r:rNrZ	reason_fnrrrr;+szSolver.__init__cCsdd�|jD�S)NcSsh|]
}|j�qSr)r)rrxrrrr2sz.Solver._mandatory_group_set.<locals>.<setcomp>)r�)rZrrr�_mandatory_group_set0szSolver._mandatory_group_setcCs"dd�|j|j|j|jD�S)NcSsh|]}|j��qSr)r�)rr�rrrr6sz+Solver._full_package_set.<locals>.<setcomp>)r�r�r�r�)rxrrr�_full_package_set4szSolver._full_package_setcsv�fdd�}t�}|t@r*|j||j��|t@rB|j||j��|t@rZ|j||j��|t@rr|j||j	��|S)Ncs�fdd�|D�S)Ncsg|]}|j�kr|�qSr)r)rr�)r3rrr�=sz8Solver._pkgs_of_type.<locals>.filter.<locals>.<listcomp>r)�pkgs)r3rr�filter<sz$Solver._pkgs_of_type.<locals>.filter)
r'r�rSr�r�r�r�r�r�r�)r0�	pkg_typesr3r�r�r)r3r�
_pkgs_of_type:szSolver._pkgs_of_typecCstjj|�st�|jjj|�S)N)r	rr�r�rNr0Zis_removable_pkg)r:Zpkg_namerrr�_removable_pkgKszSolver._removable_pkgcCstjj|�st�|jjj|�S)N)r	rr�r�rNrZZis_removable_group)r:�group_idrrr�_removable_grpOszSolver._removable_grpNTc
Cs�tjj|�st�|jj|�}|s4ttd�t|���|j	j
j||j|j
|�}|j	j
j|�t�}xD|jD]:}	|r||	j|kr|qh||j|	j|||�7}|j|	jdt�qhWx.|jD]$}	|r�|	j|kr�q�|j|	jdt�q�W|S)Nz#Environment id '%s' does not exist.TF)r	rr�r�rr�rrrrNrZ�newrr)r�r�r�r�_group_install�addGroupr�r�r�)
r:�env_idr�r3r4r5�	comps_env�swdb_env�trans�comps_grouprrr�_environment_installSs"zSolver._environment_installcCs�tjj|�dkst�|jjj|�}|s6ttd�|��|jjj	|�t
�}tdd�|j�D��}x&|D]}|j
|�svqf||j|�7}qfW|S)NTz%Environment id '%s' is not installed.cSsg|]}|j��qSr)rU)rrQrrrr�ssz.Solver._environment_remove.<locals>.<listcomp>)r	rr�r�rNrZrErrr�r�r'�	getGroupsr��
_group_remove)r:r�r�r�rzr�rrr�_environment_removejs

zSolver._environment_removecCsNtjj|�st�|jj|�}|jjj|�}|s>t	t
d�|��|sRt	t
d�|��tdd�|j�D��}|j
�}|jjj|j|j|j|�}t�}x\|jD]R}|j|kr�|jjj|j�r�||j|j�7}n||j|j|�7}|j|jdt�q�WxL|jD]B}|j|k�r(|jjj|j��r(||j|j�7}|j|jdt�q�W|jjj|�|S)Nz"Environment '%s' is not installed.z"Environment '%s' is not available.cSsg|]}|j��qSr)rU)rrQrrrr��sz/Solver._environment_upgrade.<locals>.<listcomp>TF)r	rr�r�rr�rNrZrErrr'r��getPackageTypesr�rrr)r�r�r0�_group_upgrader�r�r�r�r�r�)r:r�r�r��old_setr�r�r�rrr�_environment_upgradezs.
zSolver._environment_upgradec
Cs�tjj|�st�|jj|�}|s4ttd�t|���|j	j
j||j|j
|�}x(|j�D]}|j|jdtj|j�qVW|j	j
j|�t�}	|r�|	jj|j||gd��n|	jj|j||gd��|	S)NzGroup id '%s' does not exist.F)r3)r	rr�r�rr�rrrrNr0r�rr)r��
addPackager�r�r�r�r�rSr�r�)
r:r�r�r3r4r5r��
swdb_grouprQr�rrrr��szSolver._group_installcsbtjj|�st��jjj|�}|s2ttd�|���jjj	|�t
�}�fdd�|j�D�|_	|S)Nz&Module or Group '%s' is not installed.csh|]}�j|j��r|�qSr)r�r�)rr�)r:rrr�sz'Solver._group_remove.<locals>.<setcomp>)r	rr�r�rNr0rErrr�r��getPackages)r:r�r�r�r)r:rr��szSolver._group_removec	s&tjj|�st�|jj|�}|jjj|�}g}|sP|r<|j	n|}t
td�|��|sdt
td�|��|j�}t
dd�|j�D���|j|||��|jjj||j|j	|�}x(|j�D]}|j|jdtj|j�q�W|jjj|�t�}�fdd��D�|_�fdd��D�|_�fd	d��D�|_|S)
Nz&Module or Group '%s' is not installed.z&Module or Group '%s' is not available.cSsg|]}|j��qSr)r�)rrQrrrr��sz)Solver._group_upgrade.<locals>.<listcomp>Fcsh|]}|j�kr|�qSr)r)rr�)r�rrr�sz(Solver._group_upgrade.<locals>.<setcomp>cs"h|]}|dd��D�kr|�qS)cSsg|]
}|j�qSr)r)rr�rrrr��sz3Solver._group_upgrade.<locals>.<setcomp>.<listcomp>r)rr)�new_setrrr�scsh|]}|j�kr|�qSr)r)rr�)r�rrr�s)r	rr�r�rr�rNr0rEr)rrr�r'r�r�r�rr�r�r�r�r�r�r�r�r�)	r:r�r�r�r3Zargumentr�rQr�r)r�r�rr��s*zSolver._group_upgradecCslxf|jjD]Z}|jj|�}|jr
t|j�t|j�}|jj�j�j	|d�}x|D]}|j
j|�qPWq
WdS)N)r)Z	persistorrr0rWr'Z	full_listZpkg_excludeZsackZqueryZfiltermZ_goalr�)r:�baser0Zp_grpZinstalled_pkg_namesZinstalled_pkgsr�rrr�'_exclude_packages_from_installed_groups�s
z.Solver._exclude_packages_from_installed_groups)NTN)NTN)rFrGrHr;rJr�r�r�r�r�r�r�r�r�r�r�r�rrrrr�*s
#

r�)NTN)5Z
__future__rrrZlibdnf.transactionr�Zdnf.exceptionsrZdnf.i18nrr�	functoolsrr	Zdnf.utilr#rCr�r�r>Zloggingr
r!r.Z	getLoggerrr�ZCompsPackageType_CONDITIONALr�ZCompsPackageType_DEFAULTr�ZCompsPackageType_MANDATORYr�ZCompsPackageType_OPTIONALr�Z	ALL_TYPESrrr-r1r6�objectr7rKrerqr~r�r�r�r�r�r�rrrr�<module>sP

!A'"f(C

?>