
    ij4                     b   U d Z ddlmZmZ ddlZddlZddlZddlZddlZddl	m
Z
mZ ddlmZ dZeed<   dZeed	<   d
Zeed<    ej(                  d      Z eej.                  e         hZee   ed<   dZe
ed<   dZej:                  dz  ed<    G d de      Zdee e
f   dedz  fdZ!defdZ"de fdZ#dejH                  de de
dejJ                  fdZ&defdZ'de dee    de(e    fdZ)d Z*	 	 	 d+d e d!edz  d"e d#e dz  de f
d$Z+	 d,d%ee e
f   d&ee    dz  dee    fd'Z,d(e de fd)Z-de de fd*Z.y)-z:Internal helper functions for Abseil Python flags library.    )IterableSequenceN)Any
NamedTuple)minidomP   _DEFAULT_HELP_WIDTH(   _MIN_HELP_WIDTHg      ? _SUGGESTION_ERROR_RATE_THRESHOLDu    [ -----￾￿]disclaim_module_idsSPECIAL_FLAGSFLAGS_MODULEc                   :    e Zd ZU dZej
                  ed<   eed<   y)_ModuleObjectAndNamezkModule object and name.

  Fields:
  - module: object, module object.
  - module_name: str, module name.
  modulemodule_nameN)__name__
__module____qualname____doc__types
ModuleType__annotations__str     h/var/www/html/emotional.easysim.app/public_html/venv/lib/python3.12/site-packages/absl/flags/_helpers.pyr   r   F   s     

r   r   globals_dictreturnc                     	 | d   }t         j                  |   }t        ||dk(  rt         j                  d         S |      S # t        $ r Y yw xY w)aF  Returns the module that defines a global environment, and its name.

  Args:
    globals_dict: A dictionary that should correspond to an environment
      providing the values of the globals.

  Returns:
    _ModuleObjectAndName - pair of module object & module name.
    Returns None if the module could not be identified.
  r   N__main__r   )sysmodulesKeyErrorr   argv)r   namer   s      r   get_module_object_and_namer(   R   sc    
#D[[F 
TZ/chhqk
 59
  
 s   A 	AAc                      t        dt        j                               D ]N  } t        j                  |       j                  }t        |      }|0t        |j                        t        vsL|c S  t        d      )a)  Returns the module that's calling into this module.

  We generally use this function to get the name of the module calling a
  DEFINE_foo... function.

  Returns:
    The module object that called into this one.

  Raises:
    AssertionError: Raised when no calling module could be identified.
     zNo module was found)
ranger#   getrecursionlimit	_getframe	f_globalsr(   idr   r   AssertionError)depthglobals_for_framer   s      r   "get_calling_module_object_and_namer3   j   so     Q--/0 e e,66'(9:Fb/7JJm 	,--r   c                  *    t               j                  S )z?Returns the name of the module that's calling into this module.)r3   r   r   r   r   get_calling_moduler5      s    	+	-	9	99r   docr'   valuec                     t        |      }t        |t              r|j                         }t        j                  d|      }| j                  |      }|j                  | j                  |             |S )a  Returns an XML DOM element with name and text value.

  Args:
    doc: minidom.Document, the DOM document it should create nodes from.
    name: str, the tag of XML element.
    value: object, whose string representation will be used as the value of the
      XML element. Illegal or highly discouraged xml 1.0 characters are
      stripped.

  Returns:
    An instance of minidom.Element.
   )	r   
isinstanceboollower_ILLEGAL_XML_CHARS_REGEXsubcreateElementappendChildcreateTextNode)r6   r'   r7   ses        r   create_xml_dom_elementrD      s`      
%j!t		A""2q)!	!--""1%&	
(r   c                  R    t        j                  t        df      } | j                  S )zAReturns the integer width of help lines that is used in TextWrap.r*   )fallback)shutilget_terminal_sizer	   columns)sizes    r   get_help_widthrK      s"    		!	!,?+C	D$	r   attemptlongopt_listc                 v   t        |       dk  s|sg S |D cg c]  }|j                  d      d    }}|D cg c]  }t        | |dt        |              |f }}|j                          |d   \  }}|t        t        |       z  k\  rg S g }|D ]  \  }	}
|	|k(  r|j                  |
        |S  |S c c}w c c}w )z4Returns helpful similar matches for an invalid flag.   =r   )lensplit_damerau_levenshteinsortr   append)rL   rM   voption_namesoption	distancesleast_errors_suggestionserrorsr'   s              r   get_flag_suggestionsr^      s    
 	\QlI+78a!''#,q/8,8 !
 GVAG%=>G) 
 ..aL/,5GDDI+ lfd	
 
- 9s
   B1!B6c                 (    i fd | |      S )z6Returns Damerau-Levenshtein edit distance from a to b.c           
      ~   | |fv r| |f   S | st        |      }n|st        |       }nt         | dd |      dz    | |dd       dz    | dd |dd       | d   |d   k7  z         }t        |       dk\  r=t        |      dk\  r/| d   |d   k(  r$| d   |d   k(  r | dd |dd       dz   }||kD  r|}|| |f<   |S )z5Recursively defined string distance with memoization.r*   Nr   rO   )rQ   min)xydtdistancememos       r   rf   z&_damerau_levenshtein.<locals>.distance   s    	1v~!Q$Z
a&a
a&a

1QR5!
q
 
1ae
q
 
1QR5!AB%
 AaDAaDL
1a
 
Q1Q111!A$!A$,QqrUAabE"Q&q5!DAJHr   r   )abrf   rg   s     @@r   rS   rS      s    	$. 
!Qr   textlengthindentfirstline_indentc                    |
t               }|d}||}t        |      |k\  rt        d      t        |      |k\  rt        d      | j                  d      } g }t	        j
                  |||      }t	        j
                  |||      }d | j                         D        D ]8  }|r!|j                  |j                  |             n|j                  d       |}: dj                  |      S )a:  Wraps a given text to a maximum line length and returns it.

  It turns lines that only contain whitespace into empty lines, keeps new lines,
  and expands tabs using 4 spaces.

  Args:
    text: Text to wrap.
    length: Maximum length of a line, includes indentation. If this is `None`
      then use `get_help_width()`.
    indent: Indent for all but first line.
    firstline_indent: Indent for first line. If `None`, fall back to `indent`.

  Returns:
    The wrapped text.

  Raises:
    ValueError: Raised if indent or firstline_indent not shorter than length.
  r9   zLength of indent exceeds lengthz*Length of first line indent exceeds length   )widthinitial_indentsubsequent_indentc              3   <   K   | ]  }|j                           y wN)strip).0ps     r   	<genexpr>ztext_wrap.<locals>.<genexpr>  s     9!AGGI9s   
)rK   rQ   
ValueError
expandtabstextwrapTextWrapper
splitlinesextendwraprU   join)rj   rk   rl   rm   resultwrappersubsequent_wrapper	paragraphs           r   	text_wrapr      s    2 ^F^F[F
6
77	f$
A
BB		$&   #3v'  ++6V :t'89 !immGLL+,mmB G! 
6	r   flag_mapmulti_flagsc              #   z  K   | j                         D ]  \  }}|d|  t        |t              r|rd|  *d|  2t        |t        t        f      rd| d|  S	 |r||v r|D ]  }d| d|   n d| ddj                  d |D                 y# t        $ r d| d|  Y w xY ww)a2  Convert a dict of values into process call parameters.

  This method is used to convert a dictionary into a sequence of parameters
  for a binary that parses arguments using this module.

  Args:
    flag_map: dict, a mapping where the keys are flag names (strings).
        values are treated according to their type:

        * If value is ``None``, then only the name is emitted.
        * If value is ``True``, then only the name is emitted.
        * If value is ``False``, then only the name prepended with 'no' is
          emitted.
        * If value is a string then ``--name=value`` is emitted.
        * If value is a collection, this will emit
          ``--name=value1,value2,value3``, unless the flag name is in
          ``multi_flags``, in which case this will emit
          ``--name=value1 --name=value2 --name=value3``.
        * Everything else is converted to string an passed as such.

    multi_flags: set, names (strings) of flags that should be treated as
      multi-flags.

  Yields:
    sequence of string suitable for a subprocess execution.
  Nz--z--norP   ,c              3   2   K   | ]  }t        |        y wrt   )r   )rv   items     r   rx   z$flag_dict_to_args.<locals>.<genexpr>W  s     #@$CI#@s   )itemsr:   r;   bytesr   r   	TypeError)r   r   keyr7   r   s        r   flag_dict_to_argsr   &  s     > NN$ !jc5}J	E4	 	3%jSEl	EE3<	(Qug!3+- $dse1TF##$ SE388#@%#@@AB
B%!&  !3%q  !s*   A$B;'8B"B;"B85B;7B88B;	docstringc                    | syd}| j                         j                         }|}|dd D ]6  }|j                         }|st        |t	        |      t	        |      z
        }8 |d   j                         g}||k  r,|dd D ]$  }|j                  ||d j                                & |r|d   s|j                          |r|d   s|r|d   s|j                  d       |r|d   sdj                  |      S )a  Removes indentation from triple-quoted strings.

  This is the function specified in PEP 257 to handle docstrings:
  https://www.python.org/dev/peps/pep-0257/.

  Args:
    docstring: str, a python docstring.

  Returns:
    str, docstring with indentation removed.
  r9   i    r*   Nr   ry   )
r{   r~   lstripra   rQ   ru   rU   rstrippopr   )r   
max_indentlinesrl   linestrippedtrimmeds          r   trim_docstringr   ]  s	    
 * 


 
+
+
-% &ABi 6d{{}H63t9s8}45f6
 1X^^'jab	 -nnT&']))+,- 	KKM 	
KKN 	
 
7	r   c                     | j                         } t        j                  dt        j                        }|j	                  d|       } t        |       } t        j                  dd| t        j                        } | S )z0Takes a __doc__ string and reformats it as help.z^[ 	]+$r9   z(?<=\S)\n(?=\S) )flags)ru   recompileMr>   r   )r6   whitespace_only_lines     r   doc_to_helpr     sd     			# J5  S)# 	s# 	!32448#	*r   )Nr9   Nrt   )/r   collections.abcr   r   r   rG   r#   r|   r   typingr   r   xml.domr   r	   intr   r   r   floatr   r=   r/   r$   r   r   setr   r   r   r   dictr   r(   r3   r5   DocumentElementrD   rK   listr^   rS   r   r   r   r   r   r   r   <module>r      s   A . 	  
   "   S    +/  % .
 &2::M  "$CKK$9!: ; SX ; s  )-e% ,	: 	sCx.D 0.,@ .,:C :
			!$-0__8  (	#YB@ #'	=
=$J= = Dj	=
 	=B >B4!38n4!+.s8d?4!c]4!n'c 'c 'TS S r   