509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
ÌÐg&  ã               @   s`   d dl mZ d dlmZ d dlmZ d dlZd dlZ	d dl
Z
d dlZejjZG dd„ deƒZdS )é    )Úunicode_literals)ÚConfigError)Ú_Nc                   s€   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zf fd	d
„Zdd„ Zdd„ Z	dd„ Z
dd„ Z‡ fdd„Zdd„ Zdd„ Zdd„ Z‡  ZS )ÚRepoDictc             C   sj   |j }|| krd}t|| ƒ‚y|jjƒ  W n0 tk
r\ } ztdj|ƒƒ‚W Y d d }~X nX || |< d S )Nz;Repository %s is listed more than once in the configurationz{0})Úidr   Z_repoZverifyÚRuntimeErrorÚformat)ÚselfÚrepoZid_ÚmsgÚe© r   ú/usr/lib/python3.6/repodict.pyÚadd#   s     zRepoDict.addc             C   s   t jj| jƒ ƒS )N)ÚdnfÚutilÚMultiCallListÚvalues)r	   r   r   r   Úall/   s    zRepoDict.allc             C   s   t jj| jƒ ƒ S )N)r   r   ÚemptyÚiter_enabled)r	   r   r   r   Ú_any_enabled3   s    zRepoDict._any_enabledc             C   sP   xJ| j ƒ D ]>}x8| j||jƒƒD ]$}|js tjtdƒ|jƒ |jƒ  q W q
W d S )Nzenabling %s repository)r   Úget_matchingr   ÚenabledÚloggerÚinfor   Úenable)r	   Zsub_name_fnr
   Úfoundr   r   r   Ú_enable_sub_repos6   s
    zRepoDict._enable_sub_reposc       
         s¢   ‡ fdd„}t jj|ˆ ƒ}x:|D ]2}d|kr>djtjj|ƒƒ}| j||ƒg7  _q W x$|jƒ D ]\}}	t	||||	ƒƒ q`W | j
|ƒ tjtdƒ|dj|ƒƒ |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
        c                sp   t | tƒrtjjj| ˆ jƒS t | tƒs0t | tƒrlg }x.| D ]&}t |tƒr:|j	tjjj|ˆ jƒƒ q:W |rl|S | S )N)
Ú
isinstanceÚstrÚlibdnfÚconfZConfigParserÚ
substituteZsubstitutionsÚlistÚtupleÚappend)r   ZsubstitutedÚvalue)r"   r   r   r#   I   s    


z)RepoDict.add_new_repo.<locals>.substitutez://z	file://{}zAdded %s repo from %sz, )r   r
   ZRepor   ÚosÚpathÚabspathÚbaseurlÚitemsÚsetattrr   r   r   r   Újoin)
r	   Zrepoidr"   r+   Úkwargsr#   r
   r)   Úkeyr'   r   )r"   r   Úadd_new_repo=   s    

zRepoDict.add_new_repoc             C   s   dd„ }| j |ƒ dS )z@enable debug repos corresponding to already enabled binary reposc             S   s&   | j dƒrdj| d d… ƒS dj| ƒS )Nz-rpmsz{}-debug-rpmsé   z{}-debuginfoéûÿÿÿ)Úendswithr   )Únamer   r   r   Ú
debug_namee   s    z/RepoDict.enable_debug_repos.<locals>.debug_nameN)r   )r	   r6   r   r   r   Úenable_debug_reposa   s    zRepoDict.enable_debug_reposc             C   s   dd„ }| j |ƒ dS )zAenable source repos corresponding to already enabled binary reposc             S   s&   | j dƒrdj| d d… ƒS dj| ƒS )Nz-rpmsz{}-source-rpmsr2   z	{}-sourcer3   )r4   r   )r5   r   r   r   Úsource_nameo   s    z1RepoDict.enable_source_repos.<locals>.source_nameN)r   )r	   r8   r   r   r   Úenable_source_reposk   s    zRepoDict.enable_source_reposc                sZ   t jjˆ ƒr,‡ ‡fdd„ˆD ƒ}t jj|ƒS ˆjˆ d ƒ}|d krLt jjg ƒS t jj|gƒS )Nc                s    g | ]}t j |ˆ ƒrˆ| ‘qS r   )Úfnmatch)Ú.0Úk)r0   r	   r   r   ú
<listcomp>x   s    z)RepoDict.get_matching.<locals>.<listcomp>)r   r   Zis_glob_patternr   Úget)r	   r0   Úlr
   r   )r0   r	   r   r   u   s    zRepoDict.get_matchingc             C   s   dd„ | j ƒ D ƒS )Nc             s   s   | ]}|j r|V  qd S )N)r   )r;   Úrr   r   r   ú	<genexpr>�   s    z(RepoDict.iter_enabled.<locals>.<genexpr>)r   )r	   r   r   r   r      s    zRepoDict.iter_enabledc                s$   dd„ t tt| ƒjƒ dd„ d�D ƒS )zreturn repos sorted by priorityc             s   s   | ]
}|V  qd S )Nr   )r;   Úitemr   r   r   rA   …   s    z!RepoDict.items.<locals>.<genexpr>c             S   s   | d j | d jfS )Né   )ZpriorityZcost)Úxr   r   r   Ú<lambda>†   s    z RepoDict.items.<locals>.<lambda>)r0   )ÚsortedÚsuperr   r,   )r	   )Ú	__class__r   r   r,   ƒ   s    zRepoDict.itemsc             C   s   | j ƒ S )N)Úkeys)r	   r   r   r   Ú__iter__ˆ   s    zRepoDict.__iter__c             C   s   dd„ | j ƒ D ƒS )Nc             s   s   | ]\}}|V  qd S )Nr   )r;   r<   Úvr   r   r   rA   Œ   s    z RepoDict.keys.<locals>.<genexpr>)r,   )r	   r   r   r   rI   ‹   s    zRepoDict.keysc             C   s   dd„ | j ƒ D ƒS )Nc             s   s   | ]\}}|V  qd S )Nr   )r;   r<   rK   r   r   r   rA   �   s    z"RepoDict.values.<locals>.<genexpr>)r,   )r	   r   r   r   r   Ž   s    zRepoDict.values)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r1   r7   r9   r   r   r,   rJ   rI   r   Ú__classcell__r   r   )rH   r   r   !   s   $


r   )Z
__future__r   Zdnf.exceptionsr   Zdnf.i18nr   Zdnf.utilr   Zlibdnf.confr!   r:   r(   r   r   Údictr   r   r   r   r   Ú<module>   s   