a ©!c‹ã@s~ddlmZddlmZddlmZmZddlZddlZ ddl Zddl Zddl Z ddl Z ddlZe  d¡ZGdd„deƒZdS)é)Úabsolute_import)Úunicode_literals)Ú_ÚucdNÚdnfc@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) Ú RepoReadercCs||_||_dS)N)ÚconfÚopts)Úselfrr ©r ú1/usr/lib/python3.9/site-packages/dnf/conf/read.pyÚ__init__$szRepoReader.__init__c cs°| |jj¡D] }|Vqg}|jjD](}t tj |d¡¡D]}| |¡q>q&|j dd„d|D]F}z| |¡D] }|VqtWqdt j j y¨t  tdƒ|¡Yqd0qddS)Nz*.repocSstj |dd…¡S)Néûÿÿÿ)rÚutilZ split_path)Úxr r r Ú5óz%RepoReader.__iter__..)Úkeyz'Warning: failed loading '%s', skipping.)Ú _get_reposrZconfig_file_pathÚreposdirÚglobÚosÚpathÚjoinÚappendÚsortrÚ exceptionsÚ ConfigErrorÚloggerÚwarningr)r ÚrZ repo_configsrrÚrepofnr r r Ú__iter__(s   ÿzRepoReader.__iter__c Cs`tjj ||jj¡}tj |¡}|durl||krJtdƒ  |||||¡}ntdƒ  ||||¡}tj   |¡‚tj  ||j¡}z|  |||tjj¡Wn\tyð}zD||krÀtdƒ  |||¡}ntdƒ  ||¡}tj   |¡‚WYd}~n d}~00| d¡tjjkr:||kr"tdƒ  ||¡}ntdƒ  |¡}t |¡t|jƒ|_|j |jj¡||_|S) z)Build a repository using the parsed data.Nz&Bad id for repo: {} ({}), byte = {} {}z!Bad id for repo: {}, byte = {} {}z.Repository '{}' ({}): Error parsing config: {}z)Repository '{}': Error parsing config: {}Únamez@Repository '{}' ({}) is missing name in configuration, using id.z;Repository '{}' is missing name in configuration, using id.)ÚlibdnfrÚ ConfigParserZ substituteÚ substitutionsrÚrepoZrepo_id_invalidrÚformatrrZRepoZ _populateZPRIO_REPOCONFIGÚ ValueErrorZ _get_priorityZ PRIO_DEFAULTrrrr#Z_substitutionsÚupdateZcfg) r ÚparserZid_r!Zsubstituted_idZinvalidÚmsgr'Úer r r Ú _build_repo?s>  þ  ÿ" ÿ  zRepoReader._build_repoc cs(|jj}tj ¡}| |¡z| |¡Wnhtyf}z$tj  t dƒ  ||¡¡‚WYd}~n6d}~0t y’}zt  |¡WYd}~n d}~00| ¡D]†}|dkrªqœz| |t|ƒ|¡}WnHtjjtjj fy}z"t  |¡WYd}~qœWYd}~nd}~00||_| |j¡|VqœdS)z4Parse and yield all repositories from a config file.zParsing file "{}" failed: {}NÚmain)rr&r$r%ZsetSubstitutionsÚreadÚ RuntimeErrorrrrrr(ÚIOErrorrrZgetDatar.rZ RepoErrorZrepofileZ_configure_from_optionsr )r r!Zsubstsr+r-ÚsectionZthisrepor r r rhs(  ,   " zRepoReader._get_reposN)Ú__name__Ú __module__Ú __qualname__r r"r.rr r r r r#s)r)Z __future__rrZdnf.i18nrrZdnf.confrZ libdnf.confr$Zdnf.exceptionsZdnf.reporZloggingrZ getLoggerrÚobjectrr r r r Ús