ó ¾[/\c@@s…ddlmZddlmZddlmZddlmZidd6dd6d d 6d d 6Zd „Zdefd„ƒYZ dS(i(tabsolute_import(tprint_function(tunicode_literals(treduceiunameiusummaryiu descriptioniuurlcC@s+t|ƒ}dg||t|ƒ}|S(u, Ordered sset with empty strings prepended. u(tlentsorted(tssettlengthtcurrenttl((s5/usr/lib/python2.7/site-packages/dnf/match_counter.pyt_canonize_string_set"s t MatchCountercB@sƒeZdZed„ƒZed„ƒZd„Zd„Zd„Zd„Z d„Z d„Z d „Z e d d „Zd „ZRS( u—Map packages to which of their attributes matched in a search against what values. The mapping is: ``package -> [(key, needle), ... ]``. c@s"‡fd†}tt||ƒƒS(Nc@sG|d}|d}tˆ|ƒ}||kr5dnd}|t|S(Niii(tgetattrtWEIGHTS(tmatchtkeytneedlethaystacktcoef(tpkg(s5/usr/lib/python2.7/site-packages/dnf/match_counter.pytweight4s   (tsumtmap(RtmatchesR((Rs5/usr/lib/python2.7/site-packages/dnf/match_counter.pyt _eval_weights1scC@sJd}x=|D]5\}}t||ƒ}|t|ƒt|ƒ7}q W|S(Ni(R R(RRtdistRRR((s5/usr/lib/python2.7/site-packages/dnf/match_counter.pyt_eval_distance=s c@s"ˆjƒ‰‡‡fd†}|S(uŒ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@ˆj|ˆ|ƒtˆj|ƒˆƒˆj|ˆ|ƒ fS(N(RR tmatched_needlesR(R(t max_lengthtself(s5/usr/lib/python2.7/site-packages/dnf/match_counter.pytget_keyRs(t _max_needles(RR((RRs5/usr/lib/python2.7/site-packages/dnf/match_counter.pyt _key_funcEs c@s$ˆr t‡fd†ˆDƒƒSdS(u0Return the max count of needles of all packages.c3@s$|]}tˆj|ƒƒVqdS(N(RR(t.0R(R(s5/usr/lib/python2.7/site-packages/dnf/match_counter.pys [si(tmax(R((Rs5/usr/lib/python2.7/site-packages/dnf/match_counter.pyRXscC@s#|j|gƒj||fƒdS(N(t setdefaulttappend(RRRR((s5/usr/lib/python2.7/site-packages/dnf/match_counter.pytadd^scC@s-x&|D]}td|||fƒqWdS(Nu%s %s(tprint(RR((s5/usr/lib/python2.7/site-packages/dnf/match_counter.pytdumpas c@st‡fd†|ˆDƒƒS(Nc3@s"|]}tˆ|dƒVqdS(iN(R (R!tm(R(s5/usr/lib/python2.7/site-packages/dnf/match_counter.pys fs(tset(RR((Rs5/usr/lib/python2.7/site-packages/dnf/match_counter.pytmatched_haystacksescC@std„||DƒƒS(Ncs@s|]}|dVqdS(iN((R!R(((s5/usr/lib/python2.7/site-packages/dnf/match_counter.pys is(R)(RR((s5/usr/lib/python2.7/site-packages/dnf/match_counter.pyt matched_keyshscC@std„||DƒƒS(Ncs@s|]}|dVqdS(iN((R!R(((s5/usr/lib/python2.7/site-packages/dnf/match_counter.pys ls(R)(RR((s5/usr/lib/python2.7/site-packages/dnf/match_counter.pyRkscC@s4|r |n |jƒ}t|d|jƒd|ƒS(NRtreverse(tkeysRR (RR,tlimit_toR-((s5/usr/lib/python2.7/site-packages/dnf/match_counter.pyRnsc@st‡fd†ˆdƒS(Nc@s|tˆ|ƒS(N(R(ttotalR(R(s5/usr/lib/python2.7/site-packages/dnf/match_counter.pytssi(R(R((Rs5/usr/lib/python2.7/site-packages/dnf/match_counter.pyR/rsN(t__name__t __module__t__doc__t staticmethodRRR RR%R'R*R+RtFalsetNoneRR/(((s5/usr/lib/python2.7/site-packages/dnf/match_counter.pyR )s        N( t __future__RRRt functoolsRR R tdictR (((s5/usr/lib/python2.7/site-packages/dnf/match_counter.pyts