
    d                        d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlZddlm	Z	 ddl
mZ ddl
mZ dd	l
mZ dd
lmZ ddlmZ ddlZd:dZd Zd;dZd Zd Zd Z G d de      Z ej4                  ej6                         G d de             Z G d de      Z G d de      Z G d de      Z G d de      Z  G d de      Z! G d  d!e      Z" G d" d#e      Z# ej4                  ej6                         G d$ d%e             Z$ G d& d'e$      Z% G d( d)e$      Z& G d* d+e$      Z' G d, d-e'      Z( G d. d/e'      Z) G d0 d1e)      Z* G d2 d3e$      Z+ G d4 d5e$      Z, G d6 d7e$      Z- G d8 d9e$      Z.y)<z8Cloud resource list filter expression evaluator backend.    )absolute_import)division)unicode_literalsN)log)resource_exceptions)resource_lex)resource_property)encoding)timesc                     	 t        j                  | |      S # t         j                  $ r*}t        j                  dj                  | |            d}~ww xY w)zReturns a compiled RE pattern.

  Args:
    pattern: The RE pattern string.
    flags: Optional RE flags.

  Raises:
    ExpressionSyntaxError: RE pattern error.

  Returns:
    The compiled RE.
  z%Filter expression RE pattern [{}]: {}N)recompileerrorr   ExpressionSyntaxErrorformat)patternflagses      1lib/googlecloudsdk/core/resource/resource_expr.py
_ReCompiler   $   sT    D::gu%%	 D

3
3/66wBD DDs    A%AAc                     | yt        | t        j                        st        |       } t        j                  t        j                  |             S )z4Returns the unicode string representation for value.null)
isinstancesixstring_typesrepr	text_typer
   Decodevalues    r   
_Stringizer!   8   s;    
]	E3++	,KE	xu-	..    c                     t        |       j                         }|rt        j                  dd|      }dj	                  t        j                  d|      D cg c]  }t        j                  |      s| c}      S c c}w )a$  Returns lowercase unicode NFKD form with accents stripped.

  Args:
    value: The value to be normalized.
    html: If True the value is HTML text and HTML tags are converted to spaces.

  Returns:
    The normalized unicode representation of value suitable for cloud search
    matching.
  z<[^>]*> NFKD)r!   lowerr   subjoinunicodedata	normalize	combining)r    htmltextcs       r   NormalizeForSearchr/   A   sw     
E		 	 	"$	66)R&D	[2264@ 3@$..q1 @ 3 
4 4 3s   A;c                     t        | t              st        | t              r| S 	 t        |       S # t        $ r t        |       cY S w xY w)z-Returns value converted to int or float type.)r   intfloat
ValueErrorr   s    r   _NumericTyper4   V   sD     sz%7Lu:	 <s   
/ AAc           	      |   |\  }}}t        |t        t        f      rd	 |t        |      k(  ry	 |dk(  r|j                         dk(  ry|dk(  r|j                         dk(  ryt        j                  ddt        |            }	n||k(  ry||d	v ry|d
k(  r|dk(  ryd}	n||rmt        |t        j                  j                        rI	 |j                  rt        j                  nd}
|t        j                  ||
      k(  ry	 t!        |d      }	nt!        |d      }	t#        |j%                  |	            }|s|S t#        |j%                  |	            }t'        |      dk(  r6|d   dv r/|t#        |j%                  |	j)                  d      d               z  }||k7  rd|rbt+        | |d      sUt-        | |d       |rdnd}|rdnd}t/        j0                  dj3                  t5        j6                  |      ||||             |S # t        $ r Y w xY w# t        t        j                  t        j                  f$ r Y =w xY w)a'  Returns True if value word matches pattern.

  Args:
    backend: The parser backend object.
    key: The parsed expression key.
    op: The expression operator string.
    warned_attribute: Deprecation warning Boolean attribute name.
    value: The value to be matched by pattern.
    pattern: An (operand, standard_regex, deprecated_regex) tuple.

  Raises:
    ValueError: To catch codebase reliance on deprecated usage.

  Returns:
    True if pattern matches value.

  Examples:
    See surface/topic/filters.py for a table of example matches.
  Tr   false   truez\.0*$r$   N)r$   N*:Fr   tzinfo)r,   )zoneregion/matcheszdoes not matchz
will matchzwill not matchz--filter : operator evaluation is changing for consistency across Google APIs.  {key}{op}{operand} currently {old_match} but {new_match} in the near future.  Run `gcloud topic filters` for details.)keyopoperand	old_match	new_match)r   r1   r2   r4   r3   r&   r   r'   r!   r   datetimer<   LOCALParseDateTimeDateTimeSyntaxErrorDateTimeValueErrorr/   boolsearchlensplitgetattrsetattrr   warningr   r   
GetKeyName)backendrB   rC   warned_attributer    r   rD   standard_regexdeprecated_regexr-   r<   matcheddeprecated_matchedrE   rF   s                  r   _MatchOneWordInTextrZ   a   sD   ( /6+'>+U|$	,w'	' 
( zgmmo0zgmmo/66(B
5 12D}*#~")D:eU^^%<%<=#llu{{f	%%%gf=	= 
> e$/De$/D &&t,-'	N,33D9: 	X]s1v!33$/66tzz#r7JKLL##(8
'+U
3G%t,/	5EI '-=IKK 6 7=f$//4#'' 7= 7)* 
u  
* 1153K3KL 
s#   G? 8H ?	HH(H;:H;c           
      t   t        |t              rOd}g }|re|j                  t        j                  |             |j                  t        j
                  |             nt        |t        t        f      r|}n|g}t        |t        t        f      r|}n|h}|D ]  }|D ]  }	t        | |||||	      s  y  y)a  Applies _MatchOneWordInText to determine if value matches pattern.

  Both value and operand can be lists.

  Args:
    backend: The parser backend object.
    key: The parsed expression key.
    op: The expression operator string.
    warned_attribute: Deprecation warning Boolean attribute name.
    value: The key value or list of values.
    pattern: Pattern value or list of values.

  Returns:
    True if the value (or any element in value if it is a list) matches pattern
    (or any element in operand if it is a list).
  NTF)	r   dictextendr   iterkeys
itervalueslisttuplerZ   )
rT   rB   rC   rU   r    r   valuespatternsvps
             r   
_WordMatchrf      s    " t FmmCLL'(mmCNN5)*%$'FWF$'HyHa	Wc2/?A	F   
r"   c                       e Zd ZdZd Zd Zd Zd Zd Zd Z	dd	Z
dd
ZddZddZddZddZddZddZddZd Zy)Backenda  Cloud resource list filter expression evaluator backend.

  This is a backend for resource_filter.Parser(). The generated "evaluator" is a
  parsed resource expression tree with branching factor 2 for binary operator
  nodes, 1 for NOT and function nodes, and 0 for TRUE nodes. Evaluation for a
  resource object starts with expression_tree_root.Evaluate(obj) which
  recursively evaluates child nodes. The logic operators use left-right shortcut
  pruning, so an evaluation may not visit every node in the expression tree.
  c                     t        |       S N)	_ExprTRUEselfs    r   ExprTRUEzBackend.ExprTRUE   s    T?r"   c                     t        | ||      S rj   )_ExprANDrm   leftrights      r   ExprANDzBackend.ExprAND   s    D$&&r"   c                     t        | ||      S rj   )_ExprORrq   s      r   ExprORzBackend.ExprOR   s    4u%%r"   c                     t        | |      S rj   )_ExprNOT)rm   exprs     r   ExprNOTzBackend.ExprNOT   s    D$r"   c                     t        | |      S rj   )_ExprGlobal)rm   calls     r   
ExprGlobalzBackend.ExprGlobal   s    tT""r"   c                     t        | |      S rj   )_ExprOperand)rm   r    s     r   ExprOperandzBackend.ExprOperand   s    e$$r"   Nc                     t        | |||      S rj   )_ExprLTrm   rB   rD   	transforms       r   ExprLTzBackend.ExprLT       4gy11r"   c                     t        | |||      S rj   )_ExprLEr   s       r   ExprLEzBackend.ExprLE  r   r"   c                     t        | |||      S )a  Case insensitive membership node.

    This is the pre-compile Expr for the ':' operator. It compiles into an
    _ExprHAS node for prefix*suffix matching.

    The * operator splits the operand into prefix and suffix matching strings.

    Args:
      key: Resource object key (list of str, int and/or None values).
      operand: The term ExprOperand operand.
      transform: Optional key value transform calls.

    Returns:
      _ExprHAS.
    )_ExprHASr   s       r   ExprHASzBackend.ExprHAS  s      D#w	22r"   c                     t        | |||      S )zCase sensitive EQ node.

    Args:
      key: Resource object key (list of str, int and/or None values).
      operand: The term ExprOperand operand.
      transform: Optional key value transform calls.

    Returns:
      _ExprEQ.
    )_ExprEQr   s       r   ExprEQzBackend.ExprEQ  s     4gy11r"   c                     t        | |||      S rj   )_ExprNEr   s       r   ExprNEzBackend.ExprNE$  r   r"   c                     t        | |||      S rj   )_ExprGEr   s       r   ExprGEzBackend.ExprGE'  r   r"   c                     t        | |||      S rj   )_ExprGTr   s       r   ExprGTzBackend.ExprGT*  r   r"   c                     t        | |||      S rj   )_ExprREr   s       r   ExprREzBackend.ExprRE-  r   r"   c                     t        | |||      S rj   )
_ExprNotREr   s       r   	ExprNotREzBackend.ExprNotRE0  s    dC)44r"   c                      yNF rl   s    r   
IsRewriterzBackend.IsRewriter3  s    r"   rj   )__name__
__module____qualname____doc__rn   rt   rw   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r"   r   rh   rh      sW    '& #%223$222225r"   rh   c                   J    e Zd ZdZd Zej                  d        Zed        Z	y)_ExprzExpression base class.c                     || _         y rj   )rT   )rm   rT   s     r   __init__z_Expr.__init__>  s	    DLr"   c                      y)zReturns the value of the subexpression applied to obj.

    Args:
      obj: The current resource object.

    Returns:
      True if the subexpression matches obj, False if it doesn't match, or
      None if the subexpression is not supported.
    Nr   rm   objs     r   Evaluatez_Expr.EvaluateA       	r"   c                      yr   r   rl   s    r   contains_keyz_Expr.contains_keyN  s    r"   N)
r   r   r   r   r   abcabstractmethodr   propertyr   r   r"   r   r   r   :  s8     
	 
	  r"   r   c                       e Zd ZdZd Zy)rk   z'TRUE node.

  Always evaluates True.
  c                      yNTr   )rm   
unused_objs     r   r   z_ExprTRUE.EvaluateY  s    r"   Nr   r   r   r   r   r   r"   r   rk   rk   S  s    
r"   rk   c                   "     e Zd ZdZ fdZ xZS )_ExprLogicalziBase logical operator node.

  Attributes:
    left: Left Expr operand.
    right: Right Expr operand.
  c                 H    t         t        |   |       || _        || _        y rj   )superr   r   _left_right)rm   rT   rr   rs   	__class__s       r   r   z_ExprLogical.__init__e  s     	,&w/DJDKr"   )r   r   r   r   r   __classcell__r   s   @r   r   r   ]  s     r"   r   c                       e Zd ZdZd Zy)rp   z8AND node.

  AND with left-to-right shortcut pruning.
  c                 t    | j                   j                  |      sy| j                  j                  |      syy)NFTr   r   r   r   s     r   r   z_ExprAND.Evaluateq  s/    ::s#;;$r"   Nr   r   r"   r   rp   rp   k  s    
r"   rp   c                       e Zd ZdZd Zy)rv   z6OR node.

  OR with left-to-right shortcut pruning.
  c                 t    | j                   j                  |      ry| j                  j                  |      ryy)NTFr   r   s     r   r   z_ExprOR.Evaluate  s/    zz3{{C r"   Nr   r   r"   r   rv   rv   y  s    
r"   rv   c                   (     e Zd ZdZ fdZd Z xZS )ry   z	NOT node.c                 :    t         t        |   |       || _        y rj   )r   ry   r   _expr)rm   rT   rz   r   s      r   r   z_ExprNOT.__init__  s    	(D"7+DJr"   c                 :    | j                   j                  |       S rj   )r   r   r   s     r   r   z_ExprNOT.Evaluate  s    zz""3'''r"   r   r   r   r   r   r   r   r   s   @r   ry   ry     s    (r"   ry   c                   (     e Zd ZdZ fdZd Z xZS )r}   z]Global restriction function call node.

  Attributes:
    _call: The function call object.
  c                 :    t         t        |   |       || _        y rj   )r   r}   r   _call)rm   rT   r~   r   s      r   r   z_ExprGlobal.__init__  s    	+t%g.DJr"   c                 8    | j                   j                  |      S rj   )r   r   r   s     r   r   z_ExprGlobal.Evaluate  s    ::s##r"   r   r   s   @r   r}   r}     s    $r"   r}   c                   *    e Zd ZdZdddZddZddZy)	r   a  Operand node.

  Converts an expession value token string to internal string and/or numeric
  values. If an operand has a numeric value then the actual key values are
  converted to numbers at Evaluate() time if possible for Apply(); if the
  conversion fails then the key and operand string values are passed to Apply().

  Attributes:
    list_value: A list of operands.
    numeric_value: The int or float number, or None if the token string does not
      convert to a number.
    string_value: The token string.
  r   r7   )r6   r8   Nc                 p    || _         d | _        d| _        d | _        d | _        | j                  ||       y )NFr*   )rT   
list_valuenumeric_constantnumeric_valuestring_value
Initialize)rm   rT   r    r*   s       r   r   z_ExprOperand.__init__  s8    DLDO!DDDOOEYO/r"   c                    t        |t              r@g | _        |D ]3  }| j                  j                  t	        | j
                  ||             5 y|r|r ||      | _        yt        |t        j                        r2|| _        	 | j                  |j                            | _        d| _        yt!        |      | _        || _        y# t        $ r& 	 t        |      | _        n# t        $ r Y nw xY wY yY yw xY w)zInitializes an operand string_value and numeric_value from value.

    Args:
      value: The operand expression string value.
      normalize: Optional normalization function.
    r   TN)r   r`   r   appendr   rT   r   r   r   _NUMERIC_CONSTANTSr&   r   r   KeyErrorr4   r3   r!   )rm   r    r*   vals       r   r   z_ExprOperand.Initialize  s     %do#si@	B  
9#E*d	E3++	,d!44U[[]C $ %U+d d  	+E2$
 	
	
 s6   )C 	C6C"!C6"	C.+C6-C..C65C6rj   )r   r   r   r   r   r   r   r   r"   r   r   r     s!     
0!r"   r   c                       e Zd ZdZej
                  j                  ej
                  j                  ej
                  j                  ej
                  j                  fZ
 fdZd Zed        Zed        Zd Zej$                  d        Z xZS )_ExprOperatora  Base term (<key operator operand>) node.

  ExprOperator subclasses must define the function Apply(self, value, operand)
  that returns the result of <value> <op> <operand>.

  Attributes:
    _key: Resource object key (list of str, int and/or None values).
    _normalize: The resource value normalization function.
    _operand: The term ExprOperand operand.
    _transform: Optional key value transform calls.
    key : Property decorator for the resource object key.
  c                     t         t        |   |       || _        || _        || _        |r	d | _        y | j                  | _        y )Nc                     | S rj   r   xs    r   <lambda>z(_ExprOperator.__init__.<locals>.<lambda>  s    !r"   )r   r   r   _key_operand
_transform
_normalizeInitializeNormalizationrm   rT   rB   rD   r   r   s        r   r   z_ExprOperator.__init__  s>    	-'0DIDMDO#do44dor"   c                    d | _         t        j                  d|      r	 t        j                  |      }|j
                  rt        j                  nd| j                  j                  | j                  j                  xs | j                  j                  fd       t        j                  | _         |S |S # t        $ r Y |S w xY w)a  Checks the first non-empty resource value to see if it can be normalized.

    This method is called at most once on the first non-empty resource value.
    After that a new normalization method is set for the remainder of the
    resource values.

    Resource values are most likely well defined protobuf string encodings. The
    RE patterns match against those.

    Args:
      value: A resource value to normalize.

    Returns:
      The normalized value.
    c                     | S rj   r   r   s    r   r   z7_ExprOperator.InitializeNormalization.<locals>.<lambda>
  s    r"   z$\d\d\d\d-\d\d-\d\d[ T]\d\d:\d\d:\d\dNc                 2    t        j                  |       S )Nr;   )r   rI   )r   r<   s    r   r   z7_ExprOperator.InitializeNormalization.<locals>.<lambda>  s     3 3Af Er"   r   )r   r   matchr   rI   r<   rH   r   r   r   r   r3   )rm   r    r<   s     @r   r   z%_ExprOperator.InitializeNormalization  s      "DO 
xx7?
##E* !&$  MM$$B(B(BE 	! 	G  -- L5L   Ls   BB9 9	CCc                      yr   r   rl   s    r   r   z_ExprOperator.contains_key  s    r"   c                     | j                   S rj   )r   rl   s    r   rB   z_ExprOperator.key#  s    99r"   c           	      ^   t        j                  || j                        }| j                  r| j                  j	                  |      }|rt        |t        t        f      r|}n|g}g }|D ]'  }|r	 | j                  |      }|j                  |       ) | j                  j                  r| j                  j                  }n| j                  g}|D ]  }|D ]  }|j                  7	 | j                  t!        |      |j                        r  y|j"                  sE	 |s!t        |j$                  | j&                        ri	 | j                  ||j$                        r  y  y# t        t        f$ r Y w xY w# t        t        f$ r Y nw xY w# t(        t        f$ r Y t        $ r |Nt        |t*        j,                  t.        t        f      s)| j                  t1        |      |j$                        rY   yt*        j2                  r"| | j                  d|j$                        rY   yY Vw xY w)zEvaluate a term node.

    Args:
      obj: The resource object to evaluate.
    Returns:
      The value of the operator applied to the key value and operand.
    Tr$   F)r	   Getr   r   r   r   r`   ra   r   	TypeErrorr3   r   r   r   r   Applyr4   r   r   _TIME_TYPESAttributeErrorr   r   r\   r!   PY3)rm   r   r    resource_valuesrb   operandsrD   s          r   r   z_ExprOperator.Evaluate'  s    !!#tyy1Eoo&&u-eED%=1ooF 		//%(% mmE ! }}))h--h '   ,zz,u-w/D/DE++ ,
 G$8$8$:J:JK
	ZZw334 5#  H ] :& 	
	* Z(  
+ 	
 	 )9)94(FG**Z.0D0DEgg-**R!5!56	sI   0E#%%E8E8?F#E54E58F
	F
H,AH,6.H,+H,c                      y)zReturns the value of applying a <value> <operator> <operand> term.

    Args:
      value: The term key value.
      operand: The term operand value.

    Returns:
      The Boolean value of applying a <value> <operator> <operand> term.
    Nr   rm   r    rD   s      r   r   z_ExprOperator.Applyl  r   r"   )r   r   r   r   r   rG   datetime	timedeltar<   r   r   r   r   r   rB   r   r   r   r   r   r   s   @r   r   r     s     nnnnnnnn	+5#J    CJ 
	 
	r"   r   c                       e Zd ZdZd Zy)r   zLT node.c                     ||k  S rj   r   r   s      r   r   z_ExprLT.Apply}      7?r"   Nr   r   r   r   r   r   r"   r   r   r   z  
    r"   r   c                       e Zd ZdZd Zy)r   zLE node.c                     ||k  S rj   r   r   s      r   r   z_ExprLE.Apply      Gr"   Nr  r   r"   r   r   r     
    r"   r   c                   R     e Zd ZdZ	 	 d fd	Zej                  d        Zd Z xZ	S )_ExprWordMatchBasez${ HAS EQ NE } word match base class.c                    t         t        |   ||||       || _        || _        g | _        | j                  j                  U| j                  j                  D ];  }|j                  |j                  |_        | j                  |j                         = y | j                  j                  7|j                  |_        | j                  | j                  j                         y y rj   )
r   r  r   _op_warned_attribute	_patternsr   r   r   _AddPattern)rm   rT   rB   rD   r   rC   rU   r   s          r   r   z_ExprWordMatchBase.__init__  s    	
d,Wc7INDH-DDN}}+]]--'+!(!5!5'



7//
0 . 
	#	#	/$11g
t}}112 
0r"   c                      y)z,Adds a word match pattern to self._patterns.Nr   )rm   r   s     r   r  z_ExprWordMatchBase._AddPattern  s     	r"   c                     t        | j                  | j                  | j                  | j                  || j
                        S )aQ  Checks if value word matches operand ignoring case differences.

    Args:
      value: The number, string, dict or list object value.
      operand: Non-pattern operand for equality check. The ':' HAS operator
        operand can be a prefix*suffix pattern or a literal value. Literal
        values are first checked by the _Equals method to handle numeric
        constant matching. String literals and patterns are then matched by the
        _Has method.

    Returns:
      True if value HAS matches operand (or any value in operand if it is a
      list) ignoring case differences.
    )rf   rT   r   r  r  r  r   s      r   r   z_ExprWordMatchBase.Apply  s4     dllDIItxx9O9OT^^- -r"   )NN)
r   r   r   r   r   r   r   r  r   r   r   s   @r   r  r    s0    ,:> $3  	 	-r"   r  c                   (     e Zd ZdZ fdZd Z xZS )r   zHAS word match node.c                 8    t         t        |   ||||dd       y )Nr:   _deprecated_has_warnedrC   rU   )r   r   r   r   s        r   r   z_ExprHAS.__init__  s%    	(D"7C)4L # Nr"   c                    |dk(  rd}d}nMd}d}d}t        |      }|j                  d      }t        |      dkD  r$t        j                  dj                  |            |j                  d      r|dd }d}t        j                  |      }	||	z   |z   }t        |      d	k(  r|j                  d       n*|j                  d      rd}n|j                  d      rd}nd
}|d   rt        j                  |d         nd}
|d	   rt        j                  |d	         nd}|r|r|rd|
z   |z   |z   dz   }n'|
|z   |z   }n|rd|
z   |z   |z   }n|r|
|z   |z   dz   }nd}t        j                  t        j                  z  t        j                  z  }t        ||      }|rt        ||      }nd}| j                  j                  |||f       y)ah  Adds a HAS match pattern to self._patterns.

    A pattern is a word that optionally contains one trailing * that matches
    0 or more characters.

    This method re-implements both the original and the OnePlatform : using REs.
    It was tested against the original tests with no failures.  This cleaned up
    the code (really!) and made it easier to reason about the two
    implementations.

    Args:
      pattern: A string containing at most one trailing *.

    Raises:
      resource_exceptions.ExpressionSyntaxError if the pattern contains more
        than one leading or trailing * glob character.
    r9   .N\br$      z*At most one * expected in : patterns [{}].r@   r7   z.*r   ^$)r/   rO   rN   r   r   r   endswithr   escaper   
startswith
IGNORECASE	MULTILINEUNICODEr   r  )rm   r   standard_patterndeprecated_patternheadglobtailnormalized_patternpartswordrr   rs   reflagsrV   rW   s                  r   r  z_ExprHAS._AddPattern  s   $ #~ddd-g6 &&s+e	Ua!778??HJ 	J 
	$	$S	)/4YY)*dt+ 
UqRc"C $)!HRYYuQx "d%*1Xbiia!2e	$"TzD0583>
#d{U2
 D[4/%7!D[5036!mmBLL(3G 0':N#$6@NN7N4DEFr"   r   r   r   r   r   r  r   r   s   @r   r   r     s    NCGr"   r   c                   *     e Zd ZdZd fd	Zd Z xZS )r   zEQ word match node.c                 @    t         t        |   |||||xs dd       y )N=_deprecated_eq_warnedr  )r   r   r   )rm   rT   rB   rD   r   rC   r   s         r   r   z_ExprEQ.__init__  s*    	'4!'3%'Y33J " Lr"   c                 4   t        |      }t        j                  |      }d|z   dz   }d|z   dz   }t        j                  t        j                  z  t        j
                  z  }t        ||      }t        ||      }| j                  j                  |||f       y)a  Adds an EQ match pattern to self._patterns.

    A pattern is a word.

    This method re-implements both the original and the OnePlatform = using REs.
    It was tested against the original tests with no failures.  This cleaned up
    the code (really!) and made it easier to reason about the two
    implementations.

    Args:
      pattern: A string containing a word to match.
    r  r  r  N)	r/   r   r  r   r!  r"  r   r  r   )	rm   r   r(  r*  r#  r$  r+  rV   rW   s	            r   r  z_ExprEQ._AddPattern  s     ,G499'(D t|e+ tc)mmBLL(3G 0':N!"4g>NN7N4DEFr"   rj   r,  r   s   @r   r   r      s    L
Gr"   r   c                   ,     e Zd ZdZ fdZ fdZ xZS )r   zNE node.c                 6    t         t        |   ||||d       y )Nz!=)rC   )r   r   r   r   s        r   r   z_ExprNE.__init__'  s    	'4!'3t!Lr"   c                 .    t         t        |   ||       S rj   )r   r   r   )rm   r    rD   r   s      r   r   z_ExprNE.Apply*  s    Wd)%999r"   r   r   r   r   r   r   r   r   s   @r   r   r   $  s    M: :r"   r   c                       e Zd ZdZd Zy)r   zGE node.c                     ||k\  S rj   r   r   s      r   r   z_ExprGE.Apply1  r  r"   Nr  r   r"   r   r   r   .  r	  r"   r   c                       e Zd ZdZd Zy)r   zGT node.c                     ||kD  S rj   r   r   s      r   r   z_ExprGT.Apply8  r  r"   Nr  r   r"   r   r   r   5  r  r"   r   c                   (     e Zd ZdZ fdZd Z xZS )r   zUnanchored RE match node.c                 z    t         t        |   ||||       t        | j                  j
                        | _        y rj   )r   r   r   r   r   r   r   r   s        r   r   z_ExprRE.__init__?  s.    	'4!'3Cdmm889DLr"   c                     t        |t        j                        st        d      | j                  j                  |      d uS Nz(RE match subject value must be a string.r   r   r   r   r   rM   rm   r    unused_operands      r   r   z_ExprRE.ApplyC  s8    eS--.@AA<<u%T11r"   r5  r   s   @r   r   r   <  s    !:2r"   r   c                   (     e Zd ZdZ fdZd Z xZS )r   zUnanchored RE not match node.c                 z    t         t        |   ||||       t        | j                  j
                        | _        y rj   )r   r   r   r   r   r   r   r   s        r   r   z_ExprNotRE.__init__M  s.    	*d$Wc7IFdmm889DLr"   c                     t        |t        j                        st        d      | j                  j                  |      d u S r=  r>  r?  s      r   r   z_ExprNotRE.ApplyQ  s8    eS--.@AA<<u%--r"   r5  r   s   @r   r   r   J  s    %:.r"   r   )r   )F)/r   
__future__r   r   r   r   r   r)   googlecloudsdk.corer   googlecloudsdk.core.resourcer   r   r	   googlecloudsdk.core.utilr
   r   r   r   r!   r/   r4   rZ   rf   objectrh   add_metaclassABCMetar   rk   r   rp   rv   ry   r}   r   r   r   r   r  r   r   r   r   r   r   r   r   r"   r   <module>rK     s    ? &  ' 
 	  # < 5 : - * 
D(/4*Sl&RTf Tt 3;;F   0 5 | l (u ($% $6!6 6!r 3;;\	E \	  \	~m m (- (-VJG! JGZ!G  !GH:g :m m 2m 2. .r"   