grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a ©!cTã@sZddlmZddlmZddlmZddlmZddddd œZd d „ZGd d „d eƒZ dS)é)Úabsolute_import)Úprint_function)Úunicode_literals©Úreduceéééé)ÚnameZsummaryÚ descriptionÚurlcCs"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"src@sfeZdZdZedd„ƒZdd„Zdd„Zdd „Zd d „Z d d „Z dd„Z dd„Z ddd„Z dd„ZdS)Ú MatchCounterz—Map packages to which of their attributes matched in a search against what values. The mapping is: ``package -> [(key, needle), ... ]``. cs‡fdd„}tt||ƒƒS)Ncs>|d}|d}tˆ|ƒ}|dkr6||kr6dt|St|S)Nrr r r )ÚgetattrÚWEIGHTS)ÚmatchÚkeyÚneedleZhaystack©ÚpkgrrÚweight4s   z*MatchCounter._eval_weights..weight)ÚsumÚmap)rÚmatchesrrrrÚ _eval_weights1s zMatchCounter._eval_weightscs‡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) csˆ |ˆ|¡ |jfS©N)r#r r©ÚselfrrÚget_keyKsüz'MatchCounter._key_func..get_keyr)r&r'rr%rÚ _key_func?s zMatchCounter._key_funccsˆrt‡fdd„ˆDƒƒSdS)z0Return the max count of needles of all packages.c3s|]}tˆ |¡ƒVqdSr$)rÚmatched_needles)Ú.0rr%rrÚ Wóz,MatchCounter._max_needles..r)Úmaxr%rr%rÚ _max_needlesTszMatchCounter._max_needlescCs| |g¡ ||f¡dSr$)Ú setdefaultÚappend)r&rrrrrrÚaddZszMatchCounter.addcCs"|D]}td|||fƒqdS)Nz%s %s)Úprint©r&rrrrÚdump]szMatchCounter.dumpcst‡fdd„|ˆDƒƒS)Nc3s|]}tˆ|dƒVqdS)rN)r©r*Úmrrrr+br,z1MatchCounter.matched_haystacks..©Úsetr3rrrÚmatched_haystacksaszMatchCounter.matched_haystackscCs2g}||D] }|d|vrq | |d¡q |S)Nr)r0)r&rÚresultÚirrrÚ matched_keysds   zMatchCounter.matched_keyscCstdd„||DƒƒS)Ncss|]}|dVqdS)r Nrr5rrrr+nr,z/MatchCounter.matched_needles..r7r3rrrr)mszMatchCounter.matched_needlesFNcCs |r|n| ¡}t|| ¡d�S)N)r)Úkeysrr()r&ÚreverseZlimit_tor=rrrrpszMatchCounter.sortedcst‡fdd„ˆdƒS)Ncs|tˆ|ƒSr$)r)Útotalrr%rrÚur,z$MatchCounter.total..rrr%rr%rr?tszMatchCounter.total)FN)Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú staticmethodr#r(r.r1r4r9r<r)rr?rrrrr)s   rN) Z __future__rrrÚ functoolsrrrÚdictrrrrrÚs    ü