
    0VhoN                        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	m
Z
mZmZ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.                        Zej2                   G d de	e                Z G d dee         Z G d dee         Z G d dee         Z G d de	e   eee            Z  G d de e         Z!y)zContains 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.
    )abcN)	AnyDictGenericIterableListOptionalTypeTypeVarUnion)minidom)_argument_parser)_exceptions)_helpers_T_ET)boundc                       e Zd ZU dZee   ed<   ee   ed<   eee   ef   ed<   e	j                  e   ed<   	 	 	 	 	 	 	 d/de	j                  e   dee	j                  e      dedeee   ef   d	ee   d
ee   dededededededdfdZedee   fd       Zej                   dee   fd       Zd Zd Zd Zd Zd Zd Zdeeef   ddfdZdee   dee   fdZd eeef   ddfd!Zd eeef   dee   fd"Zd0d#Zdefd$Zdee   defd%Z deee   ef   ddfd&Z!deeef   dee   fd'Z"defd(Z#	 d1d)e$jJ                  d*ed+ede$jL                  fd,Z'dee   defd-Z(d)e$jJ                  de)e$jL                     fd.Z*y)2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.
  defaultdefault_as_strdefault_unparsedparserN
serializernamehelp_string
short_namebooleanallow_overrideallow_override_cppallow_hide_cppallow_overwriteallow_using_method_namesreturnc                 Z   || _         |sd}|| _        || _        || _        d| _        || _        || _        || _        |	| _        |
| _	        || _
        || _        d| _        d | _        g | _        | j                  r!| j                  rt        j                   d      | j#                  |       y )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_value
validatorsr   Error_set_default)selfr   r   r   r   r   r   r   r   r    r!   r"   r#   s                @/home/dcms/DCMS/lib/python3.12/site-packages/absl/flags/_flag.py__init__zFlag.__init__\   s     DI)kDI DODLDLDK DO(D0D(D*D$<D!#D $DK!#DOt66EF F 	g    c                     | j                   S Nr*   r.   s    r/   valuez
Flag.value   s    ;;r1   r6   c                     || _         y r3   r4   r.   r6   s     r/   r6   z
Flag.value   s	    DKr1   c                 *    t        t        |             S r3   )hashidr5   s    r/   __hash__zFlag.__hash__   s    4>r1   c                 
    | |u S r3    r.   others     r/   __eq__zFlag.__eq__   s    5=r1   c                 \    t        |t              rt        |       t        |      k  S t        S r3   )
isinstancer   r;   NotImplementedr?   s     r/   __lt__zFlag.__lt__   s%    %X5	!!r1   c                     t        d      )NzRA Flag instance would always be True. Did you mean to test the `.value` attribute?	TypeErrorr5   s    r/   __bool__zFlag.__bool__   s    
 C D Dr1   c                     t        d      )Nzcan't pickle Flag objectsrG   r5   s    r/   __getstate__zFlag.__getstate__   s    
/
00r1   c                 D    t        dt        |       j                  z        )Nz>%s does not support shallow copies. Use copy.deepcopy instead.)rH   type__name__r5   s    r/   __copy__zFlag.__copy__   s)    
 137:3F3FG H Hr1   memozFlag[_T]c                     t         j                  t        |             }t        j                  | j
                  |      |_        |S r3   )object__new__rM   copydeepcopy__dict__)r.   rP   results      r/   __deepcopy__zFlag.__deepcopy__   s/    ^^DJ'FmmDMM48FOMr1   c                     |y| j                   r$t        | j                   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   strr8   s     r/   _get_parsed_value_as_stringz Flag._get_parsed_value_as_string   sX    }$//++E233||	F|G}E
r1   argumentc                     | j                   r>| j                  s2t        j                  d| j                  d|d| j
                        | j                  |      | _        | xj                   dz  c_         y)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   r6   _parse)r.   r`   s     r/   parsez
Flag.parse   sZ     ||D00--ii4::/0 0 X&DJLLALr1   c           	          	 | j                   j                  |      S # t        t        t        f$ r-}t        j                  d| j                  d|d|      d}~ww xY w)zInternal 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.
    rb   rc   z: N)r   rg   rH   
ValueErrorOverflowErrorr   re   r   )r.   r`   es      r/   rf   zFlag._parse   sT    9[[x((z=1 9-- $		8Q
79 99s    A(AAc                 B    | j                   | _        d| _        d| _        y )NTr   )r   r6   r)   r(   r5   s    r/   unparsezFlag.unparse   s    DJ#DDLr1   c                 8    | j                  | j                        S )zSerializes the flag.)
_serializer6   r5   s    r/   r]   zFlag.serialize   s    ??4::&&r1   c                    |y| j                   r |rd| j                  z  S d| j                  z  S | j                  s"t        j                  d| j                  z        d| j                  d| j                  j                  |      S )zInternal serialize function. z--%sz--no%s"Serializer not present for flag %sz--rc   )r   r   r   r   r,   r]   r8   s     r/   ro   zFlag._serialize   s}    }||			!!$))##__0499<> 	>  ))T__%>%>u%EFFr1   c                     || _         |d| _        n| j                  |      | _        | j                  | j                        | _        | j
                  r| j                  | _        yy)z@Changes the default value (and current value too) for this Flag.N)r   r   _parse_from_defaultr_   r   r)   r6   r8   s     r/   r-   zFlag._set_default   sX    !D}dl--e4dl::4<<HD<<dj  r1   c                 $    | j                  |      S r3   )rf   r8   s     r/   rt   zFlag._parse_from_default   s    ;;ur1   c                 6    | j                   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_typer5   s    r/   rx   zFlag.flag_type   s     ;;  ""r1   docmodule_nameis_keyc                 f   |j                  d      }|r&|j                  t        j                  |dd             |j                  t        j                  |d|             |j                  t        j                  |d| j                               | j
                  r0|j                  t        j                  |d| j
                               | j                  r0|j                  t        j                  |d| j                               | j                  rOt        | j                  t              s5| j                  &| j                  j                  | j                        }nd}n| j                  }|j                  t        j                  |d	|             | j                  | j                        }|j                  t        j                  |d
|             |j                  t        j                  |d| j                                      | j                  |      D ]  }|j                  |        |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   meaningrq   r   currentrM   )createElementappendChildr   create_xml_dom_elementr   r   r'   r   rC   r   r^   r]   _serialize_value_for_xmlr6   rx   _extra_xml_dom_elements)r.   ry   rz   r{   elementdefault_serializedvalue_serializedrk   s           r/   _create_xml_dom_elementzFlag._create_xml_dom_element  s   & 'G(99#ueLM77V[" # 77VTYYOP(99
|T__. /yy(99
y$))% &
 z$,,<		!!__66t||D<<77Y*, -44TZZ@77Y(* +77VT^^%' ( ))#. !Nr1   c                     |S )z:Returns the serialized value, for use in an XML help text.r>   r8   s     r/   r   zFlag._serialize_value_for_xml<  s    Lr1   c                 8    | j                   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.   ry   s     r/   r   zFlag._extra_xml_dom_elements@  s     ;;//44r1   )NFFFFTF)r$   NF)+rN   
__module____qualname____doc__r	   r   __annotations__r^   r   r   ArgumentParserArgumentSerializerboolr0   propertyr6   setterr<   rA   rE   rI   rK   rO   r   intr   rX   r_   rg   rf   rm   r]   ro   r-   rt   rx   r   DocumentElementr   r   r   r   r>   r1   r/   r   r   $   s   -` B<3-(2,+,,

)
)"
-- #'"!&""',(--b1( +>>rBC( 	(
 Xb\3&'( C=( 3-( ( ( ( ( ( !%( (T Xb\   	<<"  
D1HtCH~ * 
x|  E#r'N t 9U37^ 9 9$
' 'Ghrl Gs G	 hrlC&7 8 	 T 	 uS"W~ (2, # # EJ4!!4034=A44lHRL S 5!!5GOO5r1   r   c                   X     e Zd ZdZ	 d	dedeee   ef   dee   dee   ddf
 fdZ x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           	      Z    t        j                         }t        |   |d ||||dfi | y NT)r   BooleanParsersuperr0   )r.   r   r   r'   r   argsp	__class__s          r/   r0   zBooleanFlag.__init___  s1     	&&(A	GQdGT:tLtLr1   r3   )
rN   r   r   r   r^   r   r	   r   r0   __classcell__r   s   @r/   r   r   R  sd    
" #'	M	M Xd^S()	M SM		M
 3-	M 	M 	Mr1   r   c                        e Zd ZU dZej
                  ed<   	 	 ddedee   dee   de	e   dee   de
f fd	Zd
ej                  deej                     fdZ xZS )EnumFlagzFBasic enum flag; its value can be any string from list of enum_values.r   r   r   r'   enum_valuesr   case_sensitivec                     t        j                  ||      }t        j                         }	t        
|   ||	||||fi | || _        ddj                  |j                        d| j                  | _        y )N<|>: )	r   
EnumParserr   r   r0   r   joinr   r'   )r.   r   r   r'   r   r   r   r   r   gr   s             r/   r0   zEnumFlag.__init__p  se     	##K@A++-A	GQ4$
CdCDK!hhq}}5tyyADIr1   ry   r$   c                     g }| j                   j                  D ](  }|j                  t        j                  |d|             * |S N
enum_value)r   r   appendr   r   r.   ry   elementsr   s       r/   r   z EnumFlag._extra_xml_dom_elements  sI     Hkk-- *
ooh55
|Z) ** Or1   r   )rN   r   r   r   r   r   r   r^   r	   r   r   r0   r   r   r   r   r   r   r   s   @r/   r   r   k  s    N

%
%% #'!BB }B SM	B
 C=B 3-B B"!!GOOr1   r   c                        e Zd ZU dZej
                  ed<   	 	 ddedee	e
   ef   de	e   dee
   de	e   def fd	Zd
ej                  deej"                     fdZ xZS )EnumClassFlagz5Basic enum flag; its value is an enum class's member.r   r   r   r'   
enum_classr   r   c                     t        j                  ||      }t        j                  |       }	t        
|   ||	||||fi | || _        ddj                  |j                        d| j                  | _        y )Nr   )	lowercaser   r   r   )	r   EnumClassParserEnumClassSerializerr   r0   r   r   member_namesr'   )r.   r   r   r'   r   r   r   r   r   r   r   s             r/   r0   zEnumClassFlag.__init__  so     	((>	A 	,,>7IJA	GQ4$
CdCDK!hhq~~6		BDIr1   ry   r$   c                     g }| j                   j                  j                  j                         D ](  }|j	                  t        j                  |d|             * |S r   r   r   __members__keysr   r   r   r   s       r/   r   z%EnumClassFlag._extra_xml_dom_elements  X     Hkk,,88==? *
ooh55
|Z) ** Or1   )NF)rN   r   r   r   r   r   r   r^   r   r	   r   r
   r   r0   r   r   r   r   r   r   r   s   @r/   r   r     s    =

*
** #'"CC Xc]C'(C SM	C
 s)C 3-C C&!!GOOr1   r   c                        e Zd ZdZ fdZdeeeee   f   fdZ	deeeee   f   de
e   f fdZdee
e      def fdZd	 Zd
ej                   de
ej"                     fdZ x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                 N    t        |   |i | | xj                  dz  c_        y )N4;
    repeat this option to specify a list of values)r   r0   r'   )r.   r   kwargsr   s      r/   r0   zMultiFlag.__init__  s$    	Gd%f%IIHHIr1   	argumentsc                     | j                  |      }| j                  r*| j                  J | j                  j                  |       n|| _        | xj                  t	        |      z  c_        y)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)rf   r(   r6   extendlen)r.   r   
new_valuess      r/   rg   zMultiFlag.parse  sT     Y'J||ZZ###
jj
#djLLC
O#Lr1   r$   c                     t        |t              r|g}n)t        |t        j                        rt	        |      }n|g}|D cg c]  }t
        t        |   |       c}S c c}w r3   )rC   r^   r   r   listr   r   rf   )r.   r   arguments_listitemr   s       r/   rf   zMultiFlag._parse  sV     )S!!{n	Is||	,In "{n<JKDE)T)$/KKKs   A r6   c                     | j                   s"t        j                  d| j                  z        |y|D cg c]  }t        t
        |   |       }}dj                  |      S c c}w )See base class.rr   rq   
)r   r   r,   r   r   r   ro   r   )r.   r6   
value_itemserialized_itemsr   s       r/   ro   zMultiFlag._serialize  st    ??
.
:< <}   	i)*5 
 99%&&s   A$c                 <    d| j                   j                         z   S )r   zmulti rw   r5   s    r/   rx   zMultiFlag.flag_type  s    dkk++---r1   ry   c                     g }t        | j                  d      rA| j                  j                  D ](  }|j                  t	        j
                  |d|             * |S )Nr   r   )hasattrr   r   r   r   r   r   s       r/   r   z!MultiFlag._extra_xml_dom_elements  sW     Ht{{M*// ,*77z+ 	,, Or1   )rN   r   r   r   r0   r   r^   r   r   rg   r   rf   r	   ro   rx   r   r   r   r   r   r   s   @r/   r   r     s     I$U3HRL#89 $ LeCXb\$9: LtBx L"'htBx0 'S '.!!GOOr1   r   c                        e Zd ZU dZej
                  e   ed<   	 ddede	de
e   ee
e   ef   dedee   def
 fd	Zd
ej                  deej"                     fdZd Z xZS )MultiEnumClassFlagzA 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   r   r   Nr   r   r   c                     t        j                  ||      }t        j                  d|       }t        	|   |||||fi | || _        || _        ddj                  |j                        d|xs dd| _	        y )	Nr   ,)list_sepr   r   r   r   r&   r   )
r   r   EnumClassListSerializerr   r0   r   r   r   r   r'   )
r.   r   r   r   r   r   r   r   r   r   s
            r/   r0   zMultiEnumClassFlag.__init__  s     	((>	3A 	00N 2	4A	GQ4+>> DKDO 
!..	!;#G2G#G	I 	Ir1   ry   r$   c                     g }| j                   j                  j                  j                         D ](  }|j	                  t        j                  |d|             * |S r   r   r   s       r/   r   z*MultiEnumClassFlag._extra_xml_dom_elements#  r   r1   c                     |K| j                   s"t        j                  d| j                  z        | j                   j	                  |      }|S d}|S )r   rr   rq   )r   r   r,   r   r]   )r.   r6   r   s      r/   r   z+MultiEnumClassFlag._serialize_value_for_xml,  s[    __0499<
 	
 2259  r1   r   )rN   r   r   r   r   r   r   r   r^   r   r   r
   r   r0   r   r   r   r   r   r   r   r   s   @r/   r   r     s     
*
*3
// #JJ T8C=#x}cABJ 	J
 s)J J0!!GOO
r1   r   )"r   collectionsr   rT   enum	functoolstypingr   r   r   r   r   r	   r
   r   r   xml.domr   
absl.flagsr   r   r   r   Enumr   total_orderingr   r   r   r^   r   r   r   r   r>   r1   r/   <module>r      s        U U U  ' " T]e499% j572; j5 j5Z	M$t* M2tCy @DI DQT$r(^ Qh53 5r1   