관리-도구
편집 파일: match_counter.cpython-39.opt-1.pyc
a �����!cT����������������������@���sZ���d�dl�mZ�d�dl�mZ�d�dl�mZ�d�dlmZ�ddddd �Zd d��ZG�dd ��d e�Z dS�)�����)�absolute_import)�print_function)�unicode_literals��reduce����������������)�nameZsummary�description�urlc�����������������C���s"���t�|��}dg||��t|���}|S�)z, Ordered sset with empty strings prepended. ��)�len�sorted)Zsset�length�current�l��r����5/usr/lib/python3.9/site-packages/dnf/match_counter.py�_canonize_string_set"���s����r���c�������������������@���sf���e�Zd�ZdZedd���Zdd��Zdd��Zdd ��Zd d��Z dd ��Z dd��Zdd��Zddd�Z dd��ZdS�)�MatchCounterz�Map packages to which of their attributes matched in a search against what values. The mapping is: ``package -> [(key, needle), ... ]``. c��������������������s�����fdd�}t�t||��S�)Nc��������������������s>���|�d�}|�d�}t���|�}|dkr6||kr6dt|��S�t|�S�)Nr���r ���r���r ���)�getattr�WEIGHTS)�match�key�needleZhaystack��pkgr���r����weight4���s���� z*MatchCounter._eval_weights.<locals>.weight)�sum�map)r����matchesr���r���r���r���� _eval_weights1���s���� zMatchCounter._eval_weightsc��������������������s�����fdd�}|S�)a���Get the key function used for sorting matches. It is not enough to only look at the matches and order them by the sum of their weighted hits. In case this number is the same we have to ensure that the same matched needles are next to each other in the result. Returned function is: pkg -> (weights_sum, canonized_needles_set, -distance) c��������������������s�������|���|����|�jfS��N)r#���r���r�����selfr���r����get_keyK���s�����z'MatchCounter._key_func.<locals>.get_keyr���)r&���r'���r���r%���r���� _key_func?���s����zMatchCounter._key_funcc��������������������s�����rt���fdd���D���S�dS�)z0Return the max count of needles of all packages.c�����������������3���s���|�]}t����|��V��qd�S�r$���)r����matched_needles)�.0r���r%���r���r���� <genexpr>W��������z,MatchCounter._max_needles.<locals>.<genexpr>r���)�maxr%���r���r%���r����_max_needlesT���s����zMatchCounter._max_needlesc�����������������C���s���|���|g���||f��d�S�r$���)� setdefault�append)r&���r���r���r���r���r���r����addZ���s����zMatchCounter.addc�����������������C���s"���|�D�]}t�d||�|�f���qd�S�)Nz%s %s)�print�r&���r���r���r���r����dump]���s����zMatchCounter.dumpc��������������������s���t���fdd�|����D���S�)Nc�����������������3���s���|�]}t���|d���V��qdS�)r���N)r����r*����mr���r���r���r+���b���r,���z1MatchCounter.matched_haystacks.<locals>.<genexpr>��setr3���r���r���r����matched_haystacksa���s����zMatchCounter.matched_haystacksc�����������������C���s2���g�}|�|�D�] }|d�|v�rq|��|d���q|S�)Nr���)r0���)r&���r����result�ir���r���r����matched_keysd���s����zMatchCounter.matched_keysc�����������������C���s���t�dd��|�|�D���S�)Nc�����������������s���s���|�]}|d��V��qdS�)r ���Nr���r5���r���r���r���r+���n���r,���z/MatchCounter.matched_needles.<locals>.<genexpr>r7���r3���r���r���r���r)���m���s����zMatchCounter.matched_needlesFNc�����������������C���s ���|r|n|�����}t||����d�S�)N)r���)�keysr���r(���)r&����reverseZlimit_tor=���r���r���r���r���p���s����zMatchCounter.sortedc��������������������s���t���fdd���d�S�)Nc��������������������s���|�t���|���S�r$���)r���)�totalr���r%���r���r����<lambda>u���r,���z$MatchCounter.total.<locals>.<lambda>r���r���r%���r���r%���r���r?���t���s����zMatchCounter.total)FN)�__name__� __module__�__qualname__�__doc__�staticmethodr#���r(���r.���r1���r4���r9���r<���r)���r���r?���r���r���r���r���r���)���s��� r���N) Z __future__r���r���r���� functoolsr���r���r����dictr���r���r���r���r����<module>���s����