
    x                        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Jr  SSKJr   SSKJrJrJr   SSKr\R(                  R+                  \" \R.                  \   5      5        S r\R4                  SSS4S jr\R4                  SS4S jr\R4                  S4S jr\R4                  4S jr\R4                  4S jrS r \R4                  S4S jr!\R4                  SS4S jr"SS\R4                  S4S jr#SS\R4                  S4S jr$\R4                  SS4S jr%\R4                  SSS4S jr&\R4                  S4S jr'S\R4                  S4S jr(\R4                  SS4S jr)\R4                  S4S jr*SS\R4                  S4S jr+SS\R4                  S4S  jr,\R4                  S!S4S" jr-\R4                  SSS4S# jr.\R4                  S4S$ jr/g! \ a     GNf = f! \ a     GNf = f)%zThis modules contains flags DEFINE functions.

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)_argument_parser)_exceptions)_flag)_flagvalues)_helpers)_validators)TextListAnyc                 r   ^  T R                   c  T R                  b  U 4S jn[        R                  " XUS9  gg)zEnforces lower and upper bounds for numeric flags.

Args:
  parser: NumericParser (either FloatParser or IntegerParser), provides lower
    and upper bounds, and help text to display.
  name: str, name of the flag
  flag_values: FlagValues.
Nc                    > U b?  TR                  U 5      (       a)  U < STR                  < 3n[        R                  " U5      eg)Nz is not T)is_outside_boundssyntactic_helpr   ValidationError)valuemessageparsers     .platform/bq/third_party/absl/flags/_defines.pychecker5_register_bounds_validator_if_needed.<locals>.checker<   s=    		v77>>$)6+@+@A))'22    flag_values)lower_boundupper_boundr   register_validator)r   namer   r   s   `   r   $_register_bounds_validator_if_neededr!   1   s9     #v'9'9'E ""4kJ (Fr   Fc           	      J    [        [        R                  " XXU40 UD6UXg5      $ )a  Registers a generic Flag object.

NOTE: in the docstrings of all DEFINE* functions, "registers" is short
for "creates a new flag and registers it".

Auxiliary function: clients should use the specialized DEFINE_<type>
function instead.

Args:
  parser: ArgumentParser, used to parse the flag arguments.
  name: str, the flag name.
  default: The default value of the flag.
  help: str, the help message.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  serializer: ArgumentSerializer, the flag serializer instance.
  module_name: str, the name of the Python module declaring this flag. If not
    provided, it will be computed using the stack trace of this call.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: dict, the extra keyword args that are passed to Flag __init__.

Returns:
  a handle to defined flag.
)DEFINE_flagr   Flag)	r   r    defaulthelpr   
serializermodule_namerequiredargss	            r   DEFINEr+   E   s,    F 
jjTDADA;
 r   c                    U(       a%  U R                   b  [        SU R                  -  5      eUnXU R                  '   U(       a   [        R                  R                  U5      nO[        R                  " 5       u  pRUR                  X 5        UR                  [        U5      U 5        U(       a!  [        R                  " U R                  U5        U R                   SL=(       d    Un[        R                  " X@US9$ )a(  Registers a 'Flag' object with a 'FlagValues' object.

By default, the global FLAGS 'FlagValue' object is used.

Typical users will use one of the more specialized DEFINE_xxx
functions, such as DEFINE_string or DEFINE_integer.  But developers
who need to create Flag objects themselves should use this function
to register their flags.

Args:
  flag: Flag, a flag that is key to the module.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  module_name: str, the name of the Python module declaring this flag. If not
    provided, it will be computed using the stack trace of this call.
  required: bool, is this a required flag. This must be used as a keyword
    argument.

Returns:
  a handle to defined flag.
Nz1Required flag --%s cannot have a non-None default)ensure_non_none_value)r%   
ValueErrorr    sysmodulesgetr
   "get_calling_module_object_and_nameregister_flag_by_moduleregister_flag_by_module_ididr   mark_flag_as_requiredr	   
FlagHolder)flagr   r(   r)   fvmoduler-   s          r   r#   r#   m   s    4 $,,*
HYY     "TYY-[[__[)F"EEGF%%k8((FT:%%dii4<<t3@			&;
= =r   c                     U=(       d    Un[         R                  " 5       nU  H  nX   nUR                  X55        M     g)a1  Declares a flag as key for the calling module.

Internal function.  User code should call declare_key_flag or
adopt_module_key_flags instead.

Args:
  flag_names: [str], a list of strings that are names of already-registered
    Flag objects.
  flag_values: FlagValues, the FlagValues instance with which the flags listed
    in flag_names have registered (the value of the flag_values argument from
    the DEFINE_* calls that defined those flags). This should almost never
    need to be overridden.
  key_flag_values: FlagValues, the FlagValues instance that (among possibly
    many other things) keeps track of the key flags for each module. Default
    None means "same as flag_values".  This should almost never need to be
    overridden.

Raises:
  UnrecognizedFlagError: Raised when the flag is not defined.
N)r
   get_calling_moduleregister_key_flag_for_module)
flag_namesr   key_flag_valuesr:   	flag_namer8   s         r   _internal_declare_key_flagsrA      s<    . $2{/&&(&i!D00> r   c                     U [         R                  ;   a  [        U /[         R                  US9  g [        U /US9  g! [         a    [	        SU -  5      ef = f)a  Declares one flag as key to the current module.

Key flags are flags that are deemed really important for a module.
They are important when listing help messages; e.g., if the
--helpshort command-line flag is used, then only the key flags of the
main module are listed (instead of all flags, as in the case of
--helpfull).

Sample usage:

  flags.declare_key_flag('flag_1')

Args:
  flag_name: str, the name of an already declared flag. (Redeclaring flags as
    key, including flags implicitly key because they were declared in this
    module, is a no-op.)
  flag_values: FlagValues, the FlagValues instance in which the flag will be
    declared as a key flag. This should almost never need to be overridden.

Raises:
  ValueError: Raised if flag_name not defined as a Python flag.
r   r?   Nr   zNFlag --%s is undefined. To set a flag as a key flag first define it in Python.)r
   SPECIAL_FLAGSrA   KeyErrorr.   )r@   r   s     r   declare_key_flagrF      sk    . ((((
  ,4,B,B0;= ?E	 ?
 24=> ? ??s	   = Ac                    [        U [        R                  5      (       d  [        R                  " SU < S35      e[        UR                  U R                  5       Vs/ s H  o"R                  PM     snUS9  U [        R                  :X  aT  [        [        R                   Vs/ s H   n[        R                  U   R                  PM"     sn[        R                  US9  ggs  snf s  snf )a  Declares that all flags key to a module are key to the current module.

Args:
  module: module, the module object from which all key flags will be declared
    as key flags to the current module.
  flag_values: FlagValues, the FlagValues instance in which the flags will be
    declared as key flags. This should almost never need to be overridden.

Raises:
  Error: Raised when given an argument that is a module name (a string),
      instead of a module object.
zExpected a module object, not .r   rC   N)
isinstancetypes
ModuleTyper   ErrorrA   get_key_flags_for_module__name__r    r
   FLAGS_MODULErD   )r:   r   fr    s       r   adopt_module_key_flagsrQ      s     
FE,,	-	-


6K
LL";;FOOLML!vvLM x$$$ 8@7M7MN7Mt			%	*	*7MN**#% % N 	Os   C!#'C&c                      [         R                  " S5      R                  n [        R                  " U 5      u  p[        R
                  R                  [        U5      5        g)a  Declares that the current module will not define any more key flags.

Normally, the module that calls the DEFINE_xxx functions claims the
flag to be its key flag.  This is undesirable for modules that
define additional DEFINE_yyy functions with its own flag parsers and
serializers, since that module will accidentally claim flags defined
by DEFINE_yyy as its key flags.  After calling this function, the
module disclaims flag definitions thereafter, so the key flags will
be correctly attributed to the caller of DEFINE_yyy.

After calling this function, the module will not be able to define
any more flags.  This function will affect all FlagValues objects.
   N)r/   	_getframe	f_globalsr
   get_module_object_and_namedisclaim_module_idsaddr5   )globals_for_callerr:   _s      r   disclaim_key_flagsr[     sD     }}Q'11112DE)&
""2f:.r   c                 |    [         R                  " 5       n[         R                  " 5       n[        UU UUUU4SU0UD6$ )z/Registers a flag whose value can be any string.r)   )r   ArgumentParserArgumentSerializerr+   r    r%   r&   r   r)   r*   r   r'   s           r   DEFINE_stringr`     sS     **,&224*	


 
 	
 r   c                 H    [        [        R                  " XU40 UD6X4U5      $ )a  Registers a boolean flag.

Such a boolean flag does not take an argument.  If a user wants to
specify a false value explicitly, the long option beginning with 'no'
must be used: i.e. --noflag

This flag will have a value of None, True or False.  None is possible
if default=None and the user does not specify the flag on the command
line.

Args:
  name: str, the flag name.
  default: bool|str|None, the default value of the flag.
  help: str, the help message.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  module_name: str, the name of the Python module declaring this flag. If not
    provided, it will be computed using the stack trace of this call.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: dict, the extra keyword args that are passed to Flag __init__.

Returns:
  a handle to defined flag.
)r#   r   BooleanFlag)r    r%   r&   r   r(   r)   r*   s          r   DEFINE_booleanrc   )  s,    B 
t4t4k
 r   c                     [         R                  " X45      n[         R                  " 5       n	[        UU UUUU	4SU0UD6n
[	        XUS9  U
$ )a  Registers a flag whose value must be a float.

If lower_bound or upper_bound are set, then this flag must be
within the given range.

Args:
  name: str, the flag name.
  default: float|str|None, the default value of the flag.
  help: str, the help message.
  lower_bound: float, min value of the flag.
  upper_bound: float, max value of the flag.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: dict, the extra keyword args that are passed to DEFINE.

Returns:
  a handle to defined flag.
r)   r   )r   FloatParserr^   r+   r!   r    r%   r&   r   r   r   r)   r*   r   r'   results              r   DEFINE_floatrh   O  sc    : ''A&224*

  	& 'vM	-r   c                     [         R                  " X45      n[         R                  " 5       n	[        UU UUUU	4SU0UD6n
[	        XUS9  U
$ )a  Registers a flag whose value must be an integer.

If lower_bound, or upper_bound are set, then this flag must be
within the given range.

Args:
  name: str, the flag name.
  default: int|str|None, the default value of the flag.
  help: str, the help message.
  lower_bound: int, min value of the flag.
  upper_bound: int, max value of the flag.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: dict, the extra keyword args that are passed to DEFINE.

Returns:
  a handle to defined flag.
r)   r   )r   IntegerParserr^   r+   r!   rf   s              r   DEFINE_integerrk   {  sc    : ))+C&224*

  	& 'vM	-r   c                 H    [        [        R                  " XX240 UD6UXV5      $ )al  Registers a flag whose value can be any string from enum_values.

Instead of a string enum, prefer `DEFINE_enum_class`, which allows
defining enums from an `enum.Enum` class.

Args:
  name: str, the flag name.
  default: str|None, the default value of the flag.
  enum_values: [str], a non-empty list of strings with the possible values for
    the flag.
  help: str, the help message.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  module_name: str, the name of the Python module declaring this flag. If not
    provided, it will be computed using the stack trace of this call.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: dict, the extra keyword args that are passed to Flag __init__.

Returns:
  a handle to defined flag.
)r#   r   EnumFlag)r    r%   enum_valuesr&   r   r(   r)   r*   s           r   DEFINE_enumro     s)    > 
nnTD>>
 r   c                 P    [        [        R                  " U UUU4SU0UD6XEU5      $ )a\  Registers a flag whose value can be the name of enum members.

Args:
  name: str, the flag name.
  default: Enum|str|None, the default value of the flag.
  enum_class: class, the Enum class with all the possible values for the flag.
  help: str, the help message.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  module_name: str, the name of the Python module declaring this flag. If not
    provided, it will be computed using the stack trace of this call.
  case_sensitive: bool, whether to map strings to members of the enum_class
    without considering case.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: dict, the extra keyword args that are passed to Flag __init__.

Returns:
  a handle to defined flag.
case_sensitive)r#   r   EnumClassFlag	r    r%   
enum_classr&   r   r(   rq   r)   r*   s	            r   DEFINE_enum_classru     sF    < 




	
 (  X
7 7r   c                 ~    [         R                  " 5       n[         R                  " S5      n[        UU UUUU4SU0UD6$ )aO  Registers a flag whose value is a comma-separated list of strings.

The flag value is parsed with a CSV parser.

Args:
  name: str, the flag name.
  default: list|str|None, the default value of the flag.
  help: str, the help message.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: Dictionary with extra keyword args that are passed to the Flag
    __init__.

Returns:
  a handle to defined flag.
,r)   )r   
ListParserCsvListSerializerr+   r_   s           r   DEFINE_listrz     sU    2 &&(&11#6*	


 
 	
 r   c                 |    [         R                  " US9n[         R                  " S5      n[        UU UUUU4SU0UD6$ )a2  Registers a flag whose value is a whitespace-separated list of strings.

Any whitespace can be used as a separator.

Args:
  name: str, the flag name.
  default: list|str|None, the default value of the flag.
  help: str, the help message.
  comma_compat: bool - Whether to support comma as an additional separator. If
    false then only whitespace is supported.  This is intended only for
    backwards compatibility with flags that used to be comma-separated.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: Dictionary with extra keyword args that are passed to the Flag
    __init__.

Returns:
  a handle to defined flag.
)comma_compat r)   )r   WhitespaceSeparatedListParserListSerializerr+   )	r    r%   r&   r|   r   r)   r*   r   r'   s	            r   DEFINE_spaceseplistr     sZ    : 99!&..s3*	


 
 	
 r   c           	      J    [        [        R                  " XX#U40 UD6XVU5      $ )a  Registers a generic MultiFlag that parses its args with a given parser.

Auxiliary function.  Normal users should NOT use it directly.

Developers who need to create their own 'Parser' classes for options
which can appear multiple times can call this module function to
register their flags.

Args:
  parser: ArgumentParser, used to parse the flag arguments.
  serializer: ArgumentSerializer, the flag serializer instance.
  name: str, the flag name.
  default: Union[Iterable[T], Text, None], the default value of the flag. If
    the value is text, it will be parsed as if it was provided from the
    command line. If the value is a non-string iterable, it will be iterated
    over to create a shallow copy of the values. If it is None, it is left
    as-is.
  help: str, the help message.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  module_name: A string, the name of the Python module declaring this flag. If
    not provided, it will be computed using the stack trace of this call.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: Dictionary with extra keyword args that are passed to the Flag
    __init__.

Returns:
  a handle to defined flag.
)r#   r   	MultiFlag)	r   r'   r    r%   r&   r   r(   r)   r*   s	            r   DEFINE_multir   D  s,    P 
oof$FF
* *r   c                 |    [         R                  " 5       n[         R                  " 5       n[        UUU UUU4SU0UD6$ )a  Registers a flag whose value can be a list of any strings.

Use the flag on the command line multiple times to place multiple
string values into the list.  The 'default' may be a single string
(which will be converted into a single-element list) or a list of
strings.


Args:
  name: str, the flag name.
  default: Union[Iterable[Text], Text, None], the default value of the flag;
    see `DEFINE_multi`.
  help: str, the help message.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: Dictionary with extra keyword args that are passed to the Flag
    __init__.

Returns:
  a handle to defined flag.
r)   )r   r]   r^   r   r_   s           r   DEFINE_multi_stringr   q  sS    < **,&224*	


 
 	
 r   c                 ~    [         R                  " X45      n[         R                  " 5       n	[        UU	U UUU4SU0UD6$ )ax  Registers a flag whose value can be a list of arbitrary integers.

Use the flag on the command line multiple times to place multiple
integer values into the list.  The 'default' may be a single integer
(which will be converted into a single-element list) or a list of
integers.

Args:
  name: str, the flag name.
  default: Union[Iterable[int], Text, None], the default value of the flag;
    see `DEFINE_multi`.
  help: str, the help message.
  lower_bound: int, min values of the flag.
  upper_bound: int, max values of the flag.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: Dictionary with extra keyword args that are passed to the Flag
    __init__.

Returns:
  a handle to defined flag.
r)   )r   rj   r^   r   
r    r%   r&   r   r   r   r)   r*   r   r'   s
             r   DEFINE_multi_integerr     sV    B ))+C&224*	


 
 	
 r   c                 ~    [         R                  " X45      n[         R                  " 5       n	[        UU	U UUU4SU0UD6$ )av  Registers a flag whose value can be a list of arbitrary floats.

Use the flag on the command line multiple times to place multiple
float values into the list.  The 'default' may be a single float
(which will be converted into a single-element list) or a list of
floats.

Args:
  name: str, the flag name.
  default: Union[Iterable[float], Text, None], the default value of the flag;
    see `DEFINE_multi`.
  help: str, the help message.
  lower_bound: float, min values of the flag.
  upper_bound: float, max values of the flag.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: Dictionary with extra keyword args that are passed to the Flag
    __init__.

Returns:
  a handle to defined flag.
r)   )r   re   r^   r   r   s
             r   DEFINE_multi_floatr     sV    B ''A&224*	


 
 	
 r   Tc                 ~    [         R                  " X%5      n[         R                  " 5       n	[        UU	U UUU4SU0UD6$ )a  Registers a flag whose value can be a list strings from enum_values.

Use the flag on the command line multiple times to place multiple
enum values into the list.  The 'default' may be a single string
(which will be converted into a single-element list) or a list of
strings.

Args:
  name: str, the flag name.
  default: Union[Iterable[Text], Text, None], the default value of the flag;
    see `DEFINE_multi`.
  enum_values: [str], a non-empty list of strings with the possible values for
    the flag.
  help: str, the help message.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  case_sensitive: Whether or not the enum is to be case-sensitive.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: Dictionary with extra keyword args that are passed to the Flag
    __init__.

Returns:
  a handle to defined flag.
r)   )r   
EnumParserr^   r   )
r    r%   rn   r&   r   rq   r)   r*   r   r'   s
             r   DEFINE_multi_enumr     sV    D &&{C&224*	


 
 	
 r   c           
      J    [        [        R                  " XX2US9UU4SU0UD6$ )a  Registers a flag whose value can be a list of enum members.

Use the flag on the command line multiple times to place multiple
enum values into the list.

Args:
  name: str, the flag name.
  default: Union[Iterable[Enum], Iterable[Text], Enum, Text, None], the
    default value of the flag; see `DEFINE_multi`; only differences are
    documented here. If the value is a single Enum, it is treated as a
    single-item list of that Enum value. If it is an iterable, text values
    within the iterable will be converted to the equivalent Enum objects.
  enum_class: class, the Enum class with all the possible values for the flag.
      help: str, the help message.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  module_name: A string, the name of the Python module declaring this flag. If
    not provided, it will be computed using the stack trace of this call.
  case_sensitive: bool, whether to map strings to members of the enum_class
    without considering case.
  required: bool, is this a required flag. This must be used as a keyword
    argument.
  **args: Dictionary with extra keyword args that are passed to the Flag
    __init__.

Returns:
  a handle to defined flag.
)rq   r)   )r#   r   MultiEnumClassFlagrs   s	            r   DEFINE_multi_enum_classr   '  sB    L 

.J	

 
 	
 r   c                   ^ X;  a  [         R                  " U5      eX!   m " U4S jS[        R                  5      nSTR                  -  n[        U" TR                  TR                  U TR                  UTR                  S9X#5      $ )a%  Defines an alias flag for an existing one.

Args:
  name: str, the flag name.
  original_name: str, the original flag name.
  flag_values: FlagValues, the FlagValues instance with which the flag will be
    registered. This should almost never need to be overridden.
  module_name: A string, the name of the module that defines this flag.

Returns:
  a handle to defined flag.

Raises:
  flags.FlagError:
    UnrecognizedFlagError: if the referenced flag doesn't exist.
    DuplicateFlagError: if the alias name has been used by some existing flag.
c                   l   > \ rS rSrSrU 4S jrS r\U 4S j5       r\R                  U 4S j5       rSr
g)	 DEFINE_alias.<locals>._FlagAliasip  zCOverrides Flag class so alias value is copy of original flag value.c                 R   > TR                  U5        U =R                  S-  sl        g )NrS   )parsepresent)selfargumentr8   s     r   r   &DEFINE_alias.<locals>._FlagAlias.parses  s    
jj
llalr   c                     U$ N )r   r   s     r   _parse_from_default4DEFINE_alias.<locals>._FlagAlias._parse_from_defaultw  s	     lr   c                    > TR                   $ r   r   )r   r8   s    r   r   &DEFINE_alias.<locals>._FlagAlias.value  s    ZZr   c                    > UTl         g r   r   )r   r   r8   s     r   r   r     s
    djr   r   N)rN   
__module____qualname____firstlineno____doc__r   r   propertyr   setter__static_attributes__)r8   s   r   
_FlagAliasr   p  s<    M   \\ r   r   zAlias for --%s.)boolean)
r   UnrecognizedFlagErrorr   r$   r    r#   r   r'   r%   r   )r    original_namer   r(   r   help_msgr8   s         @r   DEFINE_aliasr   V  s    , %

+
+M
::		#$5:: . *(	
++
//

,,
,,  "-
; ;r   )0r   
__future__r   r   r   r/   rJ   
absl.flagsr   r   r   r	   r
   r   typingr   r   r   ImportErrorenumrW   rX   r5   r0   rN   r!   FLAGSr+   r#   rA   rF   rQ   r[   r`   rc   rh   rk   ro   ru   rz   r   r   r   r   r   r   r   r   r   r   r   <module>r      sZ   '  % 
  ' "  "  "$$
 	      CKK$9!: ;K2 !!%T !!	+=^ -8,=,=04?@ -8,=,= $?N 0;/@/@ %>/. !!2 !!#T !!)` !!)b !!!R !!%7X !!#T !!(b !!**b !!(^ !!+d !!+f !!,h !!,d !!	:;c  
  s$   
G, G9 ,G65G69HH