
    :                     Z    S r SSKJr  SSKJr  SSKJr  S rS rS rS rSS	 jr	S
 r
S rg)z<Contains some functions that come in handy with XML parsing.    )absolute_import)division)unicode_literalsc                 @    U R                   R                  SS5      S   $ )zStrips namespace prefix.}   )tagrsplitnodes    6lib/googlecloudsdk/appengine/tools/xml_parser_utils.pyGetTagr      s    	a	 	$$    c                 N    [        U 5       H  n[        U5      U:X  d  M  Us  $    g)z%Returns first child of node with tag.N)listr   )r   r
   childs      r   GetChildr      s!    Dzee}l r   c                 (    U R                  5       S;   $ )N)1true)lower)	node_texts    r   BooleanValuer   "   s    		m	++r   c                 :    U R                   R                  US5      $ )z7Wrapper function to retrieve attributes from XML nodes. )attribget)r   attrs     r   GetAttributer    &   s    	r	""r   c                 t    [        U 5       H(  n[        U5      U:X  d  M  [        U5      =(       d    Us  $    U$ )z;Finds child xml node with desired tag and returns its text.)r   r   GetNodeText)r   	child_tagdefaultr   s       r   GetChildNodeTextr%   +   s3    Dzee}	!*7*  
.r   c                 \    U R                   (       a  U R                   R                  5       $ S$ )z1Returns the node text after stripping whitespace.r   )textstripr   s    r   r"   r"   3   s      #ii	/R/r   c                 .   ^ U4S j[        U 5       5       $ )z1Gets all children of a node with the desired tag.c              3   J   >#    U  H  n[        U5      T:X  d  M  Uv   M     g 7f)N)r   ).0r   	match_tags     r   	<genexpr>GetNodes.<locals>.<genexpr>;   s     	FZE6%=I+E%%Zs   #	#)r   )r   r,   s    `r   GetNodesr/   9   s    	FT$Z	FFr   N)r   )__doc__
__future__r   r   r   r   r   r   r    r%   r"   r/    r   r   <module>r3      s8    C &  '%
,#
0Gr   