HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/1784574/root/lib/python3/dist-packages/__pycache__/
Upload File :
Current File : //proc/1784574/root/lib/python3/dist-packages/__pycache__/configargparse.cpython-311.pyc
�

=�Xa�����dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
Z
ejdkrddlm
Z
nddl
m
Z
ejejejejejgZejdkre�ej��d�Znd�Zee��ZiZdd	�Zdd
�ZGd�dejejej��ZGd
�de��Z Gd�de!��Z"Gd�de ��Z#Gd�de ��Z$Gd�de ��Z%dZ&dZ'dZ(dZ)Gd�dej*��Z*d�Z+d�Z,ej-j+ej-_.e+ej-_+ej/Z/ejZejZejZej0Z0ej1Z1ej2Z2ej3Z3ej4Z4ej5Z5ej6Z6ej7Z7ej8Z8ej9Z9eZ:eZ;eZ<eZ=eZ>eZ?e*Z@e*ZAej-j+ej-_Bej-j+ej-_Ce*jDe*_Ee*jFe*_GeZHeZIeZJdS) z�
A drop-in replacement for `argparse` that allows options to also be set via config files and/or environment variables.

:see: `configargparse.ArgumentParser`, `configargparse.add_argument`
�N)�OrderedDict)�r)�StringIO)r�	c�6�t|tj��S�N)�
isinstance�argparse�BooleanOptionalAction��actions �0/usr/lib/python3/dist-packages/configargparse.py�<lambda>rs��
�6�8�Ca�0b�0b��c��dS)NF�rs rrrs���rc���|�d}|tvr td|�dt|�����|�dtj��|�dd��tdi|��t|<dS)	z�Creates a global ArgumentParser instance with the given name,
    passing any args other than "name" to the ArgumentParser constructor.
    This instance can then be retrieved using get_argument_parser(..)
    N�defaultz=kwargs besides 'name' can only be passed in the first time. 'z!' ArgumentParser already exists: �formatter_class�conflict_handler�resolver)�_parsers�
ValueError�
setdefaultr
�ArgumentDefaultsHelpFormatter�ArgumentParser��name�kwargss  r�init_argument_parserr &s����|����x����j��D�D�(�4�.�.�"�#�#�	#����'��)O�P�P�P�
���(�)�4�4�4�#�-�-�f�-�-�H�T�N�N�Nrc�v�|�d}t|��dks	|tvr
t|fi|��t|S)aReturns the global ArgumentParser instance with the given name. The 1st
    time this function is called, a new ArgumentParser instance will be created
    for the given name, and any args other than "name" will be passed on to the
    ArgumentParser constructor.
    Nrr)�lenrr rs  r�get_argument_parserr#9sG���|���
�6�{�{�Q���$�h�.�.��T�,�,�V�,�,�,��D�>�rc��eZdZdZdS)� ArgumentDefaultsRawHelpFormatterzCHelpFormatter that adds default values AND doesn't do line-wrappingN��__name__�
__module__�__qualname__�__doc__rrrr%r%Hs������N�M��Drr%c�$�eZdZdZd�Zd�Zd�ZdS)�ConfigFileParserzRThis abstract class can be extended to add support for new config file
    formatsc� �td���)z3Returns a string describing the config file syntax.z*get_syntax_description(..) not implemented��NotImplementedError��selfs r�get_syntax_descriptionz'ConfigFileParser.get_syntax_descriptionTs��!�"N�O�O�Orc� �td���)aHParses the keys and values from a config file.

        NOTE: For keys that were specified to configargparse as
        action="store_true" or "store_false", the config file value must be
        one of: "yes", "no", "true", "false". Otherwise an error will be raised.

        Args:
            stream (IO): A config file input stream (such as an open file object).

        Returns:
            OrderedDict: Items where the keys are strings and the
            values are either strings or lists (eg. to support config file
            formats like YAML which allow lists).
        zparse(..) not implementedr.)r1�streams  r�parsezConfigFileParser.parseXs��"�"=�>�>�>rc� �td���)a�Does the inverse of config parsing by taking parsed values and
        converting them back to a string representing config file contents.

        Args:
            items: an OrderedDict of items to be converted to the config file
                format. Keys should be strings, and values should be either strings
                or lists.

        Returns:
            Contents of config file as a string
        zserialize(..) not implementedr.)r1�itemss  r�	serializezConfigFileParser.serializeis��"�"A�B�B�BrN�r'r(r)r*r2r5r8rrrr,r,PsS��������P�P�P�?�?�?�"C�C�C�C�Crr,c��eZdZdZdS)�ConfigFileParserExceptionz'Raised when config file parsing failed.Nr&rrrr;r;xs������1�1�1�1rr;c�$�eZdZdZd�Zd�Zd�ZdS)�DefaultConfigFileParsera�
    Based on a simplified subset of INI and YAML formats. Here is the
    supported syntax

    .. code::

        # this is a comment
        ; this is also a comment (.ini style)
        ---            # lines that start with --- are ignored (yaml style)
        -------------------
        [section]      # .ini-style section names are treated as comments

        # how to specify a key-value pair (all of these are equivalent):
        name value     # key is case sensitive: "Name" isn't "name"
        name = value   # (.ini style)  (white space is ignored, so name = value same as name=value)
        name: value    # (yaml style)
        --name value   # (argparse style)

        # how to set a flag arg (eg. arg which has action="store_true")
        --name
        name
        name = True    # "True" and "true" are the same

        # how to specify a list arg (eg. arg which has action="append")
        fruit = [apple, orange, lemon]
        indexes = [1, 12, 35 , 40]

    c�
�d}|S)NzrConfig file syntax allows: key=value, flag=true, stuff=[a,b,c] (for details, see syntax at https://goo.gl/R74nmi).r�r1�msgs  rr2z.DefaultConfigFileParser.get_syntax_description�s��E���
rc��t��}t|��D�]�\}}|���}|r|ddvs|�d��r�<t	jd|��}|�r|�d��}|�d��}|�d��}|�d��}	|�|�	|d	krd
}n|�d}|�d��ri|�d
��rT	tj	|��}n>#t$r1}
d�|dd��d��D��}Yd}
~
nd}
~
wwxYw|	r.|	���dd����}	|||<��ntd�
|t|dd��|�����|S)Nr)�#�;�[z---zn^(?P<key>[^:=;#\s]+)\s*(?:(?P<equal>[:=\s])\s*([\'"]?)(?P<value>.+?)?\3)?\s*(?:\s[;#]\s*(?P<comment>.*?)\s*)?$�key�equal�value�comment� ��truerD�]c�6�g|]}|�����Sr��strip��.0�elems  r�
<listcomp>z1DefaultConfigFileParser.parse.<locals>.<listcomp>�� �� Q� Q� Q�$������ Q� Q� Qr�����,zUnexpected line {} in {}: {}rr4)r�	enumeraterO�
startswith�re�match�group�endswith�json�loads�	Exception�splitr;�format�getattr)r1r4r7�i�liner[rErFrGrH�es           rr5zDefaultConfigFileParser.parse�s����
�
�� ��(�(�	>�	>�G�A�t��:�:�<�<�D��
�4��7�o�5�5�����9O�9O�5���H�F�GK�M�M�E��
>��k�k�%�(�(�����G�,�,�����G�,�,���+�+�i�0�0���=�U�%6�5�C�<�<��E�E��]�"�E��#�#�C�(�(�R�U�^�^�C�-@�-@�R�R� $�
�5� 1� 1����$�R�R�R� Q� Q�%��"��+�:K�:K�C�:P�:P� Q� Q� Q�����������R�����:�%�m�m�o�o�a�b�b�1�7�7�9�9�G�"��c�
�
�/�0N�0U�0U�VW��F�F�H�5�5�t�1=�1=�>�>�>��s�D�
E�!'E
�
Ec�R�t��}|���D]q\}}t|t��r.dd�tt|����zdz}|�d�||�����r|�	��S)NrD�, rLz{} = {}
)
rr7r	�list�join�map�str�writerb�getvalue)r1r7�rrErGs     rr8z!DefaultConfigFileParser.serialize�s����J�J���+�+�-�-�	4�	4�J�C���%��&�&�
;��D�I�I�c�#�u�o�o�6�6�6�s�:��
�G�G�K�&�&�s�E�2�2�3�3�3�3��z�z�|�|�rNr9rrrr=r=|sL��������:���
"�"�"�H����rr=c�$�eZdZdZd�Zd�Zd�ZdS)�ConfigparserConfigFileParserz,parses INI files using pythons configparser.c�
�d}|S)Na�Uses configparser module to parse an INI file which allows multi-line
        values.

        Allowed syntax is that for a ConfigParser with the following options:

            allow_no_value = False,
            inline_comment_prefixes = ("#",)
            strict = True
            empty_lines_in_values = False

        See https://docs.python.org/3/library/configparser.html for details.

        Note: INI file sections names are still treated as comments.
        rr?s  rr2z3ConfigparserConfigFileParser.get_syntax_description�s��
���
rc�J�ddl}ddlm}|�dddddd���}	|�|�����n$#t$r}td|z���d}~wwxYwt��}|�	��D]�}||�
��D]p\}}	|	�d	d
���dd
��}
d|
vr8d
|
vr4|
�d��d}d|vr||
��||<�e|
||<�k|
||<�q��|S)Nr)�literal_eval)�=�:F)rBrCT)�
delimiters�allow_no_value�comment_prefixes�inline_comment_prefixes�strict�empty_lines_in_values�Couldn't parse config file: %s�
rI�
rDrL�{)
�configparser�astrt�ConfigParser�read_string�readr`r;r�sectionsr7�replacera)r1r4r�rt�configrf�result�section�k�v�multiLine2SingleLine�prelist_strings            rr5z"ConfigparserConfigFileParser.parse�s�������$�$�$�$�$�$��*�*� � �&�$-��"'�
+�
�
��	R����v�{�{�}�}�-�-�-�-���	R�	R�	R�+�,L�q�,P�Q�Q�Q�����	R�����������(�(�	5�	5�G��g��,�,�.�.�
5�
5���!�'(�y�y��c�':�':�'B�'B�4��'L�'L�$��.�.�.�3�:N�3N�3N�%9�%?�%?��%D�%D�Q�%G�N��.�0�0�$0�L�1E�$F�$F��q�	�	�$8��q�	�	� 4�F�1�I�I�
5��
s�'A�
A0�A+�+A0c��ddl}ddl}|�dddd���}d|i}|�|��|���}|�|��|�d��|���S)NrF)rBT)rxrzr{r|�DEFAULT)r��ior��	read_dictrrm�seekr�)r1r7r�r�r�r4s      rr8z&ConfigparserConfigFileParser.serializes��������	�	�	��*�*� �$*��"'�	+�
�
���E�"������������������V�������A�����{�{�}�}�rNr9rrrrqrq�sH������6�6����"!�!�!�F����rrqc�,�eZdZdZd�Zd�Zd�Zdd�ZdS)	�YAMLConfigFileParserzdParses YAML config files. Depends on the PyYAML module.
    https://pypi.python.org/pypi/PyYAML
    c�
�d}|S)NzThe config file uses YAML syntax and must represent a YAML 'mapping' (for details, see http://learn.getgrav.org/advanced/yaml).rr?s  rr2z+YAMLConfigFileParser.get_syntax_descriptions��S���
rc�L�	ddl}n#t$rtd���wxYw|S)zjlazy-import PyYAML so that configargparse doesn't have to depend
        on it unless this parser is used.rNzJCould not import yaml. It can be installed by running 'pip install PyYAML')�yaml�ImportErrorr;)r1r�s  r�
_load_yamlzYAMLConfigFileParser._load_yaml!sT��	G��K�K�K�K���	G�	G�	G�+�-F�G�G�
G�	G�����s��!c���|���}	|�|��}n$#t$r}td|z���d}~wwxYwt	|t
��s7tdt
|dd���dt|��j�d����t��}|�
��D]5\}}t	|t��r|||<� |��#t|��||<�6|S)Nr}z_The config file doesn't appear to contain 'key: value' pairs (aka. a YAML mapping). yaml.load('rr4z') returned type 'z' instead of 'dict'.)
r��	safe_loadr`r;r	�dictrc�typer'rr7rirl)r1r4r��
parsed_objrfr�rErGs        rr5zYAMLConfigFileParser.parse,s#����� � ��	R�����/�/�J�J���	R�	R�	R�+�,L�q�,P�Q�Q�Q�����	R�����*�d�+�+�	P�+�+�����1�1�1�1�D��4D�4D�4M�4M�4M�-O�P�P�
P�
����$�*�*�,�,�	)�	)�J�C���%��&�&�
)�#��s������!�%�j�j��s����
s�,�
A
�A�A
Fc�v�|���}t|��}|�||���S)N)�default_flow_style)r�r��dump)r1r7r�r�s    rr8zYAMLConfigFileParser.serializeFs7����� � ���U�����y�y��3E�y�F�F�FrN�F)r'r(r)r*r2r�r5r8rrrr�r�se�����������
	�	�	����4G�G�G�G�G�Grr��command_line�environment_variables�config_file�defaultsc��eZdZdZd�Zdddejfd�Zdddejdfd�Zd�Z	dd�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zejfd�Zd�ZdS)rz�Drop-in replacement for `argparse.ArgumentParser` that adds support for
    environment variables and ``.ini`` or ``.yaml-style`` config files.
    c�D�|�dd��}|�dd��}|�dd��}|�dg��}|�dd��}|�d	t��}|�d
g��}	|�dd��}
|�dd
��}|�dg��}|�dd��}
|�dt��|_||_||_||_tjj	|g|�Ri|��|�t��|_
n|��|_
||_||_|	r|j
|	d|
|dd��|r|j
|dd|
dd��dSdS)aR
Supports args of the `argparse.ArgumentParser` constructor
        as \*\*kwargs, as well as the following additional args.

        Arguments:
            add_config_file_help: Whether to add a description of config file
                syntax to the help message.
            add_env_var_help: Whether to add something to the help message for
                args that can be set through environment variables.
            auto_env_var_prefix: If set to a string instead of None, all config-
                file-settable options will become also settable via environment
                variables whose names are this prefix followed by the config
                file key, all in upper case. (eg. setting this to ``foo_`` will
                allow an arg like ``--my-arg`` to also be set via the FOO_MY_ARG
                environment variable)
            default_config_files: When specified, this list of config files will
                be parsed in order, with the values from each config file
                taking precedence over previous ones. This allows an application
                to look for config files in multiple standard locations such as
                the install directory, home directory, and current directory.
                Also, shell \* syntax can be used to specify all conf files in a
                directory. For example::

                    ["/etc/conf/app_config.ini",
                    "/etc/conf/conf-enabled/*.ini",
                    "~/.my_app_config.ini",
                    "./app_config.txt"]

            ignore_unknown_config_file_keys: If true, settings that are found
                in a config file but don't correspond to any defined
                configargparse args will be ignored. If false, they will be
                processed and appended to the commandline like other args, and
                can be retrieved using parse_known_args() instead of parse_args()
            config_file_open_func: function used to open a config file for reading
                or writing. Needs to return a file-like object.
            config_file_parser_class: configargparse.ConfigFileParser subclass
                which determines the config file format. configargparse comes
                with DefaultConfigFileParser and YAMLConfigFileParser.
            args_for_setting_config_path: A list of one or more command line
                args to be used for specifying the config file path
                (eg. ["-c", "--config-file"]). Default: []
            config_arg_is_required: When args_for_setting_config_path is set,
                set this to True to always require users to provide a config path.
            config_arg_help_message: the help message to use for the
                args listed in args_for_setting_config_path.
            args_for_writing_out_config_file: A list of one or more command line
                args to use for specifying a config file output path. If
                provided, these args cause configargparse to write out a config
                file with settings based on the other provided commandline args,
                environment variants and defaults, and then to exit.
                (eg. ["-w", "--write-out-config-file"]). Default: []
            write_out_config_file_arg_help_message: The help message to use for
                the args in args_for_writing_out_config_file.
        �add_config_file_helpT�add_env_var_help�auto_env_var_prefixN�default_config_files�ignore_unknown_config_file_keysF�config_file_parser_class�args_for_setting_config_path�config_arg_is_required�config_arg_help_messagezconfig file path� args_for_writing_out_config_file�&write_out_config_file_arg_help_messagezftakes the current command line args and writes them out to a config file at the given path, then exits�config_file_open_funcr�)�dest�required�help�is_config_file_arg�"write_out_config_file_to_this_path�CONFIG_OUTPUT_PATH)r��metavarr��is_write_out_config_file_arg)�popr=�open�_config_file_open_func�_add_config_file_help�_add_env_var_help�_auto_env_var_prefixr
r�__init__�_config_file_parser�_default_config_files� _ignore_unknown_config_file_keys�add_argument)r1�argsrr�r�r�r�r�r�r�r�r�r�r�s              rr�zArgumentParser.__init__]s��t &�z�z�*@�$�G�G��!�:�:�&8�$�?�?��$�j�j�)>��E�E��%�z�z�*@�"�E�E��*0�*�*�-�u�+6�+6�'�#)�:�:�.H�.E�$G�$G� �'-�z�z�*�B�(0�(0�$�!'���,D�e�!L�!L��"(�*�*�-F�-?�#A�#A��+1�:�:�.��,4�,4�(�17���4�7%�2&�2&�.�
'-�j�j�1H�$�&O�&O��#�%9��"�!1���$7��!���(��?��?�?�?��?�?�?�$�+�'>�'@�'@�D�$�$�'?�'?�'A�'A�D�$�%9��"�0O��-�'�	)��D��;�-�/�6M�#'�
)�
)�
)�
)�,�	3��D��?�9�,�;�-1�	
3�
3�
3�
3�
3�
3�	3�	3rNc��|�||||d���\}}|r+|�dd�|��z��|S)a�Supports all the same args as the `argparse.ArgumentParser.parse_args()`,
        as well as the following additional args.

        Arguments:
            args: a list of args as in argparse, or a string (eg. "-x -y bla")
            config_file_contents: String. Used for testing.
            env_vars: Dictionary. Used for testing.

        Returns:
            argparse.Namespace: namespace
        F)r��	namespace�config_file_contents�env_vars�ignore_help_argszunrecognized arguments: %srI)�parse_known_args�errorrj)r1r�r�r�r��argvs      r�
parse_argszArgumentParser.parse_args�sc���*�*���!5��"�+�$�$�
��d��	F��J�J�3�c�h�h�t�n�n�D�E�E�E��rFc��������tjdd��n9t�t��r�����nt�����jD]}|j|_�|rd��D���t���_
�r"dt���f}d|i�j
t<�j�ƉjD]�}��
|��}|r�|js�|js�|js�|js�t|t"j��sot|t"j��sU|d��j��}	�j|	z�dd�����|_��g}
d}���fd	��jD��}|D]�}
|
j}�|}|
jst|
t"j��ryd
}|�d��rb|�d��rM	t9j|��}n7#t<$r*d
�|dd��d��D��}YnwxYw|
��|
||��z
}
��|r�|
z�n|
�z�|
r(t�fd�|D�����j
t@<tCd��jD����}|od�vpd�v}�fd��jD��}g}|�tE|��}d|_#|g}n|s��$���}tK|��D�]�}	�j&�'|��}n,#tP$r}��)|��Yd}~nd}~wwxYwtU|d��r|�+��n*#tU|d��r|�+��wwxYwg}d}|�,��D]�\}}||vr$||}
t[�|
j�j��}n3d}
�j.p)t[���/|��g�j��}|s�|��|
||��z
}t`�d|j#��}|�j
vrt���j
|<|
|f�j
||<|
r|
jst|
t"j��rd
}��|r�|z����|�z����t��}�jD]�}
|
jp|
jtbtdfv}t[�|
j�j��s.|r,|
j3�%|
j3thkst|
tj��r�i|
jr|
jd}n|
j6}|
t|
j3��f||<��|r|�j
tn<t"j8�9������\�}�fd��jD��}d�|D��}��:�|d
����|fS)a�Supports all the same args as the `argparse.ArgumentParser.parse_args()`,
        as well as the following additional args.

        Arguments:
            args: a list of args as in argparse, or a string (eg. "-x -y bla")
            config_file_contents (str). Used for testing.
            env_vars (dict). Used for testing.
            ignore_help_args (bool): This flag determines behavior when user specifies ``--help`` or ``-h``. If False,
                it will have the default behavior - printing help and exiting. If True, it won't do either.

        Returns:
            tuple[argparse.Namespace, list[str]]: tuple namescpace, unknown_args
        NrUc��g|]}|dv�|��	S))�-h�--helpr)rQ�args  rrSz3ArgumentParser.parse_known_args.<locals>.<listcomp>�s#��G�G�G�C�3�6F�+F�+F�C�+F�+F�+FrrJr�-�_Fc�x��g|]6}|js-|jr&|j�v�t�|j�j���4|��7Sr)�is_positional_arg�env_var�already_on_command_line�option_strings�prefix_chars)rQ�ar�r�r1s  ���rrSz3ArgumentParser.parse_known_args.<locals>.<listcomp>sd���'\�'\�'\�Q��&�'\�+,�9�'\�9:��h�9N�9N�/��a�6F��HY�Z�Z�:O�()�9N�9N�9NrTrDrLc�6�g|]}|�����SrrNrPs  rrSz3ArgumentParser.parse_known_args.<locals>.<listcomp>)rTrrVrWc�<��g|]}|j|�|jff��Sr)r�)rQr�r�s  �rrSz3ArgumentParser.parse_known_args.<locals>.<listcomp>4s<���:�:�:���)�a��!�)�!4�5�6�:�:�:rc3�NK�|] }t|tj���|V��!dSr)r	r
�_HelpAction�rQr�s  r�	<genexpr>z2ArgumentParser.parse_known_args.<locals>.<genexpr>8sQ���� M� M��
�1�h�6J�(K�(K� M�
� M� M� M� M� M� Mrr�r�c�F��i|]}��|��D]}||���Sr)�get_possible_config_keys)rQr
�
config_keyr1s   �r�
<dictcomp>z3ArgumentParser.parse_known_args.<locals>.<dictcomp>>sV���E�E�E�F�"�;�;�F�C�C�E�E��(��E�E�E�Erz
method arg�close�|)r�r�c�^��g|])}t|dd���t�|jd����*S)r�FN)rcr�)rQr�r�s  �rrSz3ArgumentParser.parse_known_args.<locals>.<listcomp>�sO���S�S�S�!� '��+I�5� Q� Q�S�W�Y����=�=�S�S�Src��g|]}|�|��Srrr�s  rrSz3ArgumentParser.parse_known_args.<locals>.<listcomp>�s��K�K�K�1�Q�]�Q�]�]�]r)�
exit_after);�sysr�r	rlrari�_actionsr�r�r�_source_to_settings�_COMMAND_LINE_SOURCE_KEYr�r�r�r�r�r
�_VersionActionr�rOr�r��upper�nargs�
_AppendActionrYr]r^r_r`� convert_item_to_command_line_arg�_ENV_VAR_SOURCE_KEY�anyrr�_open_config_files�reversedr�r5r;r��hasattrr�r7r�r��4get_command_line_key_for_unknown_config_file_setting�_CONFIG_FILE_SOURCE_KEY�OPTIONAL�ZERO_OR_MOREr�SUPPRESS�#ACTION_TYPES_THAT_DONT_NEED_A_VALUEr��_DEFAULTS_SOURCE_KEYrr��write_config_file)r1r�r�r�r�r�r��a_v_pair�config_file_keys�stripped_config_file_key�env_var_argsr��actions_with_env_var_valuesr
rErG�supports_help_arg�skip_config_file_parsing�known_config_keys�config_streamsr4�config_itemsrf�config_args�discard_this_key�
source_key�default_settings�cares_about_default_value�unknown_args�output_file_pathss``` `                         rr�zArgumentParser.parse_known_args�s�������*�<��8�A�B�B�<�D�D�
��c�
"�
"�	��:�:�<�<�D�D���:�:�D���	7�	7�A�&'�&6�"6�A����	H�G�G�4�G�G�G�D�$/�=�=�� ��	P��d�4�j�j�)�H�BD�h��D�$�%=�>��$�0��]�	
U�	
U��#'�#@�#@��#C�#C� �#�U�Q�Y�U�!�:M�U��+�U�/0�/M�U��q�(�"9�:�:�U��q�(�"6�7�7�U�0@��/B�/H�/H��)�0+�0+�,�!%�!:�!9�":�;B�7�3��;L�;L�U�U�W�W��I������'\�'\�'\�'\�'\�'\�$�-�'\�'\�'\�#�2�	$�	$�F��.�C��S�M�E��|�
R�z�&�(�2H�I�I�
R����#�#�C�(�(�R�U�^�^�C�-@�-@�R�R� $�
�5� 1� 1����$�R�R�R� Q� Q�%��"��+�:K�:K�C�:P�:P� Q� Q� Q����R����
�D�A�A���U�$�$�
$�L�L��	'��,�&�D�D��$�&�D��	;�<G�:�:�:�:�8�:�:�:�=;�=;�D�$�%8�9�
 � M� M��}� M� M� M�M�M��#4�$.��D�L�,�H��,�	!�E�E�E�E�d�m�E�E�E�����+��2�3�3�F�&�F�K�$�X�N�N�)�	;�!�4�4�T�:�:�N��~�.�.�'	*�'	*�F�
#�#�7�=�=�f�E�E����,�
�
�
��
�
�1�
�
�
�
�
�
�
�
�����
�����6�7�+�+�#��L�L�N�N�N����6�7�+�+�#��L�L�N�N�N�N�#�����K��E�*�0�0�2�2�
%�
%�
��U��+�+�+�.�s�3�F�'>��f�3�T�5F�(H�(H�$�$�"�F�'+�'L�(/�/� �!�V�V�WZ�[�[�\� �-�/�/�%�(�	%��4�#H�#H���U�$,�$,�,�K�+B�+B�+B�F�K�K�!P�J�!��)A�A�A�?J�}�}��0��<�AG���D�,�Z�8��=��%�6�<�%�"�6�8�+A�B�B�%� $����
*��k�)���"�T�)���'�=�=���m�	F�	F�F�-3�-E�)E�*9����<� 8�8�
&�'��f�.C�T�EV�W�W�
F�1�
F��N�*��N�h�.�.��v�'J�K�K�/���(�&� �/��3�C�C� �+�C�)/��V�^�1D�1D�(E� ��%�%��	N�=M�D�$�%9�:�#+�"9�"J�"J��t�y�#K�#2�#2��	�<�S�S�S�S�t�}�S�S�S��K�K�(9�K�K�K�����y�*;���M�M�M��,�&�&sB�8H
�
1I�I�L4�3N�4
M�>M�N�M�N�'N,c��|jS)ar
        If called after `parse_args()` or `parse_known_args()`, returns a dict that contains up to 4 keys corresponding
        to where a given option's value is coming from:
        - "command_line"
        - "environment_variables"
        - "config_file"
        - "defaults"
        Each such key, will be mapped to another dictionary containing the options set via that method. Here the key
        will be the option name, and the value will be a 2-tuple of the form (`argparse.Action` obj, `str` value).

        Returns:
            dict[str, dict[str, tuple[argparse.Action, str]]]: source to settings dict
        )r�r0s r�get_source_to_settings_dictz*ArgumentParser.get_source_to_settings_dict�s
���'�'rc�X�|D]g}	|�|d��5}	ddd��n#1swxYwY�3#t$r(}td�||�����d}~wwxYw|r�|�|j|��}|j�|��}|D]E}|�|d��5}|�|��ddd��n#1swxYwY�Ftdd�
|��z��|r|�d��dSdSdS)a4Write the given settings to output files.

        Args:
            parsed_namespace: namespace object created within parse_known_args()
            output_file_paths: any number of file paths to write the config to
            exit_after: whether to exit the program after writing the config files
        �wNz Couldn't open {} for writing: {}zWrote config file to rhr)r��IOErrorrrb� get_items_for_config_file_outputr�r�r8rm�printrj�exit)	r1�parsed_namespacerr��output_file_path�output_filerfr�
file_contentss	         rrz ArgumentParser.write_config_file�s���!2�	*�	*��
*��0�0�1A�3�G�G��;�����������������������
*�
*�
*� �!C�!J�!J�$�a�")�")�*�*�*�����
*�����	��@�@��(�*:�<�<�L� �4�>�>�|�L�L�M�$5�
5�
5� ��0�0�1A�3�G�G�5�;��%�%�m�4�4�4�5�5�5�5�5�5�5�5�5�5�5����5�5�5�5��
�)�D�I�I�6G�,H�,H�H�I�I�I��
��	�	�!������	�	�
�
s?�6�*�6�.	�6�.	�6�
A(�#A#�#A(�<C�C"	�%C"	c�`�|�|j��}|jddz|z}|S)aMCompute a commandline arg key to be used for a config file setting
        that doesn't correspond to any defined configargparse arg (and so
        doesn't have a user-specified commandline arg key).

        Args:
            key: The config file key that was being set.

        Returns:
            str: command line key
        r�)rOr�)r1rE�key_without_prefix_chars�command_line_keys    rr�zCArgumentParser.get_command_line_key_for_unknown_config_file_setting�s8��$'�9�9�T�->�#?�#?� ��,�Q�/��1�4L�L���rc���t��}|���D�]�\}}|tkr�|d\}}|jD]�}|�|��}	|	r{|jstt
||j|j��rYt||j
d��}
|
�At|
t��r!t|
�����}
|
||	d<����|tkrY|���D]B\}\}}
|�|��}	|	r#t||j
d��}
|
�|
||	d<�C��|�t"��r$|���D]
\}\}}
|
||<���[|t$krW|���D]B\}\}}
|�|��}	|	r#t||j
d��}
|
�|
||	d<�C���|S)a�Converts the given settings back to a dictionary that can be passed
        to ConfigFormatParser.serialize(..).

        Args:
            source_to_settings: the dictionary described in parse_known_args()
            parsed_namespace: namespace object created within parse_known_args()
        Returns:
            OrderedDict: where keys are strings and values are either strings
            or lists
        rJNr)rr7r�r�r�r�r�r�r�rcr�r	�boolrl�lowerr�rYr�r)r1�source_to_settingsr�config_file_items�source�settingsr��existing_command_line_argsr
rrGrEs            rrz/ArgumentParser.get_items_for_config_file_output�sW��(�M�M�� 2� 8� 8� :� :�	K�	K��F�H��1�1�1�08���-��-�"�m�
K�
K�F�'+�'D�'D�V�'L�'L�$�'�K��0H�K�/�0J�06�0E�04�0A�C�C�K�!(�(8�&�+�t� L� L�� �,�)�%��6�6�;�(+�E�
�
�(8�(8�(:�(:��EJ�-�.>�q�.A�B��
K��.�.�.�,4�N�N�,<�,<�K�K�(�C��&�%�'+�'D�'D�V�'L�'L�$�'�K� '�(8�&�+�t� L� L�� �,�EJ�-�.>�q�.A�B��K��"�"�#:�;�;�	
K�,4�N�N�,<�,<�3�3�(�C��&�%�-2�%�c�*�*�3��/�/�/�,4�N�N�,<�,<�K�K�(�C��&�%�'+�'D�'D�V�'L�'L�$�'�K� '�(8�&�+�t� L� L�� �,�EJ�-�.>�q�.A�B��� � rc��	�g}|�|�|��}nt|��s
|jd}|��?t|t���r)|���dvrHt|��s|�|���n�|�|jd���n�|���dvr3t|��s�n�|�|jd���n_t|tj��rJ|D]$�	t�	fd�|jD����rd}�%||jdgt|��zz
}�n�|�d|�d	|�d
����n�t|t���rg|duoj|j
duoat|tj��pt|tj��o-|j
dvp$t|j
t��o
|j
dk}|�t|tj��r�|D]}}|rRt|t��r=|�|��|D]$}|�t!|�����%�V|�|�dt!|�������~n�|r=|�|��|D]$}|�t!|�����%n||�|�d
|�d���n`t|t ��r|�|�d|����n0t#d�t'|��|�����|S)a�Converts a config file or env var key + value to a list of
        commandline args to append to the commandline.

        Args:
            action: The argparse Action object for this setting, or None if this
                config file setting doesn't correspond to any defined
                configargparse arg.
            key: string (config file key or env var name)
            value: parsed value of type string or list

        Returns:
            list[str]: args
        NrV)rK�yes�1r)�false�no�0rUc�:��g|]}��|����Sr�rY)rQ�sr�s  �rrSzCArgumentParser.convert_item_to_command_line_arg.<locals>.<listcomp>*s%���M�M�M�!�C�N�N�1�-�-�M�M�MrzUnexpected value for z: 'z5'. Expecting 'true', 'false', 'yes', 'no', '1' or '0')�+�*ruz can't be set to a list 'zS' unless its action type is changed to 'append' or nargs is set to '*', '+', or > 1z&Unexpected value type {} for value: {})r��is_boolean_optional_actionr�r	rr)�appendr
�_CountActionr��intr�rir��_StoreActionr�rlrrbr�)
r1r
rErGr�r&�accepts_list_and_has_nargs�	list_elem�sub_elemr�s
         @rr�z/ArgumentParser.convert_item_to_command_line_args�������>��I�I�#�N�N�
��.�f�5�5�
=�#)�#8��#<� ���*�V�5X�"Y�"Y���{�{�}�}� 4�4�4�1�&�9�9�:��K�K�!1�3�3�3�3��K�K�� 5�a� 8�9�9�9�9������"6�6�6�1�&�9�9�:���K�K�� 5�a� 8�9�9�9�9��F�H�$9�:�:�
N��"�"�C��M�M�M�M�v�7L�M�M�M�N�N�"� !�����.�q�1�2�S��Z�Z�?�?����
�
�
�AD���e�e�e�M�N�N�N�N�
��t�
$�
$�	%�)/�t�);�*���TX�@X�*��f�h�&;�<�<�j�
�6�S[�Si�@j�@j�*���
�*�b�z�&�,��/L�/L�/a�QW�Q]�`a�Qa�
'��~��F�H�4J�!K�!K�~�!&�T�T�I�1�T�j��D�6Q�6Q�T����$4�5�5�5�(1�7�7�H� �K�K��H�
�
�6�6�6�6�7����0@�0@�0@�#�i�.�.�.�%Q�S�S�S�S�
T�,�
_����-�/�/�/�!&�2�2�I��K�K��Y���1�1�1�1�2��
�
�RU�RU�RU�W\�W\�W\�^�_�_�_�_�
��s�
#�
#�	%��K�K�$4�$4�$4�e�e�<�>�>�>�>��E�L�L��U���U�$�$�%�%�
%��rc���g}t|dd��r|S|jD]1�t�fd�|jD����r|�dd��gz
}�2|S)aThis method decides which actions can be set in a config file and
        what their keys will be. It returns a list of 0 or more config keys that
        can be used to set the given action's value in a config file.

        Returns:
            list[str]: keys
        r�Nc3�H�K�|]}��d|z��V��dS)r$Nr6)rQ�cr�s  �rr�z:ArgumentParser.get_possible_config_keys.<locals>.<genexpr>]s3�����B�B�1�3�>�>�!�A�#�&�&�B�B�B�B�B�Brr$)rcr�r�r�)r1r
�keysr�s   @rr�z'ArgumentParser.get_possible_config_keysNs|������6�9�4�@�@�	��K��(�	'�	'�C��B�B�B�B��0A�B�B�B�B�B�
'���Q�R�R��#��&����rc��g}ttjttjj|j����D]/}|D]*}|�|�|�����+�0d�|jD��}|s|S|D�]Q}tj
|jd���}|�|��d�}tj||��|_|�|���}	|	s�i|	\}
}t#|
|jd��}|s��tj�|��}	|�|��}
n�#t&$r�}t)|j��dkr|j\}}nt-|��}|D]'}	|����#t&$rY�$wxYw|�d|�d	|����Yd}~nd}~wwxYw||
gz
}��S|S)
a�Tries to parse config file path(s) from within command_line_args.
        Returns a list of opened config files, including files specified on the
        commandline as well as any default_config_files specified in the
        constructor that are present on disk.

        Args:
            command_line_args: List of all args
        
        Returns:
            list[IO]: open config files
        c�4�g|]}t|dd���|��S�r�F�rcr�s  rrSz5ArgumentParser._open_config_files.<locals>.<listcomp>vsA��(Q�(Q�(Q����3G��(O�(O�(Q�
�(Q�(Q�(QrF)r��add_helpc��dSrr)r1�messages  r�error_methodz7ArgumentParser._open_config_files.<locals>.error_method�s���r)r�Nr$zUnable to open config file: z	. Error: )rk�glob�os�path�
expanduserr�r;r�r�r
rr��_add_action�types�
MethodTyper�r�rcr�r`r"r�rlr�)r1�command_line_args�config_files�files�f�user_config_file_arg_actionsr
�
arg_parserrM�
parsed_argr�r��user_config_filer4rf�errnor@r�s                  rr�z!ArgumentParser._open_config_filesbs��������C���(:�D�<V�$W�$W�X�X�	D�	D�E��
D�
D���#�#�D�$?�$?��$B�$B�C�C�C�C�
D�
(Q�(Q��}�(Q�(Q�(Q�$�,�	 ���2�-	%�-	%�F�"�0�!�.�� � � �J�
�"�"�6�*�*�*�

�
�
�$�/��j�I�I�J��$�4�4�:K�4�L�L�J��
��%�L�I�q�&�y�&�+�t�D�D��#�
�� "�w�1�1�2B�C�C��
��4�4�5E�F�F�����

�

�

��q�v�;�;�!�#�#�!"��J�E�3�3��a�&�&�C�#/���K��#�)�)�+�+�+�+��$�����������
�
�
�$�$�$�c�c��������������

����
�V�H�$�L�L��s<�-E�
G�
6G	�F�G	�
F&	�#G	�%F&	�&G	�	Gc���tdtdtdtdi}t	��}|j���D�]\}}|�d��}||dt|dd���z}|�	|��|���D]�\}\}}|r-|�	d	�
|d
z|�����7t|t��r|�	d|z���et|t��r+|�	dd�|��z������|���S)
z�Returns a string with all args and settings and where they came from
        (eg. commandline, config file, environment variable or default)

        Returns:
            str: source to settings string
        zCommand Line Args: zEnvironment Variables:
zConfig File (%s):
z
Defaults:
r�rrUNz  {:<19}{}
rvz  %s
rI)r�r�r�rrr�r7ra�tuplermrbr	rlrirjrn)r1�source_key_to_display_value_mapror,r-rEr
rGs        r�
format_valueszArgumentParser.format_values�s\��
%�&;��!;�#�%:� �-�	+
�'�
�J�J�� $� 8� >� >� @� @�	<�	<��F�H��\�\�#�&�&�F�4�V�A�Y�?�%��q�r�r�
�BS�BS�S�F�
�G�G�F�O�O�O�(0���(8�(8�
<�
<�$��_�f�e��<��G�G�N�1�1�#�c�'�5�A�A�B�B�B�B�!�%��-�-�<�����5� 0�1�1�1�1�#�E�4�0�0�<�����3�8�8�E�?�?� :�;�;�;��
<��z�z�|�|�rc�T�|�|�����dS)zBPrints the format_values() string (to sys.stdout or another file).N)rmra)r1�files  r�print_valueszArgumentParser.print_values�s&���
�
�4�%�%�'�'�(�(�(�(�(rc�$��d}d}d}�jr�j}d�jdz}�fd��jD��}d��jD��}|r�|s|r�d�_d}|d|�d	|dd�d
�z
}d�d�|D����}|rd
|z}|s|rG|dd�t|��tt
d|g����z��zz
}|d�j���zz
}�j	r_d��jD��}	|	D]K\}
}|j
tkr�d|
z}|j
sd|_
||j
vr|xj
|z
c_
d}d�_	�L|s|r.dg}
|rdg|
z}
|rdg|
z}
|dd�|
��zz
}t��
��jd��}tj||��}t"j����|dkrd�|��ndzS)NrJFr$rc���g|]>}|jD]4}��|��r|jdk�"|j�)|j�0||f��5�?S)r�)r�r�r�r�r�)rQr�r�r1s   �rrSz.ArgumentParser.format_help.<locals>.<listcomp>�sq���$2�$2�$2��� �$2�$2��$(�$A�$A�!�$D�$D�$2���6�!�!�Q�%9�!��/�"�&)�!�H�!�!�!�!rc�4�g|]}t|dd���|��SrHrIr�s  rrSz.ArgumentParser.format_help.<locals>.<listcomp>�s@��#J�#J�#J��!(��,@�%�!H�!H�#J�1�#J�#J�#JrTzArgs that start with 'z' (eg. z") can also be set in a config filez or c3�>K�|]}|j�	|jdV��dS)rN)r�r�s  rr�z-ArgumentParser.format_help.<locals>.<genexpr>�sN����0F�0F��A�4D�0F��0@��0C�0F�0F�0F�0F�0F�0Frzspecified via z (%s).rIc�B�g|]}t|dd���|j|f��S)r�N)rcr�r�s  rrSz.ArgumentParser.format_help.<locals>.<listcomp>�s>��?�?�?�!�")�!�Y��"=�"=�?��	�1�~�?�?�?rz   [env var: %s]r�zconfig file valueszenvironment variableszT If an arg is specified in more than one place, then commandline values override %s.z which override �z
{}
)r�r�r�r�rjr_�filterr�r2r�r�r�max�_get_formatter�_width�textwrap�fillr
r�format_helprb)r1r@�added_config_file_help�added_env_var_helpr��cc�config_settable_args�config_path_actions�config_arg_string�env_var_actionsr�r��env_var_help_string�
value_sources�
text_widths`              rrqzArgumentParser.format_help�s�����!&��"���%�	O�#'�#=� ��4�$�Q�'�'�B�$2�$2�$2�$2�d�m�$2�$2�$2� �#J�#J��
�#J�#J�#J��$�
O�)=�
O�)<�
O�-2��*�)-�&���,.�B�B�0D�Q�0G��0J�0J�0J�L�L��$*�K�K�0F�0F�0�0F�0F�0F�%F�%F�!�$�M�(8�;L�(L�%�'�\�+<�\��8�f�k�k�%�8L�2M�2M�27��t�FW�EX�8Y�8Y�2Z�2Z�3[�'\�'\�\�\�C��s�T�5�L�L�N�N�N�N���!�	3�?�?�t�}�?�?�?�O�-�	
3�	
3�
����6�X�%�%��&8�7�&B�#��v� ��A�F�&�a�f�4�4��F�F�1�1�F�F�)-�&�-2�D�*���	8�!7�	8�'�L�M�%�
G�!5� 6�� F�
�!�
J�!8� 9�M� I�
��2�"�'�'�
�6�6�8�
8�C���,�,�.�.�5�r�:�:�
��m�C��,�,���'�3�3�D�9�9�),��������%�%�%��<�	=rr�)r'r(r)r*r�rO�environr�r�rrr�rr�r�r�rar��stdoutrdrqrrrrrXs/��������h3�h3�h3�T!%�$�*.�2�:�����4��!%��Z�"�
s'�s'�s'�s'�j(�(�(�$����: � � � -!�-!�-!�^J�J�J�X���(I�I�I�V���<#&�*�)�)�)�)�:=�:=�:=�:=�:=rrc�6�|�dd��}|�dd��p|�dd��}|�dd��}|j|i|��}|j|_||_||_||_|jr|rtd���|jr)t|tj
��std���|jrBd}t|tj
��st|d	z���|rt|d
z���|S)aH
    This method supports the same args as ArgumentParser.add_argument(..)
    as well as the additional args below.

    Arguments:
        env_var: If set, the value of this environment variable will override
            any config file or default values for this arg (but can itself
            be overridden on the commandline). Also, if auto_env_var_prefix is
            set in the constructor, this env var name will be used instead of
            the automatic name.
        is_config_file_arg: If True, this arg is treated as a config file path
            This provides an alternative way to specify config files in place of
            the ArgumentParser(fromfile_prefix_chars=..) mechanism.
            Default: False
        is_write_out_config_file_arg: If True, this arg will be treated as a
            config file path, and, when it is specified, will cause
            configargparse to write all current commandline args to this file
            as config options and then exit.
            Default: False
    
    Returns:
        argparse.Action: the new argparse action
    r�Nr��is_config_filer�z*env_var can't be set for a positional arg.z9arg with is_config_file_arg=True must have action='store'z+arg with is_write_out_config_file_arg=True zmust have action='store'z'can't also have is_config_file_arg=True)r��original_add_argument_methodr�r�r�r�r�rr	r
r>)r1r�rr�r�r�r
�error_prefixs        rr�r�sm��2�j�j��D�)�)�G�����d�$�$� �'-�z�z��$�( �( ��$*�:�:�&��$.�$.� �/�T�
.��
?��
?�
?�F�#)�#8�8�F���F�N� 2�F��*F�F�'�
��G�G�G��E�F�F�F�
� �+��F�H�<Q�)R�)R�+��*�+�+�	+�
�*�K�D���&�(�"7�8�8�	H��\�,F�F�G�G�G��	K� ��1J�"J�K�K�K��Mrc����g�|D]V}|r=|d|vr3d|vr/|�dd��\}}��|���A��|���Wt�fd�|D����S)z�Utility method for checking if any of the potential_command_line_args is
    already present in existing_args.

    Returns:
        bool: already on command line?
    rrurUc3� �K�|]}|�vV��	dSrr)rQ�
potential_arg�	arg_namess  �rr�z*already_on_command_line.<locals>.<genexpr>Ts9�������'4�
��"������r)rar;r�)�existing_args_list�potential_command_line_argsr��
arg_string�
option_string�explicit_argr�s      @rr�r�Es�����I�(�)�)�
��	)�*�Q�-�<�7�7�C�:�<M�<M�*4�*:�*:�3��*B�*B�'�M�<����]�+�+�+�+����Z�(�(�(�(������8S������rr)Kr*r
r^rNrOrZr�rS�collectionsrro�version_infor�r�_StoreTrueAction�_StoreFalseActionr<�_StoreConstAction�_AppendConstActionrr;rr:r_rr r#r�RawTextHelpFormatter�RawDescriptionHelpFormatterr%�objectr,r`r;r=rqr�r�r�r�rrr�r��_ActionsContainerr��
HelpFormatter�
ArgumentError�ArgumentTypeError�Action�FileType�	Namespace�ONE_OR_MOREr�	REMAINDERrr�initArgumentParser�getArgumentParser�getArgParser�	getParser�get_arg_parser�
get_parser�	ArgParser�Parser�add_arg�addr�r5r��parse_known�RawFormatter�DefaultsFormatter�DefaultsRawFormatterrrr�<module>r�s�����
������������	�	�	�	�	�	�	�	�
�
�
�
�����#�#�#�#�#�#�������v����������!�!�!�!�!�!�(0�'@���� 5���� ;�'=�#���v���'�.�.�x�/M�N�N�N�!b�!b���!5�!5��&+�e�,O�&P�&P�#���.�.�.�.�&����	�	�	�	�	��*��!��(�	�	�	�%C�%C�%C�%C�%C�v�%C�%C�%C�P2�2�2�2�2�	�2�2�2�O�O�O�O�O�.�O�O�O�dF�F�F�F�F�#3�F�F�F�R7G�7G�7G�7G�7G�+�7G�7G�7G�v*��-��'��!��q
=�q
=�q
=�q
=�q
=�X�,�q
=�q
=�q
=�h6�6�6�r���,;C�:T�:a���7�*6���'�
�&�
�&�B���4�� (� F���&�
��.��	��������	��"�������	�����$��*��'��"���	�%��
 �
��	�	��%-�%?�%L���"�!)�!;�!H����%�0���+�<���*��1��7���r