σ Ύ[/\c@@sΪddlmZddlmZddlmZddlZddlmZddlmZddl m Z m Z ddl Z ddl Z ddlZ ddlZddlZejdƒZd ejfd „ƒYZdS( i(tabsolute_import(tprint_function(tunicode_literalsN(tcommands(t OptionParser(tucdt_udnft SearchCommandcB@s\eZdZd ZedƒZed„ƒZd„Zd„Z d„Z d„Z d„Z RS( uTA class containing methods needed by the cli to execute the search command. usearchu+search package details for the given stringc C@sZ|jddddtdƒƒ|jdddd td ƒd d gd ddtjƒdS(Nu--alltactionu store_truethelpu'search also package description and URLu query_stringtnargsu+tmetavaru QUERY_STRINGtchoicesualltdefault(t add_argumentRtNoneRtPkgNarrowCallback(tparser((s;/usr/lib/python2.7/site-packages/dnf/cli/commands/search.pyt set_argparser0s  c @sΙtjdtdƒfdtdƒfdtdƒfdtdƒffƒ‰‡fd †‰‡‡fd †}tjjƒ}x4|D],}ˆj|d|ƒˆj|d|ƒq‚Wˆjjrψx‹|D],}ˆj|d|ƒˆj|d|ƒqΕWnTt |ƒ}t |j ƒƒ}x3|D]+}t |j |ƒƒ|kr||=qqWd}d} t} t} d} ˆjjjs¦ˆjjjƒjd |j ƒƒjƒ} nxτ|jd td | ƒD]Ϊ}||j|ƒkrς|j|ƒ}t} n| |j |ƒkr|j |ƒ} t} n| |j|ƒ| kkrX|j|ƒ| k} t} n| rw|| || ƒt} nˆjjj||j|ƒ|ƒqΏWt |ƒdkrΕtjtdƒƒndS(u0Search for simple text tags in a package object.unameuNameusummaryuSummaryu descriptionu DescriptionuurluURLc@sy ˆ|SWn|SXdS(N((tattr(t TRANS_TBL(s;/usr/lib/python2.7/site-packages/dnf/cli/commands/search.pyt_translate_attrBs c@sƒtˆ|ƒ}tdƒj|ƒ}|r=tdƒ|}ntdƒ|}ˆjjj|dj|ƒƒ}tt|ƒƒdS(Nu & u%s Exactly Matched: %%su%s Matched: %%su, (tmapRtjointbasetoutputt fmtSectiontprintR(t exact_matchtattrstkeyst trans_attrsttrans_attrs_strt section_textt formatted(Rtself(s;/usr/lib/python2.7/site-packages/dnf/cli/commands/search.pyt_print_section_headerHs"tpkgtreversetlimit_toiuNo matches found.N(t collectionst OrderedDictRtdnft match_countert MatchCountert_search_countedtoptstalltlentlistRtmatched_needlesRtFalseRtconftshowdupesfromrepostsacktquerytfiltermtlatesttsortedtTruet matched_keystmatched_haystacksRt matchcallbacktloggertinfo( R#targsR$tcountertargtneedlestpkgsR%t used_attrsR2Rtprint_section_headertlimit((RRR#s;/usr/lib/python2.7/site-packages/dnf/cli/commands/search.pyt_search8sV     -    &cC@s†i|d|6}tjj|ƒr7i|d|6}n|jjjƒjtj|}x'|j ƒD]}|j |||ƒqeW|S(Nu %s__substru%s__glob( R*tutiltis_glob_patternRR6R7R8thawkeytICASEtruntadd(R#RBRtneedletfdicttqR%((s;/usr/lib/python2.7/site-packages/dnf/cli/commands/search.pyR-€s!cC@s@|jj r<|jj r<|jjdtjdtjƒndS(Ntstdouttstderr(R.tverbosetquiettclitredirect_loggertloggingtWARNINGtINFO(R#((s;/usr/lib/python2.7/site-packages/dnf/cli/commands/search.pyt pre_configure‰scC@ss|jj r*|jj r*|jjƒn|jj}t|_t|_ t|_ |jj pf|jj |j_ dS(N( R.RURVRWtredirect_repo_progresstdemandsR;tavailable_reposR3tfresh_metadatatsack_activationR/tquery_string_action(R#R^((s;/usr/lib/python2.7/site-packages/dnf/cli/commands/search.pyt configures    cC@s&tjtdƒƒ|j|jjƒS(NuSearching Packages: (R?tdebugRRIR.t query_string(R#((s;/usr/lib/python2.7/site-packages/dnf/cli/commands/search.pyRN–s(usearch( t__name__t __module__t__doc__taliasesRtsummaryt staticmethodRRIR-R\RcRN(((s;/usr/lib/python2.7/site-packages/dnf/cli/commands/search.pyR(s  H  (t __future__RRRR(tdnf.cliRtdnf.cli.option_parserRtdnf.i18nRRR*tdnf.match_countertdnf.utilRLRYt getLoggerR?tCommandR(((s;/usr/lib/python2.7/site-packages/dnf/cli/commands/search.pyts