Your IP : 216.73.217.79


Current Path : /lib/python3/dist-packages/dotenv/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/dotenv/__pycache__/main.cpython-311.pyc

�

�%c�.��"�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZddlmZmZddlmZeje��Zdeed	eefd
�ZGd�d��Z	d,deeejfdedeed	eefd�Ze	deeejfdeed	eeeeeeffd���Z 			d-deeejfdededede!deed	eee!eeffd�Z"		d.deeejfdededeed	eee!eff
d�Z#de
eeeefde!d	eeeeffd�Z$ded	eefd �Z%			d/d"ed#e!d$e!d	efd%�Z&						d0deeejdfd'eeed(e!de!d)e!deed	e!fd*�Z'					d1deeejdfd'eeed(e!d)e!deed	eeeeffd+�Z(dS)2�N)�OrderedDict)�contextmanager)�IO�Dict�Iterable�Iterator�Mapping�Optional�Tuple�Union�)�Binding�parse_stream)�parse_variables�mappings�returnc#�tK�|D]2}|jr%t�d|jj��|V��3dS)Nz;Python-dotenv could not parse statement starting at line %s)�error�logger�warning�original�line)r�mappings  �-/usr/lib/python3/dist-packages/dotenv/main.py�with_warn_for_invalid_linesrsX���������=�	��N�N�M�� �%�
�
�
��
�
�
�
�
��c�D�eZdZ					ddeeeejfdeeede	dedefde	d	e	d
dfd�Z
ed
eeefd���Z
d
eeeeffd
�Zd
eeeeeffd�Zd
e	fd�Zded
eefd�ZdS)�DotEnvNFT�dotenv_path�stream�verbose�encoding�interpolate�overriderc�h�||_||_d|_||_||_||_||_dS�N)rr �_dictr!r"r#r$)�selfrr r!r"r#r$s       r�__init__zDotEnv.__init__s;��'��������
���� ��
�&��� ��
�
�
rc#�vK�|jr^tj�|j��r:t	|j|j���5}|V�ddd��dS#1swxYwYdS|j�|jV�dS|jr"t�	d|jpd��tjd��V�dS)N�r"z3Python-dotenv could not find configuration file %s.�.env�)r�os�path�isfile�openr"r r!r�info�io�StringIO)r(r s  r�_get_streamzDotEnv._get_stream.s������	"�����t�/?� @� @�	"��d�&���?�?�?�
�6�����
�
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�
�
�
�[�
$��+�������|�
����I��$�.������+�b�/�/�!�!�!�!�!s�	A�A�"Ac���|jr|jS|���}|jr)tt	||j�����|_nt|��|_|jS)zReturn dotenv as dict)r$)r'�parser#r�resolve_variablesr$)r(�
raw_valuess  r�dictzDotEnv.dict=sd���:�	��:���Z�Z�\�\�
���	1�$�%6�z�D�M�%Z�%Z�%Z�[�[�D�J�J�$�Z�0�0�D�J��z�rc#��K�|���5}tt|����D]}|j�|j|jfV��	ddd��dS#1swxYwYdSr&)r5rr�key�value)r(r rs   rr7zDotEnv.parseKs�����
�
�
�
�
�	5�6�6�|�F�7K�7K�L�L�
5�
5���;�*�!�+�w�}�4�4�4�4��
5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�	5�	5s�7A�A �#A c���|���sdS|������D],\}}|tjvr|js�|�|tj|<�-dS)zI
        Load the current dotenv as system environment variable.
        FNT)r:�itemsr.�environr$)r(�k�vs   r�set_as_environment_variablesz#DotEnv.set_as_environment_variablesQsj���y�y�{�{�	��5��I�I�K�K�%�%�'�'�	"�	"�D�A�q��B�J���t�}����}� !��
�1�
���trr<c��|���}||vr||S|jr!t�d||j��dS)z	
        zKey %s not found in %s.N)r:r!rrr)r(r<�datas   r�getz
DotEnv.get`sN���y�y�{�{���$�;�;���9���<�	M��N�N�4�c�4�;K�L�L�L��tr)NFNTT)�__name__�
__module__�__qualname__r
r�strr.�PathLiker�boolr)rrr5rr:rr7rCrF�rrrrsm������%)��%)� ��!�!��e�C���$4�5�6�!���C��!�!��	!�
��c�	�"�!��
!��!�
�!�!�!�!�"�"�X�b��g�.�"�"�"��^�"��d�3���
�-�.�����5�x��c�8�C�=�&8� 9�:�5�5�5�5�
�d�
�
�
�
��s��x��}������rr�utf-8r�
key_to_getr"c�L�t|d|����|��S)z
    Get the value of a given key from the given .env.

    Returns `None` if the key isn't found or doesn't have a value.
    T)r!r")rrF)rrOr"s   r�get_keyrQns'���+�t�h�?�?�?�C�C�J�O�O�Orr/c#�PK�	tj�|��s?t|d|���5}|�d��ddd��n#1swxYwYtjdd|���5}t||���5}||fV�ddd��n#1swxYwYddd��n#1swxYwYtj|j	|��dS#t$r?tj�|j	��rtj|j	���wxYw)Nzw+r+r-F)�mode�deleter")r.r/r0r1�write�tempfile�NamedTemporaryFile�shutil�move�name�
BaseException�unlink)r/r"�source�dests    r�rewriter_{s�����
%��w�~�~�d�#�#�	!��d�D�8�4�4�4�
!�����R� � � �
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!����
!�
!�
!�
!�
�
(�d�5�8�
T�
T�
T�	%�X\��d�X�.�.�.�
%�&��t�n�$�$�$�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%�
%����
%�
%�
%�
%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%�	��D�I�t�$�$�$�$�$������
�7�>�>�$�)�$�$�	!��I�d�i� � � �
����sw�1C�A�C�A�C�A�C�9B5�B�B5�B"	�"B5�%B"	�&B5�)C�5B9�9C�<B9�=C�A	D%�alwaysF�
key_to_set�value_to_set�
quote_mode�exportc��|dvr"td�|�����|dkp|dko|���}|r*d�|�dd����}n|}|rd�||��}nd	�||��}t	||�
��5\}	}
d}d}tt
|	����D]d}
|
j|kr|
�|��d}�%|
�|
j	j
��|
j	j
�d
��}�e|s,|r|
�d
��|
�|��ddd��n#1swxYwYd||fS)z�
    Adds or Updates a key/value to the given .env

    If the .env path given doesn't exist, fails instead of risking creating
    an orphan .env somewhere in the filesystem
    )r`�auto�neverzUnknown quote_mode: {}r`rfz'{}'�'z\'z
export {}={}
z{}={}
r+FT�
N)�
ValueError�format�isalnum�replacer_rrr<rUr�string�endswith)rrarbrcrdr"�quote�	value_out�line_outr]r^�replaced�missing_newliners              r�set_keyru�s����4�4�4��1�8�8��D�D�E�E�E�	�h��	A��&� �?��)=�)=�)?�)?�%?�
�

�!��M�M�,�"6�"6�s�E�"B�"B�C�C�	�	� �	�
�;�#�*�*�:�y�A�A����#�#�J�	�:�:��	��x�	0�	0�	0�
!�N�V�T�����2�<��3G�3G�H�H�	M�	M�G��{�j�(�(��
�
�8�$�$�$�����
�
�7�+�2�3�3�3�&-�&6�&=�&F�&F�t�&L�&L�"L����	!��
!��
�
�4� � � ��J�J�x� � � �
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!����
!�
!�
!�
!���\�)�)s�6B7E9�9E=�E=�key_to_unsetc��tj�|��st�d|��d|fSd}t||���5\}}t
t|����D]/}|j|krd}�|�	|j
j���0	ddd��n#1swxYwY|s t�d||��d|fS||fS)z�
    Removes a given key from the given `.env` file.

    If the .env path given doesn't exist, fails.
    If the given key doesn't exist in the .env, fails.
    z(Can't delete from %s - it doesn't exist.NFr+Tz/Key %s not removed from %s - key doesn't exist.)r.r/�existsrrr_rrr<rUrrn)rrvrcr"�removedr]r^rs        r�	unset_keyrz�s3���7�>�>�+�&�&�"����A�;�O�O�O��\�!�!��G�	��x�	0�	0�	0�4�N�V�T�2�<��3G�3G�H�H�	4�	4�G��{�l�*�*�����
�
�7�+�2�3�3�3�3�		4�4�4�4�4�4�4�4�4�4�4�4����4�4�4�4��"����H�,�Xc�d�d�d��\�!�!��L� � s�AB/�/B3�6B3�valuesr$c�j��i}|D]�\}}|�d}n�t|��}i�|r5��tj����|��n4��|����tj��d��fd�|D����}|||<��|S)Nr-c3�B�K�|]}|����V��dSr&)�resolve)�.0�atom�envs  �r�	<genexpr>z$resolve_variables.<locals>.<genexpr>�s/�����A�A�4�T�\�\�#�.�.�A�A�A�A�A�Ar)r�updater.r@�join)r{r$�
new_valuesrZr=�result�atomsr�s       @rr8r8�s�����J��"�"�
��u��=��F�F�#�E�*�*�E��C��
'��
�
�2�:�&�&�&��
�
�:�&�&�&�&��
�
�:�&�&�&��
�
�2�:�&�&�&��W�W�A�A�A�A�5�A�A�A�A�A�F�!�
�4����rc#��K�tj�|��std���tj�|��rtj�|��}d}tj�|��}||kr\|V�tj�tj�|tjj����}||}}||k�ZdSdS)zL
    Yield directories starting from the given directory up to the root
    zStarting path not foundN)	r.r/rx�IOErrorr0�dirname�abspathr��pardir)r/�last_dir�current_dir�
parent_dirs    r�
_walk_to_rootr��s������7�>�>�$���1��/�0�0�0�	�w�~�~�d���%��w���t�$�$���H��'�/�/�$�'�'�K�
�k�
!�
!������W�_�_�R�W�\�\�+�r�w�~�%N�%N�O�O�
� +�Z�+���k�
!�
!�
!�
!�
!�
!rr,�filename�raise_error_if_not_found�usecwdc�h�d�}|s |��sttdd��rtj��}n�tj��}t
}|jj|kr |j�J�|j}|jj|k� |jj}tj	�
tj	�|����}t|��D]E}tj	�
||��}	tj	�|	��r|	cS�F|rtd���dS)z�
    Search in increasingly higher folders for the given file

    Returns path to the file if found, or an empty string otherwise
    c�L�tddddg���}t|d��S)z> Decide whether this is running in a REPL or IPython notebook �__main__N�__file__)�fromlist)�
__import__�hasattr)�mains r�_is_interactivez$find_dotenv.<locals>._is_interactives-���*�d�D�J�<�H�H�H���4��,�,�,�,r�frozenFNzFile not foundr-)�getattr�sysr.�getcwd�	_getframer��f_code�co_filename�f_backr/r�r�r�r�r0r�)
r�r�r�r�r/�frame�current_file�frame_filenamer��
check_paths
          r�find_dotenvr�
s4��-�-�-�
�@���"�"�@�g�c�8�U�&C�&C�@��y�{�{����
�������l�&�,�6�6��<�+�+�+��L�E��l�&�,�6�6���1���w���r�w���~�>�>�?�?�� ��&�&�����W�\�\�'�8�4�4�
�
�7�>�>�*�%�%�	�����	� �(��&�'�'�'�
�2rTr r!r#c�x�|�|�t��}t||||||���}|���S)a�Parse a .env file and then load all the variables found as environment variables.

    Parameters:
        dotenv_path: Absolute or relative path to .env file.
        stream: Text stream (such as `io.StringIO`) with .env content, used if
            `dotenv_path` is `None`.
        verbose: Whether to output a warning the .env file is missing.
        override: Whether to override the system environment variables with the variables
            from the `.env` file.
        encoding: Encoding to be used to read the file.
    Returns:
        Bool: True if atleast one environment variable is set elese False

    If both `dotenv_path` and `stream` are `None`, `find_dotenv()` is used to find the
    .env file.
    N�rr r!r#r$r")r�rrC)rr r!r$r#r"�dotenvs       r�load_dotenvr�3sQ��0��v�~�!�m�m��
�������
���F��.�.�0�0�0rc�t�|�|�t��}t||||d|������S)a�
    Parse a .env file and return its content as a dict.

    The returned dict will have `None` values for keys without values in the .env file.
    For example, `foo=bar` results in `{"foo": "bar"}` whereas `foo` alone results in
    `{"foo": None}`

    Parameters:
        dotenv_path: Absolute or relative path to the .env file.
        stream: `StringIO` object with .env content, used if `dotenv_path` is `None`.
        verbose: Whether to output a warning if the .env file is missing.
        encoding: Encoding to be used to read the file.

    If both `dotenv_path` and `stream` are `None`, `find_dotenv()` is used to find the
    .env file.
    NTr�)r�rr:)rr r!r#r"s     r�
dotenv_valuesr�YsK��.��v�~�!�m�m���������
����d�f�f�
r)rN)r`FrN)r`rN)r,FF)NNFFTrN)NNFTrN))r3�loggingr.rXr�rV�collectionsr�
contextlibr�typingrrrrr	r
rr�parserrr�	variablesr�	getLoggerrGrrrrJrKrQr_rLrurzr8r�r�r�r�rMrr�<module>r�s���	�	�	�	�����	�	�	�	�
�
�
�
�
�
�
�
�����#�#�#�#�#�#�%�%�%�%�%�%���������������������*�)�)�)�)�)�)�)�&�&�&�&�&�&�	��	�8�	$�	$���(�7�*;����@Q�����O�O�O�O�O�O�O�O�j&�
P�
P��s�B�K�'�(�
P��
P��s�m�
P��c�]�	
P�
P�
P�
P��%�
��R�[� �
!�%��s�m�%��e�B�s�G�R��W�$�%�&�%�%�%���%�.��%�
.*�.*��s�B�K�'�(�.*��.*��.*��	.*�

�.*��s�m�
.*��8�D�>�3��#�$�.*�.*�.*�.*�h�%�	!�!��s�B�K�'�(�!��!��!��s�m�	!�
�8�D�>�3���!�!�!�!�>��U�3���
�-�.�/����
�S�(�3�-�
� �����28��8���
�8�8�8�8�&�%*��&�&��&�"�&�
�&�	�	&�&�&�&�T26� $����%�
#1�#1��s�B�K��-�.�#1��R��W��#1��#1��	#1�
�#1��s�m�
#1�
�#1�#1�#1�#1�N26� $���%�!
�!
��s�B�K��-�.�!
��R��W��!
��!
��	!
�
�s�m�!
�
�#�x��}�
��
!
�!
�!
�!
�!
�!
r