
    di[9                        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fd
Zdee         d	ee         fdZ  G d d          Z!	 d0dededee         d	ee         fdZ"e
	 d1dedee         ded	eeee         ee         f                  fd            Z#	 	 	 	 d2dedededededee         ded	eee         eef         fdZ$	 	 	 d3dedededee         d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'	 	 	 d4d%ed&ed'ed	efd(Z(	 	 	 	 	 	 d5dee         d*eee                  d+ed!ed,edee         d	efd-Z)	 	 	 	 	 d6dee         d*eee                  d+ed,edee         d	eeee         f         fd.Z*ded	efd/Z+dS )7    N)OrderedDict)contextmanager)IODictIterableIteratorMappingOptionalTupleUnion   )Bindingparse_stream)parse_variableszos.PathLike[str]returnc                  r    dt           j        vrdS t           j        d                                         } | dv S )z8
    Determine if dotenv loading has been disabled.
    PYTHON_DOTENV_DISABLEDF>   1tyyestrue)osenvironcasefold)values    I/var/www/html/volatility/venv/lib/python3.11/site-packages/dotenv/main.py_load_dotenv_disabledr      s;      rz11uJ/099;;E222    mappingsc              #   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     r   with_warn_for_invalid_linesr(       sX        = 	NNM %    r   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/   r0   )selfr+   r,   r-   r.   r/   r0   s          r   __init__zDotEnv.__init__+   s;     /:)/9=
$'/!,&r   c              #   V  K   | j         rNt          | 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+   _is_file_or_fifoopenr.   r,   r-   r#   infoioStringIO)r4   r,   s     r   _get_streamzDotEnv._get_stream<   s      	" 01A B B 	"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)r0   )r3   parser/   r   resolve_variablesr0   )r4   
raw_valuess     r   dictzDotEnv.dictK   sj    : 	:ZZ\\
 	1$!*t}EEE 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 r2   )r?   r(   r   keyr   )r4   r,   r'   s      r   rA   zDotEnv.parse[   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)rD   itemsr   r   r0   )r4   kvs      r   set_as_environment_variablesz#DotEnv.set_as_environment_variablesa   sj     yy{{ 	5IIKK%%'' 	" 	"DAqBJt}} !
1tr   rF   c                     |                                  }||v r||         S | j        r!t                              d|| j                   dS ) zKey %s not found in %s.N)rD   r-   r#   r$   r+   )r4   rF   datas      r   getz
DotEnv.getp   sL    yy{{$;;9< 	MNN4c4;KLLLtr   )NFNTT)__name__
__module____qualname__r
   StrPathr   strboolr5   r   r   r?   r   rD   r   rA   rK   rO    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*   rO   )r+   rX   r.   s      r   get_keyrZ   }   s'     +th???CCJOOOr   Fpathfollow_symlinksc              #     K   |rt           j                            |           } 	 t          | |          }	 t          j        |           }t          j        |j                  rt          j        |j                  nd }n## t          $ r |
                                  w xY wn&# t          $ r t          j        d          }d }Y nw xY wt          j        d|ddt           j                            t           j                            |                               5 }t%          j        |j                  }d }	 |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	 |t          j        ||           t          j        ||            d S # t          $ r |                    d            w xY w|                    d           |d )	Nr7   r9   wFz.tmp_)moder.   deleteprefixdirT)
missing_ok)r   r[   realpathr;   lstatstatS_ISREGst_modeS_IMODEBaseExceptioncloseFileNotFoundErrorr=   r>   tempfileNamedTemporaryFiledirnameabspathpathlibPathnamechmodreplaceunlink)
r[   r.   r\   source	path_statoriginal_modedest	dest_pathr"   errs
             r   rewriter}      s       &w%%th777		I <	 122Y./// M
  	 	 	LLNNN	     R 
	$GOOBGOOD1122
 
 
  
L++		 % %tn$$$% % % % % % % % % % % % % % % 	 	 	EEEEEE	                }	(M222Jy$''''' 	 	 	---	 	D)))s   B$ AB  ?B$   B  B$ $ CCF :E<EEE	EE	EF 
E1%E,'F ,E11F  FF,F< <"Galways
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 )aS  
    Adds or Updates a key/value to the given .env

    The target .env file is created if it doesn't exist.

    This function doesn't follow symlinks by default, to avoid accidentally
    modifying a file at a potentially untrusted path. If you don't need this
    protection and need symlinks to be followed, use `follow_symlinks`.
    )r~   autoneverzUnknown quote_mode: r~   r   z'{}''z\'zexport =
r.   r\   FTN)
ValueErrorisalnumformatru   r}   r(   r   rF   writer%   stringendswith)r+   r   r   r   r   r.   r\   quote	value_outline_outrw   rz   replacedmissing_newliner'   s                  r   set_keyr      s   $ 444<
<<===(" f;\%9%9%;%;!; 
  !MM,"6"6sE"B"BCC		 	 17Z77)777 009000	x	Q	Q	Q ! V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 )a  
    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.

    This function doesn't follow symlinks by default, to avoid accidentally
    modifying a file at a potentially untrusted path. If you don't need this
    protection and need symlinks to be followed, use `follow_symlinks`.
    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$   r}   r(   r   rF   r   r%   r   )	r+   r   r   r.   r\   removedrw   rz   r'   s	            r   	unset_keyr      sB   " 7>>+&& "A;OOO\!!G	x	Q	Q	Q 4 V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  "=|[	
 	
 	
 \!!L  s   AB00B47B4valuesr0   c                 j   i }| D ]\  }}|d }nt          |          }i |r5                    t          j                                       |           n4                    |                               t          j                   d                    fd|D                       }|||<   |S )Nr9   c              3   B   K   | ]}|                               V  d S r2   )resolve).0atomenvs     r   	<genexpr>z$resolve_variables.<locals>.<genexpr>3  s/      AA4T\\#..AAAAAAr   )r   updater   r   join)r   r0   
new_valuesrs   r   resultatomsr   s          @r   rB   rB   !  s     ,.J " "e=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   IOErrorisfilero   rp   r   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   r8   filenameraise_error_if_not_foundusecwdc                    d }d }|s* |            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 ]5}	t          j                            |	|           }
t          |
          r|
c S 6|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                      t          t          d          st          t          d          rdS 	 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ps1ps2T__main__N__file__)fromlistF)hasattrsys
__import__ModuleNotFoundError)mains    r   _is_interactivez$find_dotenv.<locals>._is_interactiveW  s~    3 	'#u"5"5 	4	j$
|LLLDD" 	 	 	55	4,,,,s   A 
AAc                  ,    t          j                    d uS r2   )r   gettracerV   r   r   _is_debuggerz!find_dotenv.<locals>._is_debuggera  s    |~~T))r   frozenFNzFile not foundr9   )getattrr   r   getcwd	_getframer   f_codeco_filenamer[   r   f_backro   rp   r   r   r:   r   )r   r   r   r   r   r[   framecurrent_fileframe_filenamero   
check_paths              r   find_dotenvr   L  s   - - -* * *  @"" @llnn @Xu8U8U @y{{ l&,66bgnnL$?
 ?
6 <+++LE	 l&,66bgnnL$?
 ?
6
 1wrw~>>?? &&  W\\'844
J'' 		   (&'''2r   Tr,   r-   r/   c                     t                      rt                              d           dS | |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 with it's default parameters. If you need to change the default parameters
    of `find_dotenv()`, you can explicitly call `find_dotenv()` and pass the result
    to this function as `dotenv_path`.

    If the environment variable `PYTHON_DOTENV_DISABLED` is set to a truthy value,
    .env loading is disabled.
    zSpython-dotenv: .env loading disabled by PYTHON_DOTENV_DISABLED environment variableFNr+   r,   r-   r/   r0   r.   )r   r#   debugr   r*   rK   )r+   r,   r-   r0   r/   r.   dotenvs          r   load_dotenvr     s    :  a	
 	
 	
 u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*   rD   )r+   r,   r-   r/   r.   s        r   dotenv_valuesr     sK    . v~!mm   dffr   c                     t           j                            |           rdS 	 t          j        |           }n# t          t
          f$ r Y dS w xY wt          j        |j                  S )zN
    Return True if `path` exists and is either a regular file or a FIFO.
    TF)r   r[   r   rf   rl   OSErrorS_ISFIFOrh   )r[   sts     r   r:   r:     sn     
w~~d tWT]]w'   uu =$$$s   8 AA)rW   )F)r~   FrW   F)r~   rW   F)r8   FF)NNFFTrW   )NNFTrW   ),r=   loggingr   rq   rf   r   rm   collectionsr   
contextlibr   typingr   r   r   r   r	   r
   r   r   parserr   r   	variablesr   rT   rS   	getLoggerrP   r#   rU   r   r(   r*   rZ   r}   r   r   rB   r   r   r   r   r:   rV   r   r   <module>r      s   				  				   



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