3 ft`@s~ddlmZddlmZddlmZmZddlZddlZ ddl Zddl Zddl Z ddl Z ddlZe jdZGdddeZdS))absolute_import)unicode_literals)_ucdNdnfc@s,eZdZddZddZddZddZd S) RepoReadercCs||_||_dS)N)confopts)selfrr r /usr/lib/python3.6/read.py__init__$szRepoReader.__init__c csx|j|jjD] }|VqWg}x8|jjD],}x&tjtjj|dD]}|j|qFWq,W|j dddxT|D]L}yx|j|D] }|VqWWqrt j j k rt jtd|YqrXqrWdS)Nz*.repocSstjj|ddS)N)rutilZ split_path)xr r r 5sz%RepoReader.__iter__..)keyz'Warning: failed loading '%s', skipping.) _get_reposrZconfig_file_pathreposdirglobospathjoinappendsortr exceptions ConfigErrorloggerwarningr)r rZ repo_configsrrrepofnr r r __iter__(s   zRepoReader.__iter__c Cs^tjjj||jj}tjj|}|dk rl||krJtdj |||||}ntdj ||||}tj j |tjj ||j}y|j |||tjjWnZtk r}z>||krtdj |||}ntdj ||}tj j |WYdd}~XnX|jdtjjkr8||kr tdj ||}ntdj |}tj|t|j|_|jj|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 substitutionsrrepoZrepo_id_invalidrformatrrZRepoZ _populateZPRIO_REPOCONFIG ValueErrorZ _get_priorityZ PRIO_DEFAULTrrrr#Z_substitutionsupdateZcfg) r parserZid_r!Zsubstituted_idZinvalidmsgr'er r r _build_repo?s8         zRepoReader._build_repoccs|jj}tjj}|j|y|j|Wndtk rd}ztjj t dj ||WYdd}~Xn,t k r}zt j|WYdd}~XnXx|jD]x}|dkrqy|j|t||}Wn:tjjtjj fk r}zt j|wWYdd}~XnX||_|j|j|VqWdS)z4Parse and yield all repositories from a config file.zParsing file "{}" failed: {}Nmain)rr&r$r%ZsetSubstitutionsread RuntimeErrorrrrrr(IOErrorrrZgetDatar.rZ RepoErrorZrepofileZ_configure_from_optionsr )r r!Zsubstsr+r-ZsectionZthisrepor 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 getLoggerrobjectrr r r r s