Ë
    h®i‚  ã                   ó2   — d Z ddlZddlmZ  G d„ de«      Zy)z*Docker-style file variable support module.é    N)ÚMutableMappingc                   ó6   — e Zd ZdZd	d„Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)
ÚFileAwareMappingaû  
    A mapping that wraps os.environ, first checking for the existence of a key
    appended with ``_FILE`` whenever reading a value. If a matching file key is
    found then the value is instead read from the file system at this location.

    By default, values read from the file system are cached so future lookups
    do not hit the disk again.

    A ``_FILE`` key has higher precedence than a value is set directly in the
    environment, and an exception is raised if the file can not be found.
    Nc                 óR   — |�|nt         j                  | _        || _        i | _        y)a  
        Initialize the mapping.

        :param env:
            where to read environment variables from (defaults to
            ``os.environ``)
        :param cache:
            cache environment variables read from the file system (defaults to
            ``True``)
        N)ÚosÚenvironÚenvÚcacheÚfiles_cache)Úselfr	   r
   s      úL/var/www/html/venv/lib/python3.12/site-packages/environ/fileaware_mapping.pyÚ__init__zFileAwareMapping.__init__   s$   € ð ˜/‘3¬r¯z©zˆŒØˆŒ
ØˆÕó    c                 óP  — | j                   r|| j                  v r| j                  |   S | j                  j                  |dz   «      }|rCt	        |d¬«      5 }|j                  «       }d d d «       | j                   r| j                  |<   S | j                  |   S # 1 sw Y   Œ5xY w)NÚ_FILEzutf-8)Úencoding)r
   r   r	   ÚgetÚopenÚread)r   ÚkeyÚkey_fileÚfÚvalues        r   Ú__getitem__zFileAwareMapping.__getitem__,   s�   € Ø�:Š:˜# ×!1Ñ!1Ñ1Ø×#Ñ# CÑ(Ð(Ø—8‘8—<‘<  g¡Ó.ˆÙÜ�h¨Õ1°QØŸ™›�÷ 2à�zŠzØ(-�× Ñ  Ñ%ØˆLØ�x‰x˜‰}Ð÷ 2Ð1ús   ÁBÂB%c              #   ó�   K  — | j                   D ]3  }|–— |j                  d«      sŒ|dd }|sŒ!|| j                   vsŒ0|–— Œ5 y­w)zp
        Iterate all keys, also always including the shortened key if ``_FILE``
        keys are found.
        r   Néûÿÿÿ)r	   Úendswith)r   r   Úno_file_keys      r   Ú__iter__zFileAwareMapping.__iter__8   sF   è ø€ ð
 —8”8ˆCØŠIØ�|‰|˜GÕ$Ø! # 2˜h�Ú ;°d·h±hÒ#>Ø%Ó%ñ ùs   ‚%A¨A°A¿Ac                 ó<   — t        t        t        | «      «      «      S )zy
        Return the length of the file, also always counting shortened keys for
        any ``_FILE`` key found.
        )ÚlenÚtupleÚiter)r   s    r   Ú__len__zFileAwareMapping.__len__D   s   € ô
 ”5œ˜d›Ó$Ó%Ð%r   c                 ó¨   — || j                   |<   | j                  r7|j                  d«      r%|d d }|r|| j                  v r| j                  |= y y y y y ©Nr   r   ©r	   r
   r   r   )r   r   r   r   s       r   Ú__setitem__zFileAwareMapping.__setitem__K   sX   € Øˆ�‰�‰Ø�:Š:˜#Ÿ,™, wÔ/Ø˜c˜r˜(ˆKÙ˜{¨d×.>Ñ.>Ñ>Ø×$Ñ$ [Ñ1ð  ?ˆ{ð 0ˆ:r   c                 ó   — |dz   }|| j                   v r| |= || j                   v r| j                   |= y | j                  r3|j                  d«      r"|d d }|r|| j                  v r| j                  |= | j                   |= y r&   r'   )r   r   Úfile_keyr   s       r   Ú__delitem__zFileAwareMapping.__delitem__R   s}   € Ø˜‘=ˆØ�t—x‘xÑØ�X�Ø�d—h‘h‰Ø—H‘H˜S�MØØ�:Š:˜#Ÿ,™, wÔ/Ø˜c˜r˜(ˆKÙ˜{¨d×.>Ñ.>Ñ>Ø×$Ñ$ [Ð1Ø�H‰H�S‰Mr   )NT)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r$   r(   r+   © r   r   r   r      s%   „ ñ
óò
ò
&ò&ò2ór   r   )r/   r   Úcollections.abcr   r   r0   r   r   Ú<module>r2      s   ðñ 1ã 	Ý *ôM�~õ Mr   