HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //proc/1233/cwd/lib/python3/dist-packages/dotenv/__pycache__/main.cpython-310.pyc
o

��a�,�@s�ddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddl
mZmZm
Z
mZmZmZmZmZddlmZmZddlmZe�e�ZejdkrTejZneZd	eed
eefdd�ZGd
d�d�Z deeefded
eefdd�Z!e	deeefd
eeeeeeffdd��Z"		d7deeefdededede#d
eee#eeffdd�Z$	d8deeefdeded
eee#effdd �Z%d!e
eeeefd"e#d
eeeeffd#d$�Z&ded
eefd%d&�Z'	'		d9d(ed)e#d*e#d
efd+d,�Z(					-	.d:deeedfd/eeed0e#d"e#d1e#d2eed
e#fd3d4�Z)				-	.d;deeedfd/eeed0e#d1e#d2eed
eeeeffd5d6�Z*dS)<�N)�OrderedDict)�contextmanager)�IO�Dict�Iterable�Iterator�Mapping�Optional�Tuple�Union�)�Binding�parse_stream)�parse_variables)���mappings�returnccs,�|D]}|jrt�d|jj�|VqdS)Nz;Python-dotenv could not parse statement starting at line %s)�error�logger�warning�original�line)r�mapping�r�-/usr/lib/python3/dist-packages/dotenv/main.py�with_warn_for_invalid_liness���rc@s�eZdZ					ddeeeefdeeedededefded	ed
dfdd�Z	e
d
eeefd
d��Zd
e
eeeffdd�Zd
eeeeeffdd�Zd
efdd�Zded
eefdd�ZdS)�DotEnvNFT�dotenv_path�stream�verbose�encoding�interpolate�overridercCs.||_||_d|_||_||_||_||_dS�N)rr�_dictr r!r"r#)�selfrrr r!r"r#rrr�__init__"s	
zDotEnv.__init__ccs��|jr*tj�|j�r*tj|j|jd��}|VWd�dS1s#wYdS|jdur5|jVdS|jrAt	�
d|jp?d�t�d�VdS)N)r!z3Python-dotenv could not find configuration file %s.�.env�)r�os�path�isfile�io�openr!rr r�info�StringIO)r&rrrr�_get_stream3s�"�
�zDotEnv._get_streamcCsD|jr|jS|��}|jrtt||jd��|_|jSt|�|_|jS)zReturn dotenv as dict)r#)r%�parser"r�resolve_variablesr#)r&�
raw_valuesrrr�dictBs
�zDotEnv.dictccsZ�|���}tt|��D]}|jdur|j|jfVqWd�dS1s&wYdSr$)r1rr�key�value)r&rrrrrr2Ps�

��"�zDotEnv.parsecCs>|����D]\}}|tjvr|jsq|dur|tj|<qdS)zI
        Load the current dotenv as system environment variable.
        NT)r5�itemsr*�environr#)r&�k�vrrr�set_as_environment_variablesVs
�z#DotEnv.set_as_environment_variablesr6cCs2|��}||vr||S|jrt�d||j�dS)z	
        zKey %s not found in %s.N)r5r rrr)r&r6�datarrr�getbsz
DotEnv.get)NFNTT)�__name__�
__module__�__qualname__r	r�str�	_PathLiker�boolr'rrr1rr5r
r2r<r>rrrrr!s6��
��
���
�rr�
key_to_getcCst|dd��|�S)zl
    Gets the value of a given key from the given .env

    If the .env path given doesn't exist, fails
    T)r )rr>)rrErrr�get_keypsrFr+c	cs��zTtj�|�s#t�|d��
}|�d�Wd�n1swYtjddd��"}t�|��
}||fVWd�n1s@wYWd�n1sOwYWntyjtj�|j	�rit�
|j	��wt�|j	|�dS)Nzw+r)F)�mode�delete)
r*r+r,r-r.�write�tempfile�NamedTemporaryFile�
BaseException�name�unlink�shutil�move)r+�source�destrrr�rewriteys&�������rS�alwaysF�
key_to_set�value_to_set�
quote_mode�exportc
Cs|dvrtd�|���|dkp|dko|��}|r$d�|�dd��}n|}|r/d�||�}nd	�||�}t|��A\}}	d
}
d
}tt|��D]}|j|krU|	�|�d}
qF|	�|j	j
�|j	j
�d�}qF|
ss|rn|	�d�|	�|�Wd
�n1s}wYd||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
    )rT�auto�neverzUnknown quote_mode: {}rTrYz'{}'�'z\'z
export {}={}
z{}={}
FT�
N)�
ValueError�format�isalnum�replacerSrrr6rIr�string�endswith)
rrUrVrWrX�quote�	value_out�line_outrQrR�replaced�missing_newlinerrrr�set_key�s6
�



��
rh�key_to_unsetcCs�tj�|�st�d|�d|fSd}t|��"\}}tt|��D]}|j|kr)d}q|�	|j
j�qWd�n1s;wY|sMt�d||�d|fS||fS)z�
    Removes a given key from the given .env

    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.NFTz/Key %s not removed from %s - key doesn't exist.)r*r+�existsrrrSrrr6rIrra)rrirW�removedrQrRrrrr�	unset_key�s
��rl�valuesr#cs�i}|D]:\}}|durd}n+t|�}i�|r#��tj���|�n��|���tj�d��fdd�|D��}|||<q|S)Nr)c3s�|]}|���VqdSr$)�resolve)�.0�atom��envrr�	<genexpr>�s�z$resolve_variables.<locals>.<genexpr>)r�updater*r9�join)rmr#�
new_valuesrMr7�result�atomsrrqrr3�s

r3ccs��tj�|�std��tj�|�rtj�|�}d}tj�|�}||kr>|Vtj�tj�|tjj��}||}}||ks#dSdS)zL
    Yield directories starting from the given directory up to the root
    zStarting path not foundN)	r*r+rj�IOErrorr,�dirname�abspathru�pardir)r+�last_dir�current_dir�
parent_dirrrr�
_walk_to_root�s�
�r�r(�filename�raise_error_if_not_found�usecwdc
Cs�dd�}|s|�sttdd�rt��}n*t��}t}|jj|kr0|jdus'J�|j}|jj|ks |jj}tj	�
tj	�|��}t|�D]}tj	�
||�}	tj	�|	�rU|	SqB|r\td��dS)z�
    Search in increasingly higher folders for the given file

    Returns path to the file if found, or an empty string otherwise
    cSstddddgd�}t|d�S)z> Decide whether this is running in a REPL or IPython notebook �__main__N�__file__)�fromlist)�
__import__�hasattr)�mainrrr�_is_interactivesz$find_dotenv.<locals>._is_interactive�frozenFNzFile not foundr))�getattr�sysr*�getcwd�	_getframer��f_code�co_filename�f_backr+rzr{r�rur,ry)
r�r�r�r�r+�frame�current_file�frame_filenamerz�
check_pathrrr�find_dotenvs&
��r�T�utf-8rr r"r!cCs2|dur|durt�}t||||||d�}|��S)azParse a .env file and then load all the variables found as environment variables.

    - *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. Defaults to
      `False`.
    - *override*: whether to override the system environment variables with the variables
      in `.env` file.  Defaults to `False`.
    - *encoding*: encoding to be used to read the file.

    If both `dotenv_path` and `stream`, `find_dotenv()` is used to find the .env file.
    N�rrr r"r#r!)r�rr<)rrr r#r"r!�dotenvrrr�load_dotenv,s�r�cCs.|dur|durt�}t||||d|d���S)a�
    Parse a .env file and return its content as a dict.

    - *dotenv_path*: absolute or relative path to .env file.
    - *stream*: `StringIO` object with .env content, used if `dotenv_path` is `None`.
    - *verbose*: whether to output a warning the .env file is missing. Defaults to
      `False`.
      in `.env` file.  Defaults to `False`.
    - *encoding*: encoding to be used to read the file.

    If both `dotenv_path` and `stream`, `find_dotenv()` is used to find the .env file.
    NTr�)r�rr5)rrr r"r!rrr�
dotenv_valuesOs��r�)rTF)rT)r(FF)NNFFTr�)NNFTr�)+r-�loggingr*rOr�rJ�collectionsr�
contextlibr�typingrrrrrr	r
r�parserr
r�	variablesr�	getLoggerr?r�version_info�PathLikerCrBrrrFrSrDrhrlr3r�r�r�r�rrrr�<module>s�(


"O	0�
�����
�3�
���
���
�����
�*��
�����
�$��
�����