usr/lib/python3.6/site-packages/dnf/__pycache__/comps.cpython-36.pyc000064400000063153147205421410021151 0ustar003 f`@sddlmZddlmZddlmZddlZddlmZddlm Z m Z ddl m Z ddlZ ddlZ ddlZddlZddlZddlZddlZddlZddlZddlZddlZejdZejjZejjZejjZ ejj!Z"eeBe Be"BZ#d d Z$d d Z%d dZ&ddZ'd*ddZ(Gddde)Z*Gddde)Z+Gddde)Z,Gddde,Z-Gddde,Z.Gddde,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)reducednfcCs"|j|j|jf}ttjtt|S)N) categoriesgroups environmentsroperator__add__maplen)comps collectionsr/usr/lib/python3.6/comps.py_internal_comps_length6srcCs|dkr dStjj|S)N)r utilfirst)seqrrr_first_if_iterable;srcstjjfdd|D}|r&|S|r>tjtjj}ntjtjtjdj}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|]}|jks|jkr|qSr)nameid).0g)patternrr Esz_by_pattern..)flagsN)r Zi18nrrecompilefnmatch translatematchIsetraddrui_name)rcase_sensitiveZsqnexactr%retrr)rr _by_patternAs      r-cCs|jdkrtjS|jS)N)Z display_ordersysmaxsize)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)Z install_fncZ grp_or_env_idtypesexcludestrictexclude_groupsrrrinstall_or_skip^s r6c@s,eZdZdZddZeddZddZdS) _Langsz6Get all usable abbreviations for the current language.cCsd|_d|_dS)N) last_localecache)selfrrr__init__osz_Langs.__init__cCs"tjtj}|dkrdSdj|S)NC.)NN)localeZ getlocale LC_MESSAGESjoin)Zlclrrr_dotted_locale_strss z_Langs._dotted_locale_strcCsz|j}|j|kr|jSg|_|g}|dkr6|jdx6|D].}x(tj|D]}||jkrL|jj|qLWq.)r'rP AVAILABLEupdate INSTALLEDZgetCompsGroupItemr( getGroupId)r: available installedresultrQr0rrr _get_groupss   zCompsQuery._get_groupscCs`t}|j|j@r&|jdd|D|j|j@r\x(|D] }|j}|sJq8|j|jq8W|S)NcSsh|] }|jqSr)r)rrQrrrrsz'CompsQuery._get_envs..)r'rPrRrSrTZgetCompsEnvironmentItemr(ZgetEnvironmentId)r:rVrWrXrQenvrrr _get_envss   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|jkrtdt|}n.|j|jkrtdt|}ntdt|}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 r rO ENVIRONMENTSrenvironments_by_patternrNrZZsearch_by_patternr[extendGROUPSgroups_by_patternr0rYrPrTrrrRr) r:ZpatternsresZpatenvsgrpsrVrWmsgrrrrEs.              zCompsQuery.getN) rFrGrHrRrTr\r_r;rYr[rErrrrrKs  rKc@s<eZdZddZddZddZeddZed d Zd S) ForwardercCs||_||_dS)N)_i_langs)r:iobjlangsrrrr;szForwarder.__init__cCs t|j|S)N)getattrrf)r:rrrr __getattr__szForwarder.__getattr__cCs.x(|jjD]}|j|}|dk r |Sq W|S)N)rgrE)r:defaultZdctrDtrrr_ui_texts  zForwarder._ui_textcCs|j|j|jS)N)rnZdescZ desc_by_lang)r:rrrui_descriptionszForwarder.ui_descriptioncCs|j|j|jS)N)rnrZ name_by_lang)r:rrrr)szForwarder.ui_nameN) rFrGrHr;rkrnpropertyror)rrrrres  recs8eZdZfddZddZddZeddZZS) 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_idgrprdrrr _build_groups  zCategory._build_groupccs x|jD]}|j|VqWdS)N) group_idsry)r:rwrrr groups_iters zCategory.groups_itercCs t|jS)N)listr{)r:rrrr szCategory.groups) rFrGrHr;ryr{rpr __classcell__rr)rurrqs rqcsLeZdZfddZddZddZddZed d Zed d 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)rBryrvloggererror)r:Zidsr Zgierrr _build_groupss  zEnvironment._build_groupsccs\xVtj|j|jD]B}y|j|VWqtk rR}ztj|WYdd}~XqXqWdS)N) itertoolschainrz option_idsryrvrr)r:rwrrrrr{s zEnvironment.groups_itercCs |j|jS)N)rrz)r:rrrmandatory_groupsszEnvironment.mandatory_groupscCs |j|jS)N)rr)r:rrroptional_groupsszEnvironment.optional_groups) rFrGrHr;ryrr{rprrr}rr)rurr~s    r~csheZdZfddZddZeddZeddZd d Zed d Z ed dZ eddZ Z S)Groupcs$tt|j||||_|j|_dS)N)rrrr; _pkg_factoryrlZselected)r:rhriZ pkg_factory)rurrr;"szGroup.__init__csfdd|jDS)Ncsg|]}|jkr|qSr)type)rpkg)type_rr (sz+Group._packages_of_type..)packages)r:rr)rr_packages_of_type'szGroup._packages_of_typecCs |jtjS)N)rlibcompsPACKAGE_TYPE_CONDITIONAL)r:rrrconditional_packages*szGroup.conditional_packagescCs |jtjS)N)rrPACKAGE_TYPE_DEFAULT)r:rrrdefault_packages.szGroup.default_packagescCst|j|jS)N)rrr)r:rrr packages_iter2szGroup.packages_itercCs |jtjS)N)rrPACKAGE_TYPE_MANDATORY)r:rrrmandatory_packages6szGroup.mandatory_packagescCs |jtjS)N)rrPACKAGE_TYPE_OPTIONAL)r:rrroptional_packages:szGroup.optional_packagescCs|jjS)N)rfZ uservisible)r:rrrvisible>sz Group.visible) rFrGrHr;rrprrrrrrr}rr)rurr s     rc@sLeZdZdZejeejeej e ej e iZ ddZeddZeddZdS) 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)rFrGrHrIrr CONDITIONALrDEFAULTr MANDATORYrOPTIONALrr;rprrrrrrrBs  rc@seZdZddZddZddZddZd d Zd d Zd dZ e ddZ d-ddZ d.ddZ ddZe ddZddZd/ddZd0ddZd d!Ze d"d#Zd$d%Zd1d&d'Zd2d(d)Zd*d+Zd,S)3CompscCstj|_t|_dS)N)rrrfr7rg)r:rrrr;\s zComps.__init__cCs t|jS)N)rrf)r:rrr__len__`sz Comps.__len__cCst||j|jS)N)rqrg _group_by_id)r:Z icategoryrrr_build_categorycszComps._build_categorycCst||j|jS)N)r~rgr)r:Z ienvironmentrrr_build_environmentfszComps._build_environmentcCst||j|jS)N)rrg_build_package)r:ZigrouprrrryiszComps._build_groupcCst|S)N)r)r:rrrrrlszComps._build_packagec CsVtj}y|j|Wn,tjk rB|j}tdj|YnX|j|7_dS)N )rrZ fromxml_fZ ParserErrorZget_last_errorsrr@rf)r:fnrerrorsrrr_add_from_xml_filenameoszComps._add_from_xml_filenamecCs t|jS)N)r|categories_iter)r:rrrr xszComps.categoriesFcCs$tjj|st|j||}t|S)N)r ris_string_typeAssertionErrorcategories_by_patternr)r:rr*Zcatsrrrcategory_by_pattern}s zComps.category_by_patterncCstjj|stt|||jS)N)r rrrr-r )r:rr*rrrrszComps.categories_by_patterncsfddjjDS)Nc3s|]}j|VqdS)N)r)rc)r:rr sz(Comps.categories_iter..)rfr )r:r)r:rrszComps.categories_itercCst|jtdS)N)key)sortedenvironments_iterr1)r:rrrr szComps.environmentscs.tjjsttjjfdd|jDS)Nc3s|]}|jkr|VqdS)N)r)rr)rrrrsz+Comps._environment_by_id..)r rrrrr)r:rr)rr_environment_by_idszComps._environment_by_idcCs$tjj|st|j||}t|S)N)r rrrr]r)r:rr*rbrrrenvironment_by_patterns zComps.environment_by_patterncCs4tjj|stt|j}t|||}t|tdS)N)r) r rrrr|rr-rr1)r:rr*rbZ found_envsrrrr]s  zComps.environments_by_patterncsfddjjDS)Nc3s|]}j|VqdS)N)r)rr)r:rrrsz*Comps.environments_iter..)rfr )r:r)r:rrszComps.environments_itercCst|jtdS)N)r)rr{r1)r:rrrr sz Comps.groupscs.tjjsttjjfdd|jDS)Nc3s|]}|jkr|VqdS)N)r)rr)id_rrrsz%Comps._group_by_id..)r rrrrr{)r:rr)rrrszComps._group_by_idcCs$tjj|st|j||}t|S)N)r rrrr`r)r:rr*rcrrrgroup_by_patterns zComps.group_by_patterncCs0tjj|stt||t|j}t|tdS)N)r) r rrrr-r|r{rr1)r:rr*rcrrrr`szComps.groups_by_patterncsfddjjDS)Nc3s|]}j|VqdS)N)ry)rr)r:rrrsz$Comps.groups_iter..)rfr )r:r)r:rr{szComps.groups_iterN)F)F)F)F)F)F)rFrGrHr;rrrryrrrpr rrrr rrr]rr rrr`r{rrrrrYs*         rc@s,eZdZddZddZddZddZd S) CompsTransPkgcCstjj|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 basearchonlyroptionalrequires isinstancelibdnf transactionZCompsGroupPackagegetNameZgetPackageTyperrr)r:Z pkg_or_namerrrr;s  zCompsTransPkg.__init__cCs0|j|jko.|j|jko.|j|jko.|j|jkS)N)rrrr)r:otherrrr__eq__s   zCompsTransPkg.__eq__cCs|jS)N)r)r:rrr__str__szCompsTransPkg.__str__cCst|j|j|j|jfS)N)hashrrrr)r:rrr__hash__szCompsTransPkg.__hash__N)rFrGrHr;rrrrrrrrsrc@seZdZddZddZddZeddZed d Z e j d d Z ed d Z e j dd Z eddZ e j ddZ eddZ e j ddZ 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)rrSrrr)r:rrrr__iadd__s  zTransactionBunch.__iadd__cCs(t|jt|jt|jt|jS)N)rinstall install_optupgraderemove)r:rrrrszTransactionBunch.__len__cCs6x0|D](}t|tr |j|q|jt|qWdS)N)rrr()Zparamvalitemrrr _set_values   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:rrrrszTransactionBunch.installcCs|j|j|dS)N)rr)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)rr)r:rrrrrscCs|jS)N)r)r:rrrrszTransactionBunch.removecCs|j|j|dS)N)rr)r:rrrrrscCs|jS)N)r)r:rrrr!szTransactionBunch.upgradecCs|j|j|dS)N)rr)r:rrrrr%sN)rFrGrHr;rrrJrrprsetterrrrrrrrrs     rc@seZdZddZeddZeddZegfddZd d Zd d Z dddZ ddZ ddZ dddZ ddZddZddZd S)SolvercCs||_||_||_dS)N)rNrZ _reason_fn)r:rNrZ reason_fnrrrr;+szSolver.__init__cCsdd|jDS)NcSsh|] }|jqSr)r)rrxrrrr2sz.Solver._mandatory_group_set..)r)rZrrr_mandatory_group_set0szSolver._mandatory_group_setcCs"dd|j|j|j|jDS)NcSsh|] }|jqSr)r)rrrrrr6sz+Solver._full_package_set..)rrrr)rxrrr_full_package_set4szSolver._full_package_setcsvfdd}t}|t@r*|j||j|t@rB|j||j|t@rZ|j||j|t@rr|j||j |S)Ncsfdd|DS)Ncsg|]}|jkr|qSr)r)rr)r3rrr=sz8Solver._pkgs_of_type..filter..r)pkgs)r3rrfilter<sz$Solver._pkgs_of_type..filter) r'rrSrrrrrrr)r0 pkg_typesr3rrr)r3r _pkgs_of_type:s zSolver._pkgs_of_typecCstjj|st|jjj|S)N)r rrrrNr0Zis_removable_pkg)r:Zpkg_namerrr_removable_pkgKszSolver._removable_pkgcCstjj|st|jjj|S)N)r rrrrNrZZis_removable_group)r:group_idrrr_removable_grpOszSolver._removable_grpNTc Cstjj|st|jj|}|s4ttdt||j j j ||j |j |}|j j j|t}xD|jD]:} |r|| j|kr|qh||j| j|||7}|j| jdtqhWx.|jD]$} |r| j|krq|j| jdtqW|S)Nz#Environment id '%s' does not exist.TF)r rrrrrrrrrNrZnewrr)rrrr_group_installaddGrouprrr) r:env_idrr3r4r5 comps_envswdb_envtrans comps_grouprrr_environment_installSs"   zSolver._environment_installcCstjj|dkst|jjj|}|s6ttd||jjj |t }t dd|j D}x&|D]}|j |svqf||j|7}qfW|S)NTz%Environment id '%s' is not installed.cSsg|] }|jqSr)rU)rrQrrrrssz.Solver._environment_remove..)r rrrrNrZrErrrrr' getGroupsr _group_remove)r:rrrrzrrrr_environment_removejs  zSolver._environment_removecCsNtjj|st|jj|}|jjj|}|s>t t d||sRt t d|t dd|j D}|j }|jjj|j|j|j|}t}x\|jD]R}|j|kr|jjj|jr||j|j7}n||j|j|7}|j|jdtqWxL|jD]B}|j|kr(|jjj|jr(||j|j7}|j|jdtqW|jjj||S)Nz"Environment '%s' is not installed.z"Environment '%s' is not available.cSsg|] }|jqSr)rU)rrQrrrrsz/Solver._environment_upgrade..TF)r rrrrrrNrZrErrr'rgetPackageTypesrrrr)rrr0_group_upgraderrrrrr)r:rrrold_setrrrrrr_environment_upgradezs.    zSolver._environment_upgradec Cstjj|st|jj|}|s4ttdt||j j j ||j |j |}x(|jD]}|j|j dtj|jqVW|j j j|t} |r| jj|j||gdn| jj|j||gd| S)NzGroup id '%s' does not exist.F)r3)r rrrrrrrrrNr0rrr)r addPackagerrrrrrSrr) r:rrr3r4r5r swdb_grouprQrrrrrs zSolver._group_installcsbtjj|stjjj|}|s2ttd|jjj |t }fdd|j D|_ |S)Nz&Module or Group '%s' is not installed.csh|]}j|jr|qSr)rr)rr)r:rrrsz'Solver._group_remove..) r rrrrNr0rErrrr getPackages)r:rrrr)r:rrszSolver._group_removec s&tjj|st|jj|}|jjj|}g}|sP|r<|j n|}t t d||sdt t d||j }t dd|jD|j||||jjj||j|j |}x(|jD]}|j|jdtj|jqW|jjj|t}fddD|_fddD|_fd dD|_|S) Nz&Module or Group '%s' is not installed.z&Module or Group '%s' is not available.cSsg|] }|jqSr)r)rrQrrrrsz)Solver._group_upgrade..Fcsh|]}|jkr|qSr)r)rr)rrrrsz(Solver._group_upgrade..cs"h|]}|ddDkr|qS)cSsg|] }|jqSr)r)rrrrrrsz3Solver._group_upgrade...r)rr)new_setrrrscsh|]}|jkr|qSr)r)rr)rrrrs)r rrrrrrNr0rEr)rrrr'rrrrrrrrrrrrr) r:rrrr3ZargumentrrQrr)rrrrs* zSolver._group_upgradecCslxf|jjD]Z}|jj|}|jr t|jt|j}|jjjj |d}x|D]}|j j |qPWq WdS)N)r) Z persistorr r0rWr'Z full_listZ pkg_excludeZsackZqueryZfiltermZ_goalr)r:baser0Zp_grpZinstalled_pkg_namesZinstalled_pkgsrrrr'_exclude_packages_from_installed_groupss  z.Solver._exclude_packages_from_installed_groups)NTN)NTN)rFrGrHr;rJrrrrrrrrrrrrrrrrr*s   #  r)NTN)5Z __future__rrrZlibdnf.transactionrZdnf.exceptionsrZdnf.i18nrr functoolsrr Zdnf.utilr#rCrrr>Zloggingr r!r.Z getLoggerrrZCompsPackageType_CONDITIONALrZCompsPackageType_DEFAULTrZCompsPackageType_MANDATORYrZCompsPackageType_OPTIONALrZ ALL_TYPESrrr-r1r6objectr7rKrerqr~rrrrrrrrrrsP       !A'"f(C