bgkdZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z ejd krejZnejZd d gZGd d ejZejdGddZGdd eZGddZdZdedejfdZdedejfdZdedejfdZdedejfdZGdde e e!fZ"Gdd ZdS)aEvaluate match expressions, as used by `-k` and `-m`. The grammar is: expression: expr? EOF expr: and_expr ('or' and_expr)* and_expr: not_expr ('and' not_expr)* not_expr: 'not' not_expr | '(' expr ')' | ident ident: (\w|:|\+|-|\.|\[|\]|\\|/)+ The semantics are: - Empty expression evaluates to False. - ident evaluates to True of False according to a provided matcher function. - or/and/not evaluate according to the usual boolean semantics. N)Callable)Iterator)Mapping)NoReturn)Optional)Sequence) Expression ParseErrorc*eZdZdZdZdZdZdZdZdZ dS) TokenTypezleft parenthesiszright parenthesisorandnot identifierz end of inputN) __name__ __module__ __qualname__LPARENRPARENORANDNOTIDENTEOFh/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/_pytest/mark/expression.pyrr*s1 F F B C C E CCCrrT)frozenc2eZdZUdZeed<eed<eed<dS)Token)typevalueposr#r$r%N)rrr __slots__r__annotations__strintrrrr"r"4s0(I OOO JJJ HHHHHrr"c2eZdZdZdededdfdZdefdZdS)r zThe expression contains invalid syntax. :param column: The column in the line where the error occurred (1-based). :param message: A description of the error. columnmessagereturnNc"||_||_dSNr+r,)selfr+r,s r__init__zParseError.__init__Cs  rc&d|jd|jS)Nz at column z: r0r1s r__str__zParseError.__str__Gs9DK994<999r)rrr__doc__r)r(r2r5rrrr r <sb sST:::::::rceZdZdZdeddfdZdedeefdZddd e d e de efd Z d e e defd ZdS)Scanner)tokenscurrentinputr-Ncl|||_t|j|_dSr/)lexr9nextr:)r1r;s rr2zScanner.__init__Ns(hhuoo DK(( rc#RKd}|t|krq||dvr|dz }nL||dkr$ttjd|V|dz }n||dkr#ttjd|V|dz }nt jd||d}|r|d}|dkrttj||Vne|dkrttj ||VnA|d krttj ||Vnttj ||V|t|z }nt|dzd ||d |t|kqttj d |VdS) Nr)  ()z(:?\w|:|\+|-|\.|\[|\]|\\|/)+rrrzunexpected character "")lenr"rrrrematchgrouprrrrr r)r1r;r%rIr$s rr=z Scanner.lexRsCJJSz[((qss""I,c377777qss""I,c377777q!@%+NN!KKNNE}}#IL%======%#IM5#>>>>>>%#IM5#>>>>>>#IOUC@@@@@3u::%CC$a>s>>>/CJJ6IM2s+++++++rFrejectr#rLc|jj|ur5|j}|jtjurt |j|_|S|r||fdSr/)r:r#rrr>r9rL)r1r#rLtokens racceptzScanner.acceptqs_ <  $ $LEz..#DK00 L  ! KK trexpectedc t|jjdzddd|D|jjj)NrBzexpected {}; got {}z OR c3$K|] }|jV dSr/)r$).0r#s r z!Scanner.reject..s$<<4DJ<<<<<9>9(5/ x 2 x      rr8$sr-c |tjrtd}n0t |}|tjdt jt j|S)NFTrK)rOrrastNameConstantexprastfix_missing_locationsr )rYrets r expressionr`sexx -'..1gg t,,,  $S^C%8%8 9 99rct|}|tjrVt|}t jt j||g}|tjV|Sr/)and_exprrOrrr]BoolOpOrrYr_rhss rr\r\sh 1++C ((9< /qkkjC:.. ((9< / Jrct|}|tjrVt|}t jt j||g}|tjV|Sr/)not_exprrOrrr]rcAndres rrbrbsh 1++C ((9= ! !0qkkjS#J// ((9= ! !0 Jrc`|tjr3tjtjt |S|tjr2t|}|tj d|S|tj }|r3tj t|j ztjS|tjtjtj fdS)NTrK)rOrrr]UnaryOpNotrhrr\rrName IDENT_PREFIXr$LoadrL)rYr_idents rrhrhsxx 3{3799hqkk222xx  !!1gg !$/// HHY_ % %E @x u{2CHJJ???HHimY-y ?@@@@@rcheZdZdZdeegefddfdZdedefdZde efdZ de fd Z dS) MatcherAdapterzDAdapts a matcher function to a locals mapping as required by eval().matcherr-Nc||_dSr/)rs)r1rss rr2zMatcherAdapter.__init__s  rkeyc`||ttdSr/)rsrGrn)r1rus r __getitem__zMatcherAdapter.__getitem__s'||CL 1 1 3 34555rctr/NotImplementedErrorr4s r__iter__zMatcherAdapter.__iter__!###rctr/ryr4s r__len__zMatcherAdapter.__len__r|r) rrrr6rr(rWr2rwrr{r)r~rrrrrrrsNN# 5$6s6t6666$(3-$$$$$$$$$$$rrrcreZdZdZdZdejddfdZede ddfdZ d e e ge fde fd Z dS) r zwA compiled match expression as used by -k and -m. The expression can be evaluated against different matchers. coderr-Nc||_dSr/r)r1rs rr2zExpression.__init__s  rr;c|tt|}t|dd}t|S)z\Compile a match expression. :param input: The input expression - one line. zeval)filenamemode)r`r8compiler )r1r;astexprrs rrzExpression.compilesD WU^^,,& 0    $rrscPt|jdiit|}|S)a Evaluate the match expression. :param matcher: Given an identifier, should return whether it matches or not. Should be prepared to handle arbitrary strings as input. :returns: Whether the expression matches or not. __builtins__)rrrr)r1rsr_s revaluatezExpression.evaluates)^R$8.:Q:QRR r)rrrr6r&typesCodeTyper2 classmethodr(rrrWrrrrr r s IU^  S  \    [   # 5 $      r)#r6r] dataclassesenumrHsysrtypingrrrrrr version_infoConstantr[ NameConstant__all__Enumr dataclassr" Exceptionr r8rnr r`r\rbrhr(rWrrrrrrs   vlOO&O   d###       $#  : : : : : : : :7 7 7 7 7 7 7 7 z :':cn::::GCH A ACH A A A A $ $ $ $ $WS$Y' $ $ $ ##########r