o
    ^ôjïM  ã                   @   s  d Z ddlmZ ddlZddlZddlZddlmZmZm	Z	 ddl
mZ ddlmZ ddlmZ ddlmZ e	d	ƒZe	d
ejd�ZejG dd„ dee ƒƒZG dd„ dee ƒZG dd„ dee ƒZG dd„ dee ƒZG dd„ dee eee  ƒZG dd„ dee ƒZdS )zºContains Flag class - information about single command-line flag.

Do NOT import this module directly. Import the flags package and use the
aliases defined at the package level instead.
é    )ÚIterableN)ÚAnyÚGenericÚTypeVar)Úminidom)Ú_argument_parser)Ú_exceptions)Ú_helpersÚ_TÚ_ET)Úboundc                   @   s:  e Zd ZU dZedB ed< edB ed< edB eB ed< eje ed< 							dFdeje d	ej	e dB d
ededB eB dedB dedB de
de
de
de
de
de
ddfdd„ZededB fdd„ƒZejdedB fdd„ƒZdd„ Zdd„ Zdd„ Zd d!„ Zd"d#„ Zd$d%„ Zd&eeef dd'fd(d)„ZdedB dedB fd*d+„Zd,eeB ddfd-d.„Zd,eeB dedB fd/d0„ZdGd1d2„Zdefd3d4„ZdedB defd5d6„ZdedB eB ddfd7d8„ZdeeB dedB fd9d:„Z defd;d<„Z!	dHd=e"j#d>ed?e
de"j$fd@dA„Z%dedB defdBdC„Z&d=e"j#de'e"j$ fdDdE„Z(dS )IÚFlaga–	  Information about a command-line flag.

  Attributes:
    name: the name for this flag
    default: the default value for this flag
    default_unparsed: the unparsed default value for this flag.
    default_as_str: default value as repr'd string, e.g., "'true'" (or None)
    value: the most recent parsed value of this flag set by :meth:`parse`
    help: a help string or None if no help is available
    short_name: the single letter alias for this flag (or None)
    boolean: if 'true', this flag does not accept arguments
    present: true if this flag was parsed from command line flags
    parser: an :class:`~absl.flags.ArgumentParser` object
    serializer: an ArgumentSerializer object
    allow_override: the flag may be redefined without raising an error, and
      newly defined flag overrides the old one.
    allow_override_cpp: use the flag from C++ if available the flag definition
      is replaced by the C++ flag after init
    allow_hide_cpp: use the Python flag despite having a C++ flag with the same
      name (ignore the C++ flag)
    using_default_value: the flag value has not been set by user
    allow_overwrite: the flag may be parsed more than once without raising an
      error, the last set value will be used
    allow_using_method_names: whether this flag can be defined even if it has a
      name that conflicts with a FlagValues method.
    validators: list of the flag validators.

  The only public method of a ``Flag`` object is :meth:`parse`, but it is
  typically only called by a :class:`~absl.flags.FlagValues` object.  The
  :meth:`parse` method is a thin wrapper around the
  :meth:`ArgumentParser.parse()<absl.flags.ArgumentParser.parse>` method.  The
  parsed value is saved in ``.value``, and the ``.present`` attribute is
  updated.  If this flag was already present, an Error is raised.

  :meth:`parse` is also called during ``__init__`` to parse the default value
  and initialize the ``.value`` attribute.  This enables other python modules to
  safely use flags even if the ``__main__`` module neglects to parse the
  command line arguments.  The ``.present`` attribute is cleared after
  ``__init__`` parsing.  If the default value is set to ``None``, then the
  ``__init__`` parsing step is skipped and the ``.value`` attribute is
  initialized to None.

  Note: The default value is also presented to the user in the help
  string, so it is important that it be a legal value for this flag.
  NÚdefaultÚdefault_as_strÚdefault_unparsedÚparserFTÚ
serializerÚnameÚhelp_stringÚ
short_nameÚbooleanÚallow_overrideÚallow_override_cppÚallow_hide_cppÚallow_overwriteÚallow_using_method_namesÚreturnc                 C   s†   || _ |sd}|| _|| _|| _d| _|| _|| _|| _|	| _|
| _	|| _
|| _d| _d | _g | _| j	r<| jr<t d¡‚|  |¡ d S )Nú(no help available)r   TzsCan't have both allow_hide_cpp (means use Python flag) and allow_override_cpp (means use C++ flag after InitGoogle))r   Úhelpr   r   Úpresentr   r   r   r   r   r   r   Úusing_default_valueÚ_valueZ
validatorsr   ÚErrorÚ_set_default)Úselfr   r   r   r   r   r   r   r   r   r   r   r   © r%   úa/var/www/html/academy/tools/voices/clone/sv-venv/lib/python3.10/site-packages/absl/flags/_flag.pyÚ__init__[   s,   ÿzFlag.__init__c                 C   s   | j S ©N©r!   ©r$   r%   r%   r&   Úvalue†   s   z
Flag.valuer+   c                 C   s
   || _ d S r(   r)   ©r$   r+   r%   r%   r&   r+   Š   s   
c                 C   s   t t| ƒƒS r(   )ÚhashÚidr*   r%   r%   r&   Ú__hash__Ž   s   zFlag.__hash__c                 C   s   | |u S r(   r%   ©r$   Úotherr%   r%   r&   Ú__eq__‘   ó   zFlag.__eq__c                 C   s   t |tƒrt| ƒt|ƒk S tS r(   )Ú
isinstancer   r.   ÚNotImplementedr0   r%   r%   r&   Ú__lt__”   s   
zFlag.__lt__c                 C   ó   t dƒ‚)NzRA Flag instance would always be True. Did you mean to test the `.value` attribute?©Ú	TypeErrorr*   r%   r%   r&   Ú__bool__™   s   ÿzFlag.__bool__c                 C   r7   )Nzcan't pickle Flag objectsr8   r*   r%   r%   r&   Ú__getstate__Ÿ   r3   zFlag.__getstate__c                 C   s   t t| ƒj› d�ƒ‚)Nz< does not support shallow copies. Use copy.deepcopy instead.)r9   ÚtypeÚ__name__r*   r%   r%   r&   Ú__copy__¢   s   ÿzFlag.__copy__ÚmemozFlag[_T]c                 C   s"   t  t| ƒ¡}t | j|¡|_|S r(   )ÚobjectÚ__new__r<   ÚcopyÚdeepcopyÚ__dict__)r$   r?   Úresultr%   r%   r&   Ú__deepcopy__¨   s   zFlag.__deepcopy__c                 C   sH   |du rdS | j rt| j  |¡ƒS | jr|rtdƒS tdƒS tt|ƒƒS )z$Returns parsed flag value as string.NÚtrueÚfalse)r   ÚreprÚ	serializer   Ústrr,   r%   r%   r&   Ú_get_parsed_value_as_string­   s   z Flag._get_parsed_value_as_stringÚargumentc                 C   sJ   | j r| jst d| j› d|› d| j› �¡‚|  |¡| _|  j d7  _ dS )z}Parses string and sets flag value.

    Args:
      argument: str or the correct flag value type, argument to be parsed.
    úflag --ú=z: already defined as é   N)r   r   r   ÚIllegalFlagValueErrorr   r+   Ú_parse)r$   rM   r%   r%   r&   Úparseº   s   ÿz
Flag.parsec                 C   sL   z| j  |¡W S  tttfy% } zt d| j› d|› d|› �¡‚d}~ww )zÝInternal parse function.

    It returns the parsed value, and does not modify class states.

    Args:
      argument: str or the correct flag value type, argument to be parsed.

    Returns:
      The parsed value.
    rN   rO   z: N)r   rS   r9   Ú
ValueErrorÚOverflowErrorr   rQ   r   )r$   rM   Úer%   r%   r&   rR   Ç   s   ÿ€þzFlag._parsec                 C   s   | j | _d| _d| _d S )NTr   )r   r+   r    r   r*   r%   r%   r&   ÚunparseÚ   s   
zFlag.unparsec                 C   s   |   | j¡S )zSerializes the flag.)Ú
_serializer+   r*   r%   r%   r&   rJ   ß   s   zFlag.serializec                 C   s`   |du rdS | j r|rd| j› �S d| j› �S | js#t d| j› �¡‚d| j› d| j |¡› �S )zInternal serialize function.NÚ z--z--noú Serializer not present for flag rO   )r   r   r   r   r"   rJ   r,   r%   r%   r&   rX   ã   s   zFlag._serializec                 C   sF   || _ |du rd| _n|  |¡| _|  | j¡| _| jr!| j| _dS dS )z@Changes the default value (and current value too) for this Flag.N)r   r   Ú_parse_from_defaultrL   r   r    r+   r,   r%   r%   r&   r#   ñ   s   ÿzFlag._set_defaultc                 C   s
   |   |¡S r(   )rR   r,   r%   r%   r&   r[   þ   s   
zFlag._parse_from_defaultc                 C   s
   | j  ¡ S )a   Returns a str that describes the type of the flag.

    NOTE: we use strings, and not the types.*Type constants because
    our flags can have more exotic types, e.g., 'comma separated list
    of strings', 'whitespace separated list of strings', etc.
    ©r   Ú	flag_typer*   r%   r%   r&   r]     s   
zFlag.flag_typeÚdocÚmodule_nameÚis_keyc                 C   s&  |  d¡}|r| t |dd¡¡ | t |d|¡¡ | t |d| j¡¡ | jr4| t |d| j¡¡ | jrB| t |d| j¡¡ | jr[t| j	t
ƒs[| j	durX| j | j	¡}nd	}n| j	}| t |d
|¡¡ |  | j¡}| t |d|¡¡ | t |d|  ¡ ¡¡ |  |¡D ]}| |¡ q‰|S )a6  Returns an XML element that contains this flag's information.

    This is information that is relevant to all flags (e.g., name,
    meaning, etc.).  If you defined a flag that has some other pieces of
    info, then please override _ExtraXMLInfo.

    Please do NOT override this method.

    Args:
      doc: minidom.Document, the DOM document it should create nodes from.
      module_name: str,, the name of the module that defines this flag.
      is_key: boolean, True iff this flag is key for main module.

    Returns:
      A minidom.Element instance.
    ÚflagÚkeyÚyesÚfiler   r   ZmeaningNrY   r   Úcurrentr<   )ÚcreateElementÚappendChildr	   Úcreate_xml_dom_elementr   r   r   r   r4   r   rK   rJ   Ú_serialize_value_for_xmlr+   r]   Ú_extra_xml_dom_elements)r$   r^   r_   r`   ÚelementZdefault_serializedÚvalue_serializedrV   r%   r%   r&   Ú_create_xml_dom_element
  sB   
ÿÿÿ
ÿÿÿzFlag._create_xml_dom_elementc                 C   s   |S )z:Returns the serialized value, for use in an XML help text.r%   r,   r%   r%   r&   ri   F  s   zFlag._serialize_value_for_xmlc                 C   s   | j  |¡S )a   Returns extra info about this flag in XML.

    "Extra" means "not already included by _create_xml_dom_element above."

    Args:
      doc: minidom.Document, the DOM document it should create nodes from.

    Returns:
      A list of minidom.Element.
    )r   Ú_custom_xml_dom_elements)r$   r^   r%   r%   r&   rj   J  s   zFlag._extra_xml_dom_elements)NFFFFTF)r   N©F))r=   Ú
__module__Ú__qualname__Ú__doc__r
   Ú__annotations__rK   r   ÚArgumentParserÚArgumentSerializerÚboolr'   Úpropertyr+   Úsetterr/   r2   r6   r:   r;   r>   ÚdictÚintr   rF   rL   rS   rR   rW   rJ   rX   r#   r[   r]   r   ÚDocumentÚElementrm   ri   Úlistrj   r%   r%   r%   r&   r   $   s˜   
 /	óþýü
ûúùø	÷
öõôó
ò+

ÿÿÿÿ
þ<ÿþr   c                       sJ   e Zd ZdZ	d
dededB eB dedB dedB ddf
‡ fdd	„Z‡  ZS )ÚBooleanFlagaÈ  Basic boolean flag.

  Boolean flags do not take any arguments, and their value is either
  ``True`` (1) or ``False`` (0).  The false value is specified on the command
  line by prepending the word ``'no'`` to either the long or the short flag
  name.

  For example, if a Boolean flag was created whose long name was
  ``'update'`` and whose short name was ``'x'``, then this flag could be
  explicitly unset through either ``--noupdate`` or ``--nox``.
  Nr   r   r   r   r   c                    s,   t  ¡ }tƒ j|d ||||dfi |¤Ž d S ©NT)r   ÚBooleanParserÚsuperr'   )r$   r   r   r   r   ÚargsÚp©Ú	__class__r%   r&   r'   i  s   $zBooleanFlag.__init__r(   )r=   rp   rq   rr   rK   rv   r'   Ú__classcell__r%   r%   r„   r&   r~   \  s    ûþ
ýüûùr~   c                       sv   e Zd ZU dZejed< 		ddededB dedB dee d	edB d
e	f‡ fdd„Z
dejdeej fdd„Z‡  ZS )ÚEnumFlagzFBasic enum flag; its value can be any string from list of enum_values.r   NTr   r   r   Úenum_valuesr   Úcase_sensitivec                    s\   t  ||¡}t  ¡ }	tƒ j||	||||fi |¤Ž || _d |j¡}
d|
› d| j› �| _d S )Nú|ú<ú>: )	r   Ú
EnumParserru   r�   r'   r   Újoinrˆ   r   )r$   r   r   r   rˆ   r   r‰   r‚   rƒ   ÚgÚjoined_valuesr„   r%   r&   r'   z  s   
zEnumFlag.__init__r^   r   c                 C   s*   g }| j jD ]}| t |d|¡¡ q|S ©NÚ
enum_value)r   rˆ   Úappendr	   rh   ©r$   r^   Úelementsr’   r%   r%   r&   rj   Œ  s   ÿz EnumFlag._extra_xml_dom_elementsr   )r=   rp   rq   rr   r   r�   rs   rK   r   rv   r'   r   r{   r}   r|   rj   r†   r%   r%   r„   r&   r‡   u  s.   
 
ùþýüûúùÿþr‡   c                       sz   e Zd ZU dZejed< 		ddededB eB dedB de	e d	edB d
e
f‡ fdd„Zdejdeej fdd„Z‡  ZS )ÚEnumClassFlagz5Basic enum flag; its value is an enum class's member.r   NFr   r   r   Ú
enum_classr   r‰   c                    sd   t j||d�}t j| d�}	tƒ j||	||||fi |¤Ž || _d |j¡}
d|
› d| j› �| _d S )N©r‰   )Ú	lowercaserŠ   r‹   rŒ   )	r   ÚEnumClassParserÚEnumClassSerializerr�   r'   r   rŽ   Úmember_namesr   )r$   r   r   r   r—   r   r‰   r‚   rƒ   r�   Újoined_namesr„   r%   r&   r'   œ  s   
ÿzEnumClassFlag.__init__r^   r   c                 C   ó0   g }| j jj ¡ D ]}| t |d|¡¡ q	|S r‘   ©r   r—   Ú__members__Úkeysr“   r	   rh   r”   r%   r%   r&   rj   °  ó   ÿz%EnumClassFlag._extra_xml_dom_elements)NF)r=   rp   rq   rr   r   rš   rs   rK   r   r<   rv   r'   r   r{   r}   r|   rj   r†   r%   r%   r„   r&   r–   —  s.   
 
ùþ
ýüûúùÿþr–   c                       s    e Zd ZdZ‡ fdd„ZdeeB ee B fdd„ZdeeB ee B de	e f‡ fdd	„Z
d
e	e dB def‡ fdd„Zdd„ Zdejde	ej fdd„Z‡  ZS )Ú	MultiFlagae  A flag that can appear multiple time on the command-line.

  The value of such a flag is a list that contains the individual values
  from all the appearances of that flag on the command-line.

  See the __doc__ for Flag for most behavior of this class.  Only
  differences in behavior are described here:

    * The default value may be either a single value or an iterable of values.
      A single value is transformed into a single-item list of that value.

    * The value of the flag is always a list, even if the option was
      only supplied once, and even if the default value is a single
      value
  c                    s$   t ƒ j|i |¤Ž |  jd7  _d S )Nú4;
    repeat this option to specify a list of values)r�   r'   r   )r$   r‚   Úkwargsr„   r%   r&   r'   Ì  s   zMultiFlag.__init__Ú	argumentsc                 C   sH   |   |¡}| jr| jdusJ ‚| j |¡ n|| _|  jt|ƒ7  _dS )a  Parses one or more arguments with the installed parser.

    Args:
      arguments: a single argument or a list of arguments (typically a list of
        default values); a single argument is converted internally into a list
        containing one item.
    N)rR   r   r+   ÚextendÚlen)r$   r¦   Ú
new_valuesr%   r%   r&   rS   Ð  s   
zMultiFlag.parser   c                    sL   | t d˜ r  |g}n td˜ r t|ƒ}n 	 |g}‡‡ fdd„|D ƒS )Nr%   c                    ó   g | ]
}t tˆƒ |¡‘qS r%   )r�   r£   rR   )Ú.0Úitem©r…   r$   r%   r&   Ú
<listcomp>î  s    z$MultiFlag._parse.<locals>.<listcomp>)rK   r   r}   )r$   r¦   Zarguments_listr„   r*   r&   rR   à  s   ÿ

ÿzMultiFlag._parser+   Nc                    sB   ˆ j st dˆ j› �¡‚|du rdS ‡‡ fdd„|D ƒ}d |¡S )úSee base class.rZ   NrY   c                    rª   r%   )r�   r£   rX   )r«   Z
value_itemr­   r%   r&   r®   ÷  s    ÿÿz(MultiFlag._serialize.<locals>.<listcomp>Ú
)r   r   r"   r   rŽ   )r$   r+   Zserialized_itemsr„   r*   r&   rX   ð  s   þ
zMultiFlag._serializec                 C   s   d| j  ¡  S )r¯   zmulti r\   r*   r%   r%   r&   r]   þ  s   zMultiFlag.flag_typer^   c                 C   s6   g }t | jdƒr| jjD ]}| t |d|¡¡ q|S )Nrˆ   r’   )Úhasattrr   rˆ   r“   r	   rh   r”   r%   r%   r&   rj     s   ÿz!MultiFlag._extra_xml_dom_elements)r=   rp   rq   rr   r'   rK   r
   r   rS   r}   rR   rX   r]   r   r{   r|   rj   r†   r%   r%   r„   r&   r£   »  s    &ÿþr£   c                       sˆ   e Zd ZU dZeje ed< 	ddedde	e B eB e	e B eB dede
e d	ef
‡ fd
d„Zdejdeej fdd„Zdd„ Z‡  ZS )ÚMultiEnumClassFlagzÁA multi_enum_class flag.

  See the __doc__ for MultiFlag for most behaviors of this class.  In addition,
  this class knows how to handle enum.Enum instances as values for this flag
  type.
  r   Fr   r   Nr   r—   r‰   c           
         sn   t j||d�}t jd| d�}tƒ j|||||fi |¤Ž || _|| _d |j¡}	d|	› d|p0d› d�| _	d S )	Nr˜   ú,)Úlist_sepr™   rŠ   r‹   rŒ   r   r¤   )
r   rš   ÚEnumClassListSerializerr�   r'   r   r   rŽ   rœ   r   )
r$   r   r   r   r—   r‰   r‚   rƒ   r�   r�   r„   r%   r&   r'     s   	ÿÿÿÿzMultiEnumClassFlag.__init__r^   r   c                 C   rž   r‘   rŸ   r”   r%   r%   r&   rj   5  r¢   z*MultiEnumClassFlag._extra_xml_dom_elementsc                 C   s8   |dur| j st d| j› �¡‚| j  |¡}|S d}|S )r¯   NrZ   rY   )r   r   r"   r   rJ   )r$   r+   rl   r%   r%   r&   ri   ?  s   ÿz+MultiEnumClassFlag._serialize_value_for_xmlro   )r=   rp   rq   rr   r   rš   r   rs   rK   r   r<   rv   r'   r   r{   r}   r|   rj   ri   r†   r%   r%   r„   r&   r²     s*   
 úþýüûúÿ
þ
r²   )rr   Úcollections.abcr   rB   ÚenumÚ	functoolsÚtypingr   r   r   Úxml.domr   Ú
absl.flagsr   r   r	   r
   ÚEnumr   Útotal_orderingr   rv   r~   rK   r‡   r–   r}   r£   r²   r%   r%   r%   r&   Ú<module>   s*     9"$S