3 f&@s`ddlmZddlmZddlmZddlZddlZ ddl Z ddl Z ej j Z GdddeZdS))unicode_literals) ConfigError)_NcseZdZddZddZddZddZffd d Zd d Zd dZ ddZ ddZ fddZ ddZ ddZddZZS)RepoDictcCsj|j}||krd}t||y|jjWn0tk r\}ztdj|WYdd}~XnX|||<dS)Nz;Repository %s is listed more than once in the configurationz{0})idrZ_repoZverify RuntimeErrorformat)selfrepoZid_msger /usr/lib/python3.6/repodict.pyadd#s  z RepoDict.addcCstjj|jS)N)dnfutil MultiCallListvalues)r r r rall/sz RepoDict.allcCstjj|j S)N)rrempty iter_enabled)r r r r _any_enabled3szRepoDict._any_enabledcCsPxJ|jD]>}x8|j||jD]$}|js tjtd|j|jq Wq WdS)Nzenabling %s repository)r get_matchingrenabledloggerinforenable)r Z sub_name_fnr foundr r r_enable_sub_repos6s zRepoDict._enable_sub_reposc  sfdd}tjj|}x:|D]2}d|kr>djtjj|}|j||g7_q Wx$|jD]\}} t |||| q`W|j |t j t d|dj||S)a Creates new repo object and add it into RepoDict. Variables in provided values will be automatically substituted using conf.substitutions (like $releasever, ...) @param repoid: Repo ID - string @param conf: dnf Base().conf object @param baseurl: List of strings @param kwargs: keys and values that will be used to setattr on dnf.repo.Repo() object @return: dnf.repo.Repo() object cspt|trtjjj|jSt|ts0t|trlg}x.|D]&}t|tr:|j tjjj|jq:W|rl|S|S)N) isinstancestrlibdnfconfZ ConfigParser substituteZ substitutionslisttupleappend)rZ substitutedvalue)r"r rr#Is   z)RepoDict.add_new_repo..substitutez://z file://{}zAdded %s repo from %sz, )rr ZReporospathabspathbaseurlitemssetattrrrrrjoin) r Zrepoidr"r+kwargsr#r r)keyr'r )r"r add_new_repo=s   zRepoDict.add_new_repocCsdd}|j|dS)z@enable debug repos corresponding to already enabled binary reposcSs&|jdrdj|ddSdj|S)Nz-rpmsz {}-debug-rpmsz {}-debuginfo)endswithr)namer r r debug_nameesz/RepoDict.enable_debug_repos..debug_nameN)r)r r6r r renable_debug_reposaszRepoDict.enable_debug_reposcCsdd}|j|dS)zAenable source repos corresponding to already enabled binary reposcSs&|jdrdj|ddSdj|S)Nz-rpmsz{}-source-rpmsr2z {}-sourcer3)r4r)r5r r r source_nameosz1RepoDict.enable_source_repos..source_nameN)r)r r8r r renable_source_reposkszRepoDict.enable_source_reposcsZtjjr,fddD}tjj|Sjd}|dkrLtjjgStjj|gS)Ncs g|]}tj|r|qSr )fnmatch).0k)r0r r r xsz)RepoDict.get_matching..)rrZis_glob_patternrget)r r0lr r )r0r rrus    zRepoDict.get_matchingcCsdd|jDS)Ncss|]}|jr|VqdS)N)r)r;rr r r sz(RepoDict.iter_enabled..)r)r r r rrszRepoDict.iter_enabledcs$ddttt|jdddDS)zreturn repos sorted by prioritycss|] }|VqdS)Nr )r;itemr r rrAsz!RepoDict.items..cSs|dj|djfS)N)ZpriorityZcost)xr r rsz RepoDict.items..)r0)sortedsuperrr,)r ) __class__r rr,szRepoDict.itemscCs|jS)N)keys)r r r r__iter__szRepoDict.__iter__cCsdd|jDS)Ncss|]\}}|VqdS)Nr )r;r<vr r rrAsz RepoDict.keys..)r,)r r r rrIsz RepoDict.keyscCsdd|jDS)Ncss|]\}}|VqdS)Nr )r;r<rKr r rrAsz"RepoDict.values..)r,)r r r rrszRepoDict.values)__name__ __module__ __qualname__rrrrr1r7r9rrr,rJrIr __classcell__r r )rHrr!s  $    r)Z __future__rZdnf.exceptionsrZdnf.i18nrZdnf.utilrZ libdnf.confr!r:r(rrdictrr r r rs