
    RC                        S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKJr  SSK	J
r
  SSK	Jr  SS	K	Jr  SSKr\R                   " S
 S\5      5       r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      rg)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.
    )absolute_import)division)print_functionN)abc)_argument_parser)_exceptions)_helpersc                       \ rS rSrSr   SS jr\S 5       r\R                  S 5       rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rSS jrS rS rSrg)Flag#   a;	  Information about a command-line flag.

'Flag' objects define the following fields:
  .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 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 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.

The only public method of a 'Flag' object is parse(), but it is
typically only called by a 'FlagValues' object.  The parse() method is
a thin wrapper around the '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.

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.
Nc                 d   X0l         U(       d  SnXPl        X`l        Xpl        SU l        Xl        X l        Xl        Xl        Xl	        Xl
        Xl        SU l        S U l        / U l        U R                  (       a'  U R                  (       a  [        R                   " S5      eU R#                  U5        g )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))namehelp
short_namebooleanpresentparser
serializerallow_overrideallow_override_cppallow_hide_cppallow_overwriteallow_using_method_namesusing_default_value_value
validatorsr   Error_set_default)selfr   r   r   defaulthelp_stringr   r   r   r   r   r   r   s                +platform/bq/third_party/absl/flags/_flag.py__init__Flag.__init__Q   s     I)kI OLDLK O(0(*$<!#DDKDOt66EF F 	g    c                     U R                   $ Nr   r    s    r#   value
Flag.valuep   s    ;;r&   c                     Xl         g r(   r)   r    r+   s     r#   r+   r,   t   s    Kr&   c                 *    [        [        U 5      5      $ r(   )hashidr*   s    r#   __hash__Flag.__hash__x   s    4>r&   c                     XL $ r(    r    others     r#   __eq__Flag.__eq__{   s
    =r&   c                 f    [        U[        5      (       a  [        U 5      [        U5      :  $ [        $ r(   )
isinstancer   r1   NotImplementedr6   s     r#   __lt__Flag.__lt__~   s(    %X5	!!r&   c                     [        S5      e)Nzcan't pickle Flag objects)	TypeErrorr*   s    r#   __getstate__Flag.__getstate__   s    
/
00r&   c                 D    [        S[        U 5      R                  -  5      e)Nz>%s does not support shallow copies. Use copy.deepcopy instead.)r@   type__name__r*   s    r#   __copy__Flag.__copy__   s)    
 137:3F3FG H Hr&   c                     [         R                  [        U 5      5      n[        R                  " U R
                  U5      Ul        U$ r(   )object__new__rD   copydeepcopy__dict__)r    memoresults      r#   __deepcopy__Flag.__deepcopy__   s/    ^^DJ'FmmDMM48FOMr&   c                    Uc  gU R                   (       a$  [        U R                   R                  U5      5      $ U R                  (       a  U(       a  [        S5      $ [        S5      $ [        [        R
                  " U5      5      $ )z$Returns parsed flag value as string.Ntruefalse)r   repr	serializer   r	   str_or_unicoder.   s     r#   _get_parsed_value_as_string Flag._get_parsed_value_as_string   s_    }$//++E233||	F|G}''.//r&   c                 
   U R                   (       aG  U R                  (       d6  [        R                  " SU R                  < SU< SU R
                  < 35      eU R                  U5      U l        U =R                   S-  sl         g)zqParses 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    arguments     r#   parse
Flag.parse   sZ     ||D00--ii4::/0 0 X&DJLLALr&   c           	           U R                   R                  U5      $ ! [        [        4 a1  n[        R
                  " SU R                  < SU< SU< 35      eSnAff = f)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.
r[   r\   z: N)r   ra   r@   
ValueErrorr   r^   r   )r    r`   es      r#   r_   Flag._parse   sR    9[[x((z" 9-- $		8Q
79 99s    A,AAc                 B    U R                   U l        SU l        SU l        g )NTr   )r!   r+   r   r   r*   s    r#   unparseFlag.unparse   s    DJ#DDLr&   c                 8    U R                  U R                  5      $ )zSerializes the flag.)
_serializer+   r*   s    r#   rV   Flag.serialize   s    ??4::&&r&   c                 8   Uc  gU R                   (       a%  U(       a  SU R                  -  $ SU R                  -  $ U R                  (       d#  [        R                  " SU R                  -  5      eSU R                  < SU R                  R                  U5      < 3$ )zInternal serialize function. z--%sz--no%s"Serializer not present for flag %sz--r\   )r   r   r   r   r   rV   r.   s     r#   rk   Flag._serialize   s}    }||			!!$))##__0499<> 	>  ))T__%>%>u%EFFr&   c                     Xl         Uc  SU l        OU R                  U5      U l        U R                  U R                  5      U l        U R
                  (       a  U R                  U l        gg)z@Changes the default value (and current value too) for this Flag.N)default_unparsedr!   _parse_from_defaultrX   default_as_strr   r+   r.   s     r#   r   Flag._set_default   sV    !}dl--e4dl::4<<HD<<dj  r&   c                 $    U R                  U5      $ r(   )r_   r.   s     r#   rs   Flag._parse_from_default   s    ;;ur&   c                 6    U R                   R                  5       $ )zReturns 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*   s    r#   rz   Flag.flag_type   s     ;;  ""r&   c                    UR                  S5      nU(       a'  UR                  [        R                  " USS5      5        UR                  [        R                  " USU5      5        UR                  [        R                  " USU R                  5      5        U R
                  (       a1  UR                  [        R                  " USU R
                  5      5        U R                  (       a1  UR                  [        R                  " USU R                  5      5        U R                  (       aU  [        U R                  [        5      (       d6  U R                  b&  U R                  R                  U R                  5      nOSnOU R                  nUR                  [        R                  " US	U5      5        U R                  U R                  5      nUR                  [        R                  " US
U5      5        UR                  [        R                  " USU R                  5       5      5        U R                  U5       H  nUR                  U5        M     U$ )a
  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   meaningrn   r!   currentrD   )createElementappendChildr	   create_xml_dom_elementr   r   r   r   r;   r!   strrV   _serialize_value_for_xmlr+   rz   _extra_xml_dom_elements)r    docmodule_nameis_keyelementdefault_serializedvalue_serializedre   s           r#   _create_xml_dom_element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^^%' ( ))#.! /Nr&   c                     U$ )z:Returns the serialized value, for use in an XML help text.r5   r.   s     r#   r   Flag._serialize_value_for_xml  s    Lr&   c                 8    U R                   R                  U5      $ )zReturns 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   s     r#   r   Flag._extra_xml_dom_elements#  s     ;;//44r&   )r   r   r   r   r   r   r   r!   rt   rr   r   r   r   r   r   r   r   r   r+   )NFFFFTFF)rE   
__module____qualname____firstlineno____doc__r$   propertyr+   setterr2   r8   r=   rA   rF   rP   rX   ra   r_   rh   rV   rk   r   rs   rz   r   r   r   __static_attributes__r5   r&   r#   r   r   #   s    *Z ?D8=>C>   	<< 
1H
09"
'G	 #2h5r&   r   c                   0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )BooleanFlagi3  a  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.
c           	      b   > [         R                  " 5       n[        [        U ]  " US XX4S40 UD6  g )Nr]   )r   BooleanParsersuperr   r$   )r    r   r!   r   r   argsp	__class__s          r#   r$   BooleanFlag.__init__@  s3    &&(A	+t%	4!=7;=r&   r5   r(   )rE   r   r   r   r   r$   r   __classcell__r   s   @r#   r   r   3  s    
= =r&   r   c                   8   ^  \ rS rSrSr SU 4S jjrS rSrU =r$ )EnumFlagiF  zFBasic enum flag; its value can be any string from list of enum_values.c                    > [         R                  " XF5      n[         R                  " 5       n	[        [        U ]  " XXX540 UD6  SSR                  U5      < SU R                  < 3U l        g )N<|>: )r   
EnumParserArgumentSerializerr   r   r$   joinr   )r    r   r!   r   enum_valuesr   case_sensitiver   r   gr   s             r#   r$   EnumFlag.__init__I  sX    ##K@A++-A	(D"	dT7157!hh{3TYY?DIr&   c                     / nU R                   R                   H*  nUR                  [        R                  " USU5      5        M,     U$ N
enum_value)r   r   appendr	   r   r    r   elementsr   s       r#   r    EnumFlag._extra_xml_dom_elementsQ  sB    Hkk--
ooh55
|Z) * . Or&   r   )NT	rE   r   r   r   r   r$   r   r   r   r   s   @r#   r   r   F  s    N 04@ r&   r   c                   :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )EnumClassFlagiY  z5Basic enum flag; its value is an enum class's member.c                    > [         R                  " XFS9n[         R                  " U(       + S9n	[        [        U ]  " XXX540 UD6  SSR                  UR                  5      < SU R                  < 3U l        g )Nr   )	lowercaser   r   r   )	r   EnumClassParserEnumClassSerializerr   r   r$   r   member_namesr   )r    r   r!   r   
enum_classr   r   r   r   r   r   s             r#   r$   EnumClassFlag.__init__\  sf     	((	3A,,>7IJA	-'	dT7157!hhq~~6		BDIr&   c                     / nU R                   R                  R                  R                  5        H*  nUR	                  [
        R                  " USU5      5        M,     U$ r   r   r   __members__keysr   r	   r   r   s       r#   r   %EnumClassFlag._extra_xml_dom_elementsl  R    Hkk,,88==?
ooh55
|Z) * @ Or&   r   )NFr   r   s   @r#   r   r   Y  s    = C  r&   r   c                   V   ^  \ rS rSrSrU 4S jrS rU 4S jrU 4S jrS r	S r
S	rU =r$ )
	MultiFlagit  aQ  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                 X   > [         [        U ]
  " U0 UD6  U =R                  S-  sl        g )N4;
    repeat this option to specify a list of values)r   r   r$   r   )r    r   kwargsr   s      r#   r$   MultiFlag.__init__  s&    	)T#T4V4IIHHIr&   c                     U R                  U5      nU R                  (       a  U R                  R                  U5        OX l        U =R                  [	        U5      -  sl        g)zParses 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)r_   r   r+   extendlen)r    	arguments
new_valuess      r#   ra   MultiFlag.parse  sB     Y'J||
jj
#jLLC
O#Lr&   c                   > [        U[        R                  5      (       a*  [        U[        R                  5      (       d  [        U5      n[        U[
        5      (       d  U/nU Vs/ s H  n[        [        U ]#  U5      PM     sn$ s  snf r(   )	r;   r   Iterablesixstring_typeslistr   r   r_   )r    r   itemr   s      r#   r_   MultiFlag._parse  sj    9cll++y#"2"233y/ii&& +i<EFIDE)T)$/IFFFs   'Bc                    > U R                   (       d#  [        R                  " SU R                  -  5      eUc  gU Vs/ s H  n[        [
        U ]  U5      PM     nnSR                  U5      $ s  snf )See base class.ro   rn   
)r   r   r   r   r   r   rk   r   )r    r+   
value_itemserialized_itemsr   s       r#   rk   MultiFlag._serialize  st    ??
.
:< <} INHM*i)*5   99%&&	s   A.c                 <    SU R                   R                  5       -   $ )r   zmulti ry   r*   s    r#   rz   MultiFlag.flag_type  s    dkk++---r&   c                     / n[        U R                  S5      (       aD  U R                  R                   H*  nUR                  [        R
                  " USU5      5        M,     U$ )Nr   r   )hasattrr   r   r   r	   r   r   s       r#   r   !MultiFlag._extra_xml_dom_elements  sS    Ht{{M**//*77z+ 	, 0 Or&   )r+   )rE   r   r   r   r   r$   ra   r_   rk   rz   r   r   r   r   s   @r#   r   r   t  s-     I$G'. r&   r   c                   >   ^  \ rS rSrSr SU 4S jjrS rS rSrU =r	$ )MultiEnumClassFlagi  zA 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.
c                    > [         R                  " XES9n[         R                  " SU(       + S9n[        [        U ]  " XxXU40 UD6  SSR                  UR                  5      < SU=(       d    S< S3U l        g )	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   s
            r#   r$   MultiEnumClassFlag.__init__  sy     	((	3A00N 2	4A	
d,	d[2,02 
!..	!;#G2G#G	I 	Ir&   c                     / nU R                   R                  R                  R                  5        H*  nUR	                  [
        R                  " USU5      5        M,     U$ r   r   r   s       r#   r   *MultiEnumClassFlag._extra_xml_dom_elements  r   r&   c                 J    Ub  U R                   R                  U5      nU$ SnU$ )r   rn   )r   rV   )r    r+   r   s      r#   r   +MultiEnumClassFlag._serialize_value_for_xml  s3    2259  r&   r   r   )
rE   r   r   r   r   r$   r   r   r   r   r   s   @r#   r   r     s"     $J" r&   r   )r   
__future__r   r   r   rK   	functoolsabsl._collections_abcr   
absl.flagsr   r   r	   r   total_orderingrI   r   r   r   r   r   r   r5   r&   r#   <module>r      s    '  %   % ' "  
 L56 L5 L5^=$ =&t &D 6I IX& &r&   