
    gB/                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 d dlmZmZmZmZmZmZmZmZ ddlmZmZ ddlmZ eedf         Z ej        e          Zd	ee         d
ee         fdZ G d d          Z	 d-dededee         d
ee         fdZ e
dedee         d
eeee         ee         f                  fd            Z!	 	 	 d.dedededede"dee         d
eee"         eef         fdZ#	 	 d/dedededee         d
eee"         ef         f
dZ$deeeee         f                  de"d
eeee         f         fd Z%ded
ee         fd!Z&	 	 	 d0d#ed$e"d%e"d
efd&Z'	 	 	 	 	 	 d1dee         d(eee                  d)e"de"d*e"dee         d
e"fd+Z(	 	 	 	 	 d2dee         d(eee                  d)e"d*e"dee         d
eeee         f         fd,Z)dS )3    N)OrderedDict)contextmanager)IODictIterableIteratorMappingOptionalTupleUnion   )Bindingparse_stream)parse_variableszos.PathLike[str]mappingsreturnc              #   t   K   | D ]2}|j         r%t                              d|j        j                   |V  3d S )Nz;Python-dotenv could not parse statement starting at line %s)errorloggerwarningoriginalline)r   mappings     W/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/dotenv/main.pywith_warn_for_invalid_linesr      sX        = 	NNM %        c                   &   e Zd Z	 	 	 	 	 ddee         deee                  dedee         ded	ed
dfdZe	d
e
ee                  fd            Zd
eeee         f         fdZd
e
eeee         f                  fdZd
efdZded
ee         fdZdS )DotEnvNFTdotenv_pathstreamverboseencodinginterpolateoverrider   c                 h    || _         || _        d | _        || _        || _        || _        || _        d S N)r   r    _dictr!   r"   r#   r$   )selfr   r    r!   r"   r#   r$   s          r   __init__zDotEnv.__init__$   s;     /:)/9=
$'/!,&r   c              #   v  K   | j         r^t          j                            | j                   r:t	          | j         | j                  5 }|V  d d d            d S # 1 swxY w Y   d S | j        | j        V  d S | j        r"t          	                    d| j         pd           t          j        d          V  d S )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_streamzDotEnv._get_stream5   s      	"t/? @ @ 	"d&??? 6                 [$+| I$.   +b//!!!!!s   	AA"Ac                     | j         r| j         S |                                 }| j        r)t          t	          || j                            | _         nt          |          | _         | j         S )zReturn dotenv as dict)r$   )r'   parser#   r   resolve_variablesr$   )r(   
raw_valuess     r   dictzDotEnv.dictD   sd    : 	:ZZ\\
 	1$%6zDM%Z%Z%Z[[DJJ$Z00DJzr   c              #      K   |                                  5 }t          t          |                    D ]}|j        |j        |j        fV  	 d d d            d S # 1 swxY w Y   d S r&   )r5   r   r   keyvalue)r(   r    r   s      r   r7   zDotEnv.parseR   s       	566|F7K7K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                     |                                  sdS |                                                                  D ],\  }}|t          j        v r| j        s||t          j        |<   -dS )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_variablesX   sj     yy{{ 	5IIKK%%'' 	" 	"DAqBJt}} !
1tr   r<   c                     |                                  }||v r||         S | j        r!t                              d|| j                   dS )z	
        zKey %s not found in %s.N)r:   r!   r   r   r   )r(   r<   datas      r   getz
DotEnv.getg   sN     yy{{$;;9< 	MNN4c4;KLLLtr   )NFNTT)__name__
__module____qualname__r
   StrPathr   strboolr)   r   r   r5   r   r:   r   r7   rC   rF    r   r   r   r   #   s\        %)"& ' 'g&' C!' 	'
 3-' ' ' 
' ' ' '" "Xbg. " " " ^"d3-.    5xc8C=&8 9: 5 5 5 5d    s x}      r   r   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"   )r   rF   )r   rO   r"   s      r   get_keyrQ   u   s'     +th???CCJOOOr   r/   c              #     K   t          j        |                                            t          j        d|d          5 }d }	 t          | |          5 }||fV  d d d            n# 1 swxY w Y   n# t          $ r}|}Y d }~nd }~ww xY wd d d            n# 1 swxY w Y   |t          j        |j	        |            d S t          j        |j	                   |d )NwF)moder"   deleter+   )pathlibPathtouchtempfileNamedTemporaryFiler1   BaseExceptionshutilmovenamer.   unlink)r/   r"   destr   sourceerrs         r   rewriterc      sx     
 L		$#	O	O	O SW	dX... %&tn$$$% % % % % % % % % % % % % % % 	 	 	EEEEEE	               }DIt$$$$$
	$)s`    BA4A(A4(A,	,A4/A,	0A43B4
B
>B BB

BB BalwaysF
key_to_setvalue_to_set
quote_modeexportc                    |dvrt          d|           |dk    p|dk    o|                                 }|r*d                    |                    dd                    }n|}|r
d| d	| d
}n| d	| d
}t	          | |          5 \  }	}
d}d}t          t          |	                    D ]d}|j        |k    r|
                    |           d}%|
                    |j	        j
                   |j	        j
                            d
           }e|s,|r|
                    d
           |
                    |           ddd           n# 1 swxY w Y   d||fS )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
    )rd   autoneverzUnknown quote_mode: rd   rj   z'{}''z\'zexport =
r+   FTN)
ValueErrorisalnumformatreplacerc   r   r   r<   writer   stringendswith)r   re   rf   rg   rh   r"   quote	value_outline_outra   r`   replacedmissing_newliner   s                 r   set_keyr{      s    444<
<<=== 	h 	A& ?)=)=)?)?%? 

  !MM,"6"6sE"B"BCC		 	 17Z77)777 009000	x	0	0	0 !NVT2<3G3GHH 	M 	MG{j((

8$$$

7+2333&-&6&=&F&Ft&L&L"L 	! !

4   JJx   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! \))s   B7EEEkey_to_unsetc                    t           j                            |           st                              d|            d|fS d}t          | |          5 \  }}t          t          |                    D ]/}|j        |k    rd}|	                    |j
        j                   0	 ddd           n# 1 swxY w Y   |s t                              d||            d|fS ||fS )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/   existsr   r   rc   r   r   r<   rs   r   rt   )r   r|   rg   r"   removedra   r`   r   s           r   	unset_keyr      s3    7>>+&& "A;OOO\!!G	x	0	0	0 4NVT2<3G3GHH 	4 	4G{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   AB//B36B3valuesr$   c                 j   i }| D ]\  }}|d }nt          |          }i |r5                    t          j                                       |           n4                    |                               t          j                   d                    fd|D                       }|||<   |S )Nr-   c              3   B   K   | ]}|                               V  d S r&   )resolve).0atomenvs     r   	<genexpr>z$resolve_variables.<locals>.<genexpr>   s/      AA4T\\#..AAAAAAr   )r   updater.   r@   join)r   r$   
new_valuesr^   r=   resultatomsr   s          @r   r8   r8      s     ,.J " "u=FF#E**E,.C '

2:&&&

:&&&&

:&&&

2:&&&WWAAAA5AAAAAF!
4r   c              #     K   t           j                            |           st          d          t           j                            |           rt           j                            |           } d}t           j                            |           }||k    r\|V  t           j                            t           j                            |t           j        j                            }||}}||k    ZdS dS )zL
    Yield directories starting from the given directory up to the root
    zStarting path not foundN)	r.   r/   r~   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__RW\\+rw~%N%NOO
 +Z+ k
!
!
!
!
!
!r   r,   filenameraise_error_if_not_foundusecwdc                    d }|s  |            st          t          dd          rt          j                    }nt          j                    }t
          }|j        j        |k    s)t          j        	                    |j        j                  sI|j
        J |j
        }|j        j        |k     t          j        	                    |j        j                  I|j        j        }t          j                            t          j                            |                    }t          |          D ]E}t          j                            ||           }	t          j                            |	          r|	c S F|rt!          d          dS )z
    Search in increasingly higher folders for the given file

    Returns path to the file if found, or an empty string otherwise
    c                  r    	 t          ddddg          } n# t          $ r Y dS w xY wt          | d           S )z> Decide whether this is running in a REPL or IPython notebook __main__N__file__)fromlistF)
__import__ModuleNotFoundErrorhasattr)mains    r   _is_interactivez$find_dotenv.<locals>._is_interactive  sV    	j$
|LLLDD" 	 	 	55	4,,,,s    
%%frozenFNzFile not foundr-   )getattrsysr.   getcwd	_getframer   f_codeco_filenamer/   r~   f_backr   r   r   r   r0   r   )
r   r   r   r   r/   framecurrent_fileframe_filenamer   
check_paths
             r   find_dotenvr     sp   - - -  @"" @gc8U&C&C @y{{ l&,66bgnnL$?
 ?
6 <+++LE	 l&,66bgnnL$?
 ?
6
 1wrw~>>?? &&  W\\'844
7>>*%% 		   (&'''2r   Tr    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 at least one environment variable is set else False

    If both `dotenv_path` and `stream` are `None`, `find_dotenv()` is used to find the
    .env file.
    Nr   r    r!   r#   r$   r"   )r   r   rC   )r   r    r!   r$   r#   r"   dotenvs          r   load_dotenvr   A  sQ    0 v~!mm  F ..000r   c                 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   r   r:   )r   r    r!   r#   r"   s        r   dotenv_valuesr   g  sK    . v~!mm   dffr   )rN   )rd   FrN   )rd   rN   )r,   FF)NNFFTrN   )NNFTrN   )*r3   loggingr.   rV   r\   r   rY   collectionsr   
contextlibr   typingr   r   r   r   r	   r
   r   r   parserr   r   	variablesr   rK   rJ   	getLoggerrG   r   r   r   rQ   rc   rL   r{   r   r8   r   r   r   r   rM   r   r   <module>r      s   				  				   



  # # # # # # % % % % % %                    * ) ) ) ) ) ) ) & & & & & & ''
(		8	$	$(7*; @Q    O O O O O O O Oj &
P 
P
P
P sm
P c]	
P 
P 
P 
P 
sm eBsGRW$%&   2 %.* .*.*.* .* 	.*
 .* sm.* 8D>3#$.* .* .* .*h %	! !!! ! sm	!
 8D>3! ! ! !>U3-./ S(3-    28 8 8 8 8 8& %*+ ++"+ + 		+ + + +^ &* $%#1 #1'"#1RW#1 #1 	#1
 #1 sm#1 
#1 #1 #1 #1N &* $%! !'"!RW! ! 	!
 sm! 
#x}
! ! ! ! ! !r   