§
    ôcg#  ã                   óœ   — d dl Z d dlZd dlZd dlZ ej        e¦  «        Zd„ Z G d„ dej	        j
        ¦  «        Zd„ Z e¦   «         Zd„ ZdS )é    Nc                 óÒ  ‡— t          j        ¦   «         t           j                             |¦  «        g}t           j                             |j        ¦  «        Št           j                             ‰¦  «        scˆfd„|D ¦   «         }|D ]%}t           j                             |¦  «        r|Š n.Œ&t          d|j        › dd 	                    |¦  «        › �¦  «        ‚t          ‰¦  «        S )a
  
    Given a ruamel.yaml.loader.Loader, a ruamel.yaml.serializer.ScalarNode containing the included
    filename, and an include directory path to search for matching files, load the given YAML
    filename (ignoring the given loader so we can use our own) and return its contents as a data
    structure of nested dicts and lists. If the filename is relative, probe for it within 1. the
    current working directory and 2. the given include directory.

    Raise FileNotFoundError if an included file was not found.
    c                 óP   •— g | ]"}t           j                             |‰¦  «        ‘Œ#S © )ÚosÚpathÚjoin)Ú.0Ú	directoryÚinclude_filenames     €ú7/usr/lib/python3/dist-packages/borgmatic/config/load.pyú
<listcomp>z)include_configuration.<locals>.<listcomp>   s7   ø€ ð 
ð 
ð 
Ø:C�BŒG�LŠL˜Ð$4Ñ5Ô5ð
ð 
ð 
ó    zCould not find include z at z or )r   Úgetcwdr   ÚabspathÚ
expanduserÚvalueÚisabsÚexistsÚFileNotFoundErrorr   Úload_configuration)ÚloaderÚfilename_nodeÚinclude_directoryÚinclude_directoriesÚcandidate_filenamesÚcandidate_filenamer   s         @r   Úinclude_configurationr   
   sÿ   ø€ õ œ9™;œ;­¬¯ªÐ8IÑ(JÔ(JÐKÐÝ”w×)Ò)¨-Ô*=Ñ>Ô>ÐåŒ7�=Š=Ð)Ñ*Ô*ð ð
ð 
ð 
ð 
ØGZð
ñ 
ô 
Ðð #6ð 	ð 	ÐÝŒw�~Š~Ð0Ñ1Ô1ð Ø#5Ð Ø�ðõ $Øe¨-Ô*=ÐeÐeÀ6Ç;Â;ÐObÑCcÔCcÐeÐeñô ð õ Ð.Ñ/Ô/Ð/r   c                   ó.   ‡ — e Zd ZdZdˆ fd„	Zˆ fd„Zˆ xZS )ÚInclude_constructorzÃ
    A YAML "constructor" (a ruamel.yaml concept) that supports a custom "!include" tag for including
    separate YAML configuration files. Example syntax: `retention: !include common.yaml`
    Nc                 ó¸   •— t          t          | ¦  «                             ||¦  «         |                      dt	          j        t          |¬¦  «        ¦  «         d S )Nú!include©r   )Úsuperr   Ú__init__Úadd_constructorÚ	functoolsÚpartialr   )ÚselfÚpreserve_quotesr   r   Ú	__class__s       €r   r$   zInclude_constructor.__init__.   s^   ø€ ÝÕ! 4Ñ(Ô(×1Ò1°/À6ÑJÔJÐJØ×ÒØÝÔÕ3ÐGXÐYÑYÔYñ	
ô 	
ð 	
ð 	
ð 	
r   c                 óž  •— t           j        j                             ¦   «         }t	          |j        ¦  «        D ]R\  }\  }}|j        dk    r?|j        dk    r4|                     |                      |¦  «        ¦  «        }||f|j        |<   ŒSt          t          | ¦  «                             |¦  «         t          |j        ¦  «        |_        dS )aü  
        Support the special case of deep merging included configuration into an existing mapping
        using the YAML '<<' merge key. Example syntax:

        ```
        retention:
            keep_daily: 1

        <<: !include common.yaml
        ```

        These includes are deep merged into the current configuration file. For instance, in this
        example, any "retention" options in common.yaml will get merged into the "retention" section
        in the example configuration file.
        ztag:yaml.org,2002:merger!   N)ÚruamelÚyamlÚrepresenterÚSafeRepresenterÚ	enumerater   ÚtagÚrepresent_dataÚconstruct_objectr#   r   Úflatten_mappingÚdeep_merge_nodes)r(   Únoder.   ÚindexÚkey_nodeÚ
value_nodeÚincluded_valuer*   s          €r   r4   z#Include_constructor.flatten_mapping5   sÁ   ø€ õ  ”kÔ-×=Ò=Ñ?Ô?ˆå-6°t´zÑ-BÔ-Bð 	?ð 	?Ñ)ˆEÑ)�H˜jØŒ|Ð9Ò9Ð9¸j¼nÐPZÒ>ZÐ>ZØ!,×!;Ò!;¸D×<QÒ<QÐR\Ñ<]Ô<]Ñ!^Ô!^�Ø%-¨~Ð$>�”
˜5Ñ!øåÕ! 4Ñ(Ô(×8Ò8¸Ñ>Ô>Ð>å% d¤jÑ1Ô1ˆŒ
ˆ
ˆ
r   )NNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r$   r4   Ú__classcell__)r*   s   @r   r   r   (   s`   ø€ € € € € ðð ð

ð 
ð 
ð 
ð 
ð 
ð2ð 2ð 2ð 2ð 2ð 2ð 2ð 2ð 2r   r   c                 óÄ   ‡ ‡—  G ˆˆ fd„dt           ¦  «        Št          j                             d¬¦  «        }‰|_        |                     t          ‰ ¦  «        ¦  «        S )a  
    Load the given configuration file and return its contents as a data structure of nested dicts
    and lists.

    Raise ruamel.yaml.error.YAMLError if something goes wrong parsing the YAML, or RecursionError
    if there are too many recursive includes.
    c                   ó&   •‡ — e Zd Zdˆˆ ˆfd„	Zˆ xZS )úFload_configuration.<locals>.Include_constructor_with_include_directoryNc                 óŽ   •— t          ‰| ¦  «                             ||t          j                             ‰¦  «        ¬¦  «         d S )Nr"   )r#   r$   r   r   Údirname)r(   r)   r   Ú*Include_constructor_with_include_directoryr*   Úfilenames      €€€r   r$   zOload_configuration.<locals>.Include_constructor_with_include_directory.__init__]   sK   ø€ ÝÐ<¸dÑCÔC×LÒLØ ½2¼7¿?º?È8Ñ;TÔ;Tð Mñ ô ð ð ð r   )NN)r;   r<   r=   r$   r?   )r*   rE   rF   s   @€€r   rE   rB   \   sH   øø€ € € € € ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	ð 	r   rE   Úsafe)Útyp)r   r,   r-   ÚYAMLÚConstructorÚloadÚopen)rF   r-   rE   s   ` @r   r   r   Q   sx   øø€ ðð ð ð ð ð ð ð Õ5Hñ ô ð õ Œ;×Ò ÐÑ'Ô'€DØA€DÔà�9Š9•T˜(‘^”^Ñ$Ô$Ð$r   c                 óð  ‡— i Š| D �]b\  }}| D �]X\  }}||f‰v s||f‰v rŒ|j         |j         k    �r4|j        |j        k    �r#||k    �rt          ‰||f<   t          |t          j        j        j        ¦  «        rk|t          j        j                             |j         t          |j        |j        z   ¦  «        |j	        |j
        |j        |j        |j        ¬¦  «        f‰||f<   Œ×t          |t          j        j        j        ¦  «        r]|t          j        j                             |j         |j        |j        z   |j	        |j
        |j        |j        |j        ¬¦  «        f‰||f<   �ŒZ�Œdˆfd„| D ¦   «         S )a�	  
    Given a nested borgmatic configuration data structure as a list of tuples in the form of:

        (
            ruamel.yaml.nodes.ScalarNode as a key,
            ruamel.yaml.nodes.MappingNode or other Node as a value,
        ),

    ... deep merge any node values corresponding to duplicate keys and return the result. If
    there are colliding keys with non-MappingNode values (e.g., integers or strings), the last
    of the values wins.

    For instance, given node values of:

        [
            (
                ScalarNode(tag='tag:yaml.org,2002:str', value='retention'),
                MappingNode(tag='tag:yaml.org,2002:map', value=[
                    (
                        ScalarNode(tag='tag:yaml.org,2002:str', value='keep_hourly'),
                        ScalarNode(tag='tag:yaml.org,2002:int', value='24')
                    ),
                    (
                        ScalarNode(tag='tag:yaml.org,2002:str', value='keep_daily'),
                        ScalarNode(tag='tag:yaml.org,2002:int', value='7')
                    ),
                ]),
            ),
            (
                ScalarNode(tag='tag:yaml.org,2002:str', value='retention'),
                MappingNode(tag='tag:yaml.org,2002:map', value=[
                    (
                        ScalarNode(tag='tag:yaml.org,2002:str', value='keep_daily'),
                        ScalarNode(tag='tag:yaml.org,2002:int', value='5')
                    ),
                ]),
            ),
        ]

    ... the returned result would be:

        [
            (
                ScalarNode(tag='tag:yaml.org,2002:str', value='retention'),
                MappingNode(tag='tag:yaml.org,2002:map', value=[
                    (
                        ScalarNode(tag='tag:yaml.org,2002:str', value='keep_hourly'),
                        ScalarNode(tag='tag:yaml.org,2002:int', value='24')
                    ),
                    (
                        ScalarNode(tag='tag:yaml.org,2002:str', value='keep_daily'),
                        ScalarNode(tag='tag:yaml.org,2002:int', value='5')
                    ),
                ]),
            ),
        ]

    The purpose of deep merging like this is to support, for instance, merging one borgmatic
    configuration file into another for reuse, such that a configuration section ("retention",
    etc.) does not completely replace the corresponding section in a merged file.
    )r1   r   Ú
start_markÚend_markÚ
flow_styleÚcommentÚanchorc                 óx   •— g | ]6}‰                      |¦  «        t          k    ¯ ‰                      ||¦  «        ‘Œ7S r   )ÚgetÚDELETED_NODE)r	   r6   Úreplaced_nodess     €r   r   z$deep_merge_nodes.<locals>.<listcomp>Ö   sI   ø€ ð ð ð Ø+/¸N×<NÒ<NÈtÑ<TÔ<TÕXdÒ<dÐ<dˆ×Ò˜4 Ñ&Ô&Ð<dÐ<dÐ<dr   )r1   r   rU   Ú
isinstancer,   r-   ÚnodesÚMappingNoder5   rN   rO   rP   rQ   rR   ÚSequenceNode)rX   Úa_keyÚa_valueÚb_keyÚb_valuerV   s        @r   r5   r5   k   s¿  ø€ ð@ €Nð  ð &ñ &‰ˆˆwØ#ð %	ñ %	‰NˆE�7à�wÐ >Ð1Ð1°e¸WÐ5EÈÐ5WÐ5WØð Œy˜EœIÒ%Ñ%¨%¬+¸¼Ò*DÑ*DÈÐT[ÒI[ÑI[å3?�  wÐ/Ñ0õ ˜g¥v¤{Ô'8Ô'DÑEÔEð àÝœÔ)×5Ò5Ø '¤Ý"2°7´=À7Ä=Ñ3PÑ"QÔ"QØ'.Ô'9Ø%,Ô%5Ø'.Ô'9Ø$+¤OØ#*¤>ð 6ñ ô ð8�N E¨7Ð#3Ñ4Ð4õ   ­¬Ô):Ô)GÑHÔHð àÝœÔ)×6Ò6Ø '¤Ø")¤-°'´-Ñ"?Ø'.Ô'9Ø%,Ô%5Ø'.Ô'9Ø$+¤OØ#*¤>ð 7ñ ô ð8�N E¨7Ð#3Ñ4ùñ5%	ðNð ð ð Ø38ðñ ô ð r   )r&   Úloggingr   Úruamel.yamlr,   Ú	getLoggerr;   Úloggerr   r-   ÚSafeConstructorr   r   ÚobjectrU   r5   r   r   r   ú<module>re      sº   ðØ Ð Ð Ð Ø €€€Ø 	€	€	€	à Ð Ð Ð à	ˆÔ	˜8Ñ	$Ô	$€ð0ð 0ð 0ð<&2ð &2ð &2ð &2ð &2˜&œ+Ô5ñ &2ô &2ð &2ðR%ð %ð %ð. ˆv‰xŒx€ðmð mð mð mð mr   