
    vKg7'                     h    S SK r S SKrS SKrS SKrS SKrS SKrS rS rS r	S
S jr
S rS rS rS	 rg)    Nc                     / n/ nU  H@  n [        U5      nUR	                  UR                  S5      5        UR	                  U5        MB     [        U5      n[        U5      nXeS'   U$ ! [        R                  R                   a     M  f = f)a}  Load and combine multiple INI configs with profiles.

This function will take a list of filesnames and return
a single dictionary that represents the merging of the loaded
config files.

If any of the provided filenames does not exist, then that file
is ignored.  It is therefore ok to provide a list of filenames,
some of which may not exist.

Configuration files are **not** deep merged, only the top level
keys are merged.  The filenames should be passed in order of
precedence.  The first config file has precedence over the
second config file, which has precedence over the third config file,
etc.  The only exception to this is that the "profiles" key is
merged to combine profiles from multiple config files into a
single profiles mapping.  However, if a profile is defined in
multiple config files, then the config file with the highest
precedence is used.  Profile values themselves are not merged.
For example::

    FileA              FileB                FileC
    [foo]             [foo]                 [bar]
    a=1               a=2                   a=3
                      b=2

    [bar]             [baz]                [profile a]
    a=2               a=3                  region=e

    [profile a]       [profile b]          [profile c]
    region=c          region=d             region=f

The final result of ``multi_file_load_config(FileA, FileB, FileC)``
would be::

    {"foo": {"a": 1}, "bar": {"a": 2}, "baz": {"a": 3},
    "profiles": {"a": {"region": "c"}}, {"b": {"region": d"}},
                {"c": {"region": "f"}}}

Note that the "foo" key comes from A, even though it's defined in both
FileA and FileB.  Because "foo" was defined in FileA first, then the values
for "foo" from FileA are used and the values for "foo" from FileB are
ignored.  Also note where the profiles originate from.  Profile "a"
comes FileA, profile "b" comes from FileB, and profile "c" comes
from FileC.

profiles)load_configbotocore
exceptionsConfigNotFoundappendpop_merge_list_of_dicts)	filenamesconfigsr   filenameloadedmerged_configmerged_profiless          U/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/botocore/configloader.pymulti_file_load_configr      s    ` GH	 *F 	

:./v  )1M*84O /* ""11 		s   A''B	B	c                 d    0 nU  H'  nUR                  5        H  u  p4X1;  d  M  XAU'   M     M)     U$ )N)items)list_of_dictsmerged_dictssingle_dictkeyvalues        r   r   r   V   s<    L$%++-JC&$)S! . %     c                 .    [        U 5      n[        U5      $ )zParse a INI config with profiles.

This will parse an INI config file and map top level profiles
into a top level "profile" key.

If you want to parse an INI file and map all section names to
top level keys, use ``raw_config_parse`` instead.

)raw_config_parsebuild_profile_map)config_filenameparseds     r   r   r   _   s     o.FV$$r   c                 j   0 nU nUGb&  [         R                  R                  U5      n[         R                  R                  U5      n[         R                  R	                  U5      (       d&  [
        R                  R                  [        U5      S9e[        R                  " 5       n UR                  U/5        UR                  5        H`  n0 X%'   UR                  U5       HD  nUR                  XV5      nU(       a"  UR                  S5      (       a   [!        U5      nXrU   U'   MF     Mb     U$ U$ ! ["         a-  n[
        R                  R%                  [        U5      US9SeSnAff = f! [        R&                  [(        4 a-  n[
        R                  R%                  [        U5      US9SeSnAff = f)a  Returns the parsed INI config contents.

    Each section name is a top level key.

    :param config_filename: The name of the INI file to parse

    :param parse_subsections: If True, parse indented blocks as
       subsections that represent their own configuration dictionary.
       For example, if the config file had the contents::

           s3 =
              signature_version = s3v4
              addressing_style = path

        The resulting ``raw_config_parse`` would be::

            {'s3': {'signature_version': 's3v4', 'addressing_style': 'path'}}

       If False, do not try to parse subsections and return the indented
       block as its literal value::

            {'s3': '
signature_version = s3v4
addressing_style = path'}

    :returns: A dict with keys for each profile found in the config
        file and the value of each key being a dict containing name
        value pairs found in that profile.

    :raises: ConfigNotFound, ConfigParseError
    N)path
)r"   error)osr"   
expandvars
expanduserisfiler   r   r   _unicode_pathconfigparserRawConfigParserreadsectionsoptionsget
startswith_parse_nested
ValueErrorConfigParseErrorErrorUnicodeDecodeError)	r   parse_subsectionsconfigr"   cpsectionoptionconfig_valuees	            r   r   r   m   s   < FDww!!$'ww!!$'ww~~d##%%44-:M4NN))+	;GGTFO ;;="$ jj1F#%66'#:L(\-D-DT-J-J(+8+FL
 /;7OF+ 2 ) M6M  * ("*"5"5"F"F%24%8 #G ##'(( ""$67 	%%66"4( 7 	s0   'E+ D11
E(;(E##E(+F2(F--F2c                     [        U [        5      (       a  U $ [        R                  " 5       nUc  [        R                  " 5       nU R                  US5      $ )Nreplace)
isinstancestrsysgetfilesystemencodinggetdefaultencodingdecode)r"   filesystem_encodings     r   r)   r)      sL    $ 335"!446;;*I66r   c                     0 nU R                  5        HP  nUR                  5       nU(       d  M  UR                  SS5      u  p4UR                  5       XR                  5       '   MR     U$ )N=   )
splitlinesstripsplit)r;   r    liner   r   s        r   r1   r1      s\     F'')zz| ZZQ'
#kkmyy{ * Mr   c                     0 n [         R                  " U 5      n[        U5      S:X  a  XUS   '   U$ ! [         a    Us $ f = f)N   rH   )shlexrK   r2   len)r   valuesresultpartss       r   _parse_sectionrT      sN    FC  5zQ!uQxM	  s   2 A Ac                    [         R                  " U 5      n0 n0 n0 n0 nUR                  5        H  u  pgUR                  S5      (       a  UR	                  [        Xg5      5        M7  UR                  S5      (       a  UR	                  [        Xg5      5        Mi  UR                  S5      (       a  UR	                  [        Xg5      5        M  US:X  a  XrU'   M  XuU'   M     X%S'   X5S'   XES'   U$ )ag  Convert the parsed INI config into a profile map.

The config file format requires that every profile except the
default to be prepended with "profile", e.g.::

    [profile test]
    aws_... = foo
    aws_... = bar

    [profile bar]
    aws_... = foo
    aws_... = bar

    # This is *not* a profile
    [preview]
    otherstuff = 1

    # Neither is this
    [foobar]
    morestuff = 2

The build_profile_map will take a parsed INI config file where each top
level key represents a section name, and convert into a format where all
the profiles are under a single top level "profiles" key, and each key in
the sub dictionary is a profile name.  For example, the above config file
would be converted from::

    {"profile test": {"aws_...": "foo", "aws...": "bar"},
     "profile bar": {"aws...": "foo", "aws...": "bar"},
     "preview": {"otherstuff": ...},
     "foobar": {"morestuff": ...},
     }

into::

    {"profiles": {"test": {"aws_...": "foo", "aws...": "bar"},
                  "bar": {"aws...": "foo", "aws...": "bar"},
     "preview": {"otherstuff": ...},
     "foobar": {"morestuff": ...},
    }

If there are no profiles in the provided parsed INI contents, then
an empty dict will be the value associated with the ``profiles`` key.

.. note::

    This will not mutate the passed in parsed_ini_config.  Instead it will
    make a deepcopy and return that value.

profilezsso-sessionservicesdefaultr   sso_sessions)copydeepcopyr   r0   updaterT   )parsed_ini_configparsed_configr   rY   rW   final_configr   rQ   s           r   r   r      s    f MM"34MHLHL$**,>>)$$OON378^^M**s ;<^^J''OON378I #SM & -  (#/ 'r   )T)r*   rZ   r%   rO   rA   botocore.exceptionsr   r   r   r   r   r)   r1   rT   r    r   r   <module>rb      sD      	  
 <~%<~7(Ir   