XRc@slddlZddlZddlZddlZddlZddlZddlZddlZddlZddl j Z ddl j Z ddl jZddljZddljZddljZddlmZddlmZdZdZdefdYZdefd YZd efd YZ d e fd YZ!de fdYZ"de fdYZ#de fdYZ$defdYZ%de fdYZ&defdYZ'de'fdYZ(de'fdYZ)defdYZ*d efd!YZ+d"efd#YZ,d$efd%YZ-d&efd'YZ.dS((iN(tchoose(tEmptyIiidt QueryLexerc BseZdZdZd Zd Zd ZdZdZdZ dZ dZ dZ dZ dZdZdZdZdZdZdZRS(sThis class defines the lexer used to separate parse queries into its constituents. It's written for Ply, a python implementation for lex and yacc.tFTERMtTERMtLPARENtRPARENtANDtORtQUOTE1tQUOTE2tLBRACEtRBRACEs\(s\)s[\']s[\"]t cCs(tj|idd6dd6|_dS(NRR(tobjectt__init__treserved(tself((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyREs cCs d|_|S(s([pP]([kK]([gG][sS]?)?)?)?R (R(RR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pytt_RBRACEZs c CsP|jjd}t|dks*t|dd!}xZ|dD]N}|dr|dddkr|dd d||d]|[^\s\(\)\'\"\>])?t:iiiis\RitiiiiR(tvaluetsplittlentAssertionErrortappendRtgetR( RRtfieldsttmptfieldttokentkeyt action_typetpkg_name((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pytt_FTERMas,      cCs|jj|jd|_|S(s,[^\s\(\'\"][^\s]*[^\s\)\'\"\>]|[^\s\(\)\'\"]R(RRRR(RR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pytt_TERMscCsRtdjtd|jdd|jdd|jdgdS(Ns s2An unparseable character in query at position : %dis%sR t^(t RuntimeErrortjoint_tget_post get_string(RR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pytt_errors    cKstjd|||_dS(NR(tlextlexer(Rtkwargs((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pytbuildscCs|jj|dS(N(R0tinput(RR3((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyt set_inputscCs |jjS(N(R0R"(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR"scCs |jjS(N(R0tlexpos(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR,scCs |jjS(N(R0tlexdata(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR-scCs@|jj|x)|jj}|s,Pntj|IJqdS(sThis is a function useful for testing and debugging as it shows the user exactly which tokens are produced from the input data.N(R0R3R"tsyststderr(Rtdatattok((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyttests ( sFTERMsTERMRRsANDsORR R sLBRACEsRBRACE(t__name__t __module__t__doc__ttokenstt_LPARENtt_RPARENtt_QUOTE1tt_QUOTE2tt_ignoreRRRR&R'R.R2R4R"R,R-R;(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR1s(    4       t QueryParsercBseZdZejZddddfZd Zd Zd Zd Z d Z dZ dZ dZ dZdZdZdZdZdZdZdZRS(sThis class defines the parser which converts a stream of tokens into an abstract syntax tree representation of the query. The AST is able to perform the search.trightRtleftRRRR R cCs|jd|d|dRR?t precedenceRKRLRNRORQRURVRYRZR[R]R^R`RbRRh(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyREs,      '        tQueryExceptioncBseZdZRS(cCs t|S(N(tstr(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyt __unicode__ss(R<R=Rl(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRjqstQueryLengthExceededcBseZdZdZRS(cCstj|||_dS(N(RjRt token_cnt(RRn((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR|s cCstdi|jd6td6S(NsiThe number of terms in the query is %(len)i, which exceeds the maximum supported value of %(maxt)i terms.Rtmaxt(R+RntMAX_TOKEN_COUNT(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyt__str__s  (R<R=RRq(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRmzs tDetailedValueErrorcBseZdZdZRS(cCs,tj|||_||_||_dS(N(RjRtnamet bad_valuetquery(RRsRtt whole_query((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs   cCs,tdi|jd6|jd6|jd6S(Ns9In query %(query)s, %(name)s had a bad value of '%(bv)s'.RuRstbv(R+RuRsRt(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRqs    (R<R=RRq(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRrs tIncompleteQuerycBseZdZdZRS(cCstj|||_dS(N(RjRRu(RRv((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs cCstd|jS(NsA query is expected to have five fields: case sensitivity, return type, number of results to return, the number at which to start returning results, and the text of the query. The query provided lacked at least one of those fields: %s(R+Ru(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRqs (R<R=RRq(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRxs RacBseZdZdZRS(cCs,tj|||_||_||_dS(N(RjRRJtposRk(Rt parse_objecttstring_positiont input_string((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs   c CsOdjtdtd|jd|jddt|jdddgS( Ns sCould not parse query.sProblem occurred with: %s s %sR iiR((R*R+RJRktmaxRy(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRqs (R<R=RRq(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRas tQuerycBs]eZdZdZdZdZidd6ZdZdZe dZ e dZ RS( sGeneral Query object. It defines various constants and provides for marshalling a Query into and out of a string format.iiisReturn from search v1 cCst|jd}|tkr0t|n||_||_||_|jtjksu|jtj ksut ||_ ||_ dS(sConstruct a query object. The "text" parameter is the tokens and syntax of the query. The "case_sensitive" parameter is a boolean which determines whether the query is case sensitive or not. The "return_type" parameter must be either RETURN_PACKAGES or RETURN_ACTIONS and determines whether the query is expected to return packages or actions to the querier. The "num_to_return" paramter is the maximum number of results to return. The "start_point" parameter is the number of results to skip before returning results to the querier.R N( RRRpRmttexttcase_sensitivet return_typeR~tRETURN_PACKAGEStRETURN_ACTIONSRt num_to_returnt start_point(RRRRRRRn((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs     cCs&d|j|j|j|j|jfS(s2Return the v1 string representation of this query.s%s_%s_%s_%s_%s(RRRRR(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRqs cCsy%|jdd\}}}}}Wntk rDt|nX|dkrZt}n'|dkrot}ntd|||dkrd }n6yt|}Wn#tk rtd||nX|dkrd }n6yt|}Wn#tk rtd||nXyt|}Wn#tk rLtd ||nX|tj kr|tj krtd ||nt|||||S( soTake the output of the __str__ method of this class and return a Query object from that string.R+itTruetFalseRtNoneRRRN( Rt ValueErrorRxRRRrRtintR~RR(tsRRRRR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pytfromstrsB%              cCs|\}}}}}|S(s1Method which produces the sort key for an action.((tkRTtsttpfmritfvtl((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pytreturn_action_to_keys( R<R=R>t RETURN_EITHERRRtVALIDATION_STRINGRRqt staticmethodRR(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR~s   +tBooleanQueryExceptioncBs eZdZdZdZRS(s}This exception is used when the two children of a boolean query don't agree on whether to return actions or packages.cCs#tj|||_||_dS(swThe parameter "ac" is the child which returned actions while "pc" is the child which returned packages.N(RjRtactpc(RRR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs  cCsTtd}d|j}td}d|j}dj||||tdgS(Ns(This expression produces action results:s %ss)This expression produces package results:s sM'AND' and 'OR' require those expressions to produce the same type of results.(R+RRR*(Rtac_stac_qtpc_stpc_q((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRq#s     (R<R=R>RRq(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs t BooleanQuerycBsVeZdZdZdZdZdZdZdZdZ dZ RS( s1Superclass for all boolean operations in the AST.cCs/||_||_|jj|_|jdS(s The parameters "left_query" and "right_query" are objects which implement the query interface. Specifically, they're expected to implement search, allow_version, set_info, and to have a public member called return_type.N(tlctrcRt!_BooleanQuery__check_return_types(Rt left_queryt right_query((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR2s  cCsa|jj|jjkr]|jjtjkrEt|j|jq]t|j|jndS(N(RRRR~RR(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyt__check_return_types=scGs$|jj||jj|dS(N(Rtadd_field_restrictionsR(Rtparams((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRDscKs$|jj||jj|dS(sThis function passes information to the terms prior to search being executed. For a boolean query, it only needs to pass whatever information exists onto its children.N(Rtset_infoR(RR1((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRHscGs4t|jjd|t|jjd|fS(s^Distributes the search to the two children and returns a tuple of the results.N(tsetRtsearchRR(Rtargs((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRPscCs4d}|jtjkr$tj}nt|d|S(svSort the results. If the results are actions, sort by the fmris of the packages from which they came.R#N(RRR~RRtsorted(RtresR#((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRWs cCs.|dko-|jj|o-|jj|S(s-Returns whether the query supports version v.i(Rt allow_versionR(Rtv((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR`scCs\tj|_|jj}|r-||_n|jj}|rN||_n|jdS(sMakes each child return packages instead of actions. If a child returns a value that isn't None, that means a new node in the tree has been created which needs to become the new child for this node.N(R~RRRtpropagate_pkg_returnRRR(Rtnew_lctnew_rc((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRfs    ( R<R=R>RRRRRRRR(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR/s     RMcBs)eZdZdZdZdZRS(s*Class representing AND queries in the AST.cGsg|jtjkr:|jj||}|jj||Stj||\}}|j||@SdS(sPerforms a search over the two children and combines the results. The "restriction" parameter is a generator of actions, over which the search shall be performed. Only boolean queries will set restriction. Nodes that return packages have, by definition, parents that must return packages. This means that only queries contained within a boolean query higher up in the AST tree will have restriction set.N(RR~RRRRRR(Rt restrictionRtlc_ittlc_settrc_set((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRys cCsd|j|jfS(Ns (%s AND %s)(RR(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRqscCsd|j|jfS(Ns (%r AND %r)(RR(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyt__repr__s(R<R=R>RRqR(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRMvs  R_cBs)eZdZdZdZdZRS(s)Class representing OR queries in the AST.cgs|jtjkrPtj||\}}x|j||BD] }|Vq>Wn|sxtj|jj|||j j||D] }|VqWnWxT|D]L}xCtj|jj|g||j j|g|D] }|VqWqWdS(sTPerforms a search over the two children and combines the results. The "restriction" parameter is a generator function that returns actions within the search domain. If it's not None, then this query is under a higher boolean query which also returns actions.N( RR~RRRRt itertoolstchainRR(RRRRRtitj((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs  "  %cCsd|j|jfS(Ns (%s OR %s)(RR(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRqscCsd|j|jfS(Ns (%r OR %r)(RR(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs(R<R=R>RRqR(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR_s * R\cBs\eZdZdZdZdZdZedZdZ dZ dZ RS( s\Class representing a change from returning actions to returning packages in the AST.cCs||_tj|_dS(N(RuR~RR(RRu((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs cCs d|jS(Nsp<%s>(Ru(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRqscCs d|jS(Nsp<%r>(Ru(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRscKs|jj|dS(sThis function passes information to the terms prior to search being executed. It only needs to pass whatever information exists to its child.N(RuR(RR1((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRscCsg||ks|tjkr|S|tjkrW|tjkrWttd|DSdsctdS(sBased on the return_type and current type, it converts the iterator over results, it, to a sorted list of packages. return_type is what the caller wants to return and current_type is what it is iterating over.css$|]\}}}}}|VqdS(N((t.0RTRRRR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pys siN(R~RRRRRR(titRt current_type((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pytoptional_action_to_packages cGs+|j|jj||tj|jjS(s*Takes the results of its child's search and converts the results to be a sorted list of packages. The "restriction" parameter is a generator of actions which the domain over which search should be performed. It should always be None.(RRuRR~RR(RRR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRscCs|dko|jj|S(s8Returns whether the query supports a query of version v.i(RuR(RR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRscCsdS(sMakes this node return packages instead of actions. Returns None because no changes need to be made to the tree.N(R(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs( R<R=R>RRqRRRRRRR(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR\s     RWcBseZdZdZedZedZedZdZdZ dZ dZ d Z e d Zd Zd Zd ZRS(s-Class representing a phrase search in the ASTcCsx|s t||d|_dj||_|j|_tj|_t|dkrk|jj nd|_ dS(sThe "str_list" parameter is the list of strings which make up the phrase to be searched. The "term_query_class" parameter is a TermQuery object which handles searching for the initial word in the phrase.iR iN( RRuR*tfull_strt compare_strR~RRRtadd_trailing_wildcardRt_case_sensitive(Rtstr_listtterm_query_class((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR s   cCs |jjS(N(RuR%(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR%scCs |jjS(N(RuR$(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR$!scCs |jjS(N(RuR#(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR#%scCsd|jdS(NsPhrase Query:'t'(R(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR)scCsd|jj|jfS(Ns%s:'%s'(Rut field_stringsR(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRq,scGs|jj|dS(N(RuR(RR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR/scKs>||_|s$|jj|_n|jjd||dS(sThis function passes information to the terms prior to search being executed. It only needs to pass whatever information exists to its child.RN(RRtlowerRRuR(RRR1((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR2s cCs)|jr|j|kS|j|jkS(s`Check to see if the phrase is contained in l, the string of the original action.(RRR(RR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyt filter_res<s  cCs=|dks1||ks1| r5||jkr5|S|SdS(sChecks to see if the phrase being searched for is a subtring of the value which matched the token. If it is, use the value returned, otherwise use the search phrase.RN(R(tfsRRTR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pytcombineDscs)fdjj||D}|S(slPerform a search for the given phrase. The child is used to find instances of the first word of the phrase. Those results are then filtered by searching for the longer phrase within the original line of the action. restriction is a generator function that returns actions within the search domain.c 3sZ|]P\}}}}}j|r|||jj||j|fVqdS(N(RRRR(RRTRRRR(R(s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pys Xs(RuR(RRRR((Rs6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRPs cCs|dko|jj|S(s8Returns whether the query supports a query of version v.i(RuR(RR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR`scCs t|S(sInserts a conversion to package results into the tree. Creates a new node by wrapping a PkgConversion node around itself. It then returns the new node to its parent for insertion into the tree.(R\(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRes(R<R=R>RtpropertyR%R$R#RRqRRRRRRRR(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRW s       RRcBsMeZdZdZdZdZdZdZdZdZ RS(s1Class representing a structured query in the AST.cCs)||_tj|_|jj|dS(s3Builds a FieldQuery object. The "params" parameter are the three parts of the structured search term pulled apart during parsing. The "query" parameter is the Query object which contains the fourth field (the token) of the structured search.N(RuR~RRR(RRRu((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRps  cCs)d|jj|jj|jj|jfS(Ns( PN:%r AT:%r ST:%r Q:%r)(RuR%R$R#(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs cCs t|jS(N(RkRu(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRqscKs|jj|dS(sThis function passes information to the terms prior to search being executed. It only needs to pass whatever information exists to its child.N(RuR(RR1((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRscGs.|jjtjkst|jj||S(sPerform a search for the structured query. The child has been modified so that it is able to do the structured query directly.(RuRR~RRR(RRR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRscCs|dko|jj|S(s8Returns whether the query supports a query of version v.i(RuR(RR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRscCs t|S(sInserts a conversion to package results into the tree. Creates a new node by wrapping a PkgConversion node around itself. It then returns the new node to its parent for insertion into the tree.(R\(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs( R<R=R>RRRqRRRR(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRRms      RHcBs_eZdZdZdZdZdZdZdZdZ dZ d Z RS( sClass which must be at the top of all valid ASTs, and may only be at the top of an AST. It handles starting N results in, or only showing M items. It also transforms the internal representations of results into the format expected by the callers of search.cCs||_d|_d|_dS(Ni(RuRRR(RRu((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs  cCs d|jS(Ns TopQuery(%r)(Ru(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRscCs t|jS(N(RkRu(R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRqscCs2||jko1|jdkp1||j|jkS(s6Determines whether the x'th result should be returned.N(RRR(Rtx((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyt__keepscsMjjtjkr/fdt|DSfdt|DSdS(sConverts the internal result representation to the format which is expected by the callers of search. It also handles returning only those results requested by the user.c3sW|]M\}\}}}}}j|rdtjtj|||ffVqdS(iN(t_TopQuery__keepR~RtfmritPkgFmri(RRRTRRRR(R(s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pys sc3s?|]5\}}j|rdtjtj|fVqdS(iN(RR~RRR(RRR(R(s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pys s N(RuRR~Rt enumerate(RR((Rs6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pytfinalize_resultss   cKs;|r||_n||_|jjd|d||dS(sThis function passes information to the terms prior to search being executed. This is also where the starting point and number of results to return is set. Both "num_to_return" and "start_point" are expected to be integers.RRN(RRRuR(RRRR1((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs   cGs|j|jjd|S(sPerform search by taking the result of the child's search and transforming and subselecting the results. None is passed to the child since initially there is no set of results to restrict subsequent searches to.N(RRuRR(RR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRscCs|jj|S(s8Returns whether the query supports a query of version v.(RuR(RR((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRscCs%|jj}|r!||_ndS(sMakes the child return packages instead of actions. If a child returns a value that isn't None, that means a new node in the tree has been created which needs to become the new child for this node.N(RuRR(Rt new_child((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRs ( R<R=R>RRRqRRRRRR(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRHs       RPcBs"eZdZiZejdZdZdZ dZ e dZ e dZ e dZdZdZd Zd Zed Ze d Zd ZedZdZdZdZdZedZdZdZdZdZ dZ!RS(sClass representing the a single query term in the AST. This is an abstract class and should not be used instead of the related client and server classes.s .*[^\*\?].*cCs|j}t|_d|ks9d|ks9d|krEt|_n||_tj|_t|_ d|_ d|_ d|_ t|_t|_t|_d|_d|_d|_d|_d|_d|_d|_dS(s6term is a the string for the token to be searched for.RSt?t[N(tstripRt_globRt_termR~RRtFILE_OPEN_TIMEOUT_SECSt_file_timeout_secsRR%R$R#taction_type_wildcardt key_wildcardtpkg_name_wildcardtpkg_name_matchRt _dir_patht_manifest_path_funct _data_manft_data_token_offsett_data_main_dict(Rtterm((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyR s(  $                cCsc|j}||krdSitjtjd6tjtjd6tjtjdd6||UstrbN(tosRtisdirR*RRRRPtfmrisRRR"Rtopentget_nameRktversiontEnvironmentErrorterrnotENOENTtaddR(RR<t pkg_offsetstmatching_pfmritfhteR((Rs6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyt_read_pkg_dirsHs*$      c cs|jjdk st|j}|j}|j}|sEt}nd}|rtj j |r|j j }t |||}tg|D]}|j j|^q}qn>|j j|rt|j j|g}n|jdS|jsZy|jj|j} Wn tk r7|j|} nX|dkrM| }qZ|| M}n|jst} yuttjj|jd|jd} x'| D]} | jt | j!qW|dkr| }n || M}Wqt"k r} | j#t#j$kr nt}qXn|j%st} yottjj|jd|j&d} x!| D]} | jt | q_W|dkr| }n || M}Wqt"k r} | j#t#j$krnt}qXnt'}|dk r|j(|}n+|r%tj j | r%|jj}nx|D]}|dk sEt|jj)|\}}||ks| r|j*|j*ks|rt+j+||s| rt+j+|j*|j*stx|D]\}}|j r||jkrqnx|D]\}}|j% r/||j&kr/qnx|D]\}}x|D]}\}}t |}|j,j-|}|j r|j| rqIng|D]}t |^q}|||||fVqIWq6WqWqWq,W|jdS(s2Searches the indexes in dir_path for any matches of query and the results in self.res. The method assumes the dictionaries have already been loaded and read appropriately. The "fmris" parameter is a generator of fmris of installed packages.Nt__at_R9t__st_s (.RR.RRRRRRRPthas_non_wildcard_characterR Rtget_keysRRtget_idt has_entityR RRt get_offsetsRtAttributeErrorRHRR=R:RR*RR$RCRRR@RARBRR#Rt_TermQuery__offset_line_readtparse_main_dict_lineRRRt get_entity(RR<R(RRR1tkeysR,R RDttmp_setRFRRGt line_itertlineR:tat_lstRTtst_listRtfv_listRtp_listtp_idt m_off_settp_strR3tint_os((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyt_search_internalgs    +                    $   " c csx|D]\}}}}}g}tj|}|j|} t| ddd} x@t|D]2} | j| |j|||| jfqbW| jx.|D]&\}}}} ||||| fVqWqWdS(sTakes the results from search_internal ("res") and reads the lines from the manifest files at the provided offsets.R9t bufferingiN( RRRR=RR/RR0tclose( RRR)R1RTRRtsend_restfRt file_handleR3R((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyt _get_resultss  N("R<R=R>RRRRKRR<RR t classmethodRRRRRqRRRRRRRRRRR R$R-RQRHR`Rf(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pyRPs6       n   $  (/R:RRR7RRRRAtcgitply.lexR/tply.yaccRftpkg.search_storagetsearch_storageRtpkg.search_errorsRtpkg.fmriRt pkg.actionsR&t pkg.chooseRtpkg.miscRRRpRRREt ExceptionRjRmRrRxRaR~RRRMR_R\RWRRRHRP(((s6/usr/lib/python2.7/vendor-packages/pkg/query_parser.pytsF           bG%3<c7U