Dj[9ddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZmZmZmZmZmZddlmZmZddlmZeedfZejeZd efd Zd eed eefd Z Gd dZ! d0dededeed eefdZ"e d1dedeeded eee ee effdZ# d2dedededededeeded eeeeeffdZ$ d3dedededeeded eeeeff dZ%d eeeeefd!ed eeeeffd"Z&ded eefd#Z' d4d%ed&ed'ed efd(Z( d5deed*ee ed+ed!ed,edeed efd-Z) d6deed*ee ed+ed,edeed e eeeff d.Z*ded efd/Z+dS)7N) OrderedDict)contextmanager)IODictIterableIteratorMappingOptionalTupleUnion)Binding parse_stream)parse_variableszos.PathLike[str]returncrdtjvrdStjd}|dvS)z8 Determine if dotenv loading has been disabled. PYTHON_DOTENV_DISABLEDF>1tyyestrue)osenvironcasefold)values 9C:\PYTHON\_runtimes\venv\Lib\site-packages\dotenv/main.py_load_dotenv_disabledrs; rz11u J/ 0 9 9 ; ;E 2 22mappingsc#tK|D]2}|jr%td|jj|V3dS)Nz;python-dotenv could not parse statement starting at line %s)errorloggerwarningoriginalline)r mappings rwith_warn_for_invalid_linesr( sX =  NNM %    rc&eZdZ ddeedeeededeeded ed dfd Ze d e eefd Z d e eeeffd Z d e eeeeffdZd efdZded eefdZdS)DotEnvNFT dotenv_pathstreamverboseencoding interpolateoverriderch||_||_d|_||_||_||_||_dSN)r+r,_dictr-r.r/r0)selfr+r,r-r.r/r0s r__init__zDotEnv.__init__+s;/:)/ 9= $ '/ !,& rc#VK|jrNt|jr:t|j|j5}|VddddS#1swxYwYdS|j |jVdS|jr"t d|jpdtj dVdS)Nr.z3python-dotenv could not find configuration file %s..env) r+_is_file_or_fifoopenr.r,r-r#infoioStringIO)r4r,s r _get_streamzDotEnv._get_stream<s    " 01A B B "d&??? 6                    [ $+     |  I$.+b// ! ! ! ! !sA  AAc|jr|jS|}|jr)tt ||j|_nt||_|jS)zReturn dotenv as dict)r0)r3parser/rresolve_variablesr0)r4 raw_valuess rdictz DotEnv.dictKsj : : ZZ\\   1$!*t}EEEDJJ%Z00DJzrc#K|5}tt|D]}|j|j|jfV ddddS#1swxYwYdSr2)r?r(rkeyr)r4r,r's rrAz DotEnv.parse[s      566|F7K7KLL 5 5;*!+w}4444 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s7AA #A c|sdS|D],\}}|tjvr|js||tj|<-dS)zI Load the current dotenv as system environment variable. FNT)rDitemsrrr0)r4kvs rset_as_environment_variablesz#DotEnv.set_as_environment_variablesasjyy{{ 5IIKK%%'' " "DAqBJt}} ! 1 trrFc|}||vr||S|jr!td||jdS) zKey %s not found in %s.N)rDr-r#r$r+)r4rFdatas rgetz DotEnv.getpsLyy{{ $;;9  < M NN4c4;K L L Ltr)NFNTT)__name__ __module__ __qualname__r StrPathrstrboolr5rrr?rrDr rArKrOrrr*r**s\%)"& ''g&'C!' ' 3- '  '' ''''" "Xbg. " " "^ "d3 -. 5xc8C=&8 9:5555 d     s x}      rr*utf-8r+ key_to_getr.cLt|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+rXr.s rget_keyrZ}s' +th ? ? ? C CJ O OOrFpathfollow_symlinksc #K|rtj|} t||} tj|}t j|jrt j|jnd}n##t$r| wxYwn&#t$rtj d}d}YnwxYwtjd|ddtjtj|5}t%j|j}d} |5||fVdddn #1swxYwYn#t$r } | }Yd} ~ nd} ~ wwxYwdddn #1swxYwY|T |tj||tj||dS#t$r|dwxYw|d|d) Nr7r9wFz.tmp_)moder.deleteprefixdirT) missing_ok)rr[realpathr;lstatstatS_ISREGst_modeS_IMODE BaseExceptioncloseFileNotFoundErrorr=r>tempfileNamedTemporaryFiledirnameabspathpathlibPathnamechmodreplaceunlink) r[r.r\source path_stat original_modedest dest_pathr"errs rrewriter}s &w%%th777 I< 122 Y./// M     LLNNN    R   $  GOOBGOOD11 2 2     L++   % %tn$$$ % % % % % % % % % % % % % % %   EEEEEE   } (M222 Jy$ ' ' ' ' '        - - -   D)))sB$AB?B$ B  B$$ CCF:E<E EE EE EF E1%E,'F,E11FFF,F<<"Galways key_to_set value_to_set quote_modeexportc|dvrtd||dkp|dko| }|r*d|dd}n|}|r d|d |d } n|d |d } t ||| 5\} } d } d } t t | D]d}|j|kr| | d } %| |j j |j j d  } e| s,| r| d | | dddn #1swxYwYd ||fS)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~autoneverzUnknown quote_mode: r~rz'{}''z\'zexport = r.r\FTN) ValueErrorisalnumformatrur}r(rrFwriter%stringendswith)r+rrrrr.r\quote value_outline_outrwrzreplacedmissing_newliner's rset_keyrs$444< <<=== ( " f;\%9%9%;%;!;  !MM,"6"6sE"B"BCC   17Z77)777 009000 x Q Q Q!V 2<3G3GHH M MG{j(( 8$$$ 7+2333&-&6&=&F&Ft&L&L"L ! ! 4   JJx !!!!!!!!!!!!!!!!$ \ ))s B7EEE key_to_unsetctj|std|d|fSd}t |||5\}}t t|D]/}|j|krd}| |j j 0 dddn #1swxYwY|s td||d|fS||fS)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.NFrTz/Key %s not removed from %s - key doesn't exist.) rr[existsr#r$r}r(rrFrr%r) r+rrr.r\removedrwrzr's r unset_keyrsB" 7>>+ & &"A;OOO\!!G x Q Q Q4V 2<3G3GHH 4 4G{l** 7+23333  4 444444444444444 " =|[   \!! L  sAB00B47B4valuesr0cji}|D]\}}|d}nt|}i|r5tj|n4|tjdfd|D}|||<|S)Nr9c3BK|]}|VdSr2)resolve).0atomenvs r z$resolve_variables..3s/AA4T\\#..AAAAAAr)rupdaterrjoin)rr0 new_valuesrsrresultatomsrs @rrBrB!s,.J"" e =FF#E**E,.C ' 2:&&& :&&&& :&&& 2:&&&WWAAAA5AAAAAF! 4 rc#Ktj|stdtj|rtj|}d}tj|}||kr\|Vtjtj|tjj}||}}||kZdSdS)zL Yield directories starting from the given directory up to the root zStarting path not foundN) rr[rIOErrorisfilerorprpardir)r[last_dir current_dir parent_dirs r _walk_to_rootr:s 7>>$  1/000 w~~d%wt$$H'//$''K k ! !W__RW\\+rw~%N%NOO +Z+ k ! ! ! ! ! !rr8filenameraise_error_if_not_foundusecwdcd}d}|s*|s |sttddrtj}ntj}t }|jj|ks)tj |jjsI|j J|j }|jj|k tj |jjI|jj}tj tj |}t|D]5} tj| |} t| r| cS6|rt!ddS)z Search in increasingly higher folders for the given file Returns path to the file if found, or an empty string otherwise cttdsttdrdS tddddg}n#t$rYdSwxYwt|d S) z._is_interactiveWs~ 3   '#u"5"5 4 j$ |LLLDD"   55 4,,,,sA AAc,tjduSr2)rgettracerVrr _is_debuggerz!find_dotenv.._is_debuggeras|~~T))rfrozenFNzFile not foundr9)getattrrrgetcwd _getframerf_code co_filenamer[rf_backrorprrr:r) rrrrrr[frame current_fileframe_filenamero check_paths r find_dotenvrLs---***@""@llnn@Xu8U8U@y{{  l&,66bgnn L $? ? 6<+++LE l&,66bgnn L $? ? 6 1wrw~>>?? &&W\\'844 J ' '      (&''' 2rTr,r-r/ctrtddS||t}t ||||||}|S)aParse 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 variableFNr+r,r-r/r0r.)rr#debugrr*rK)r+r,r-r0r/r.dotenvs r load_dotenvrs: a   uv~!mm  F  . . 0 00rct||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)rr*rD)r+r,r-r/r.s r dotenv_valuesrsK.v~!mm      dff rctj|rdS tj|}n#tt f$rYdSwxYwtj|jS)zN Return True if `path` exists and is either a regular file or a FIFO. TF)rr[rrfrlOSErrorS_ISFIFOrh)r[sts rr:r:sn w~~dt WT]] w 'uu = $ $$s8A  A )rW)F)r~FrWF)r~rWF)r8FF)NNFFTrW)NNFTrW),r=loggingrrqrfrrm collectionsr contextlibrtypingrrrrr r r r parserrr variablesrrTrS getLoggerrPr#rUrr(r*rZr}rrrBrrrrr:rVrrrs    ######%%%%%%PPPPPPPPPPPPPPPPPPPP))))))))&&&&&& '' (  8 $ $3t3333(7*;@QPPPPPPPPl& P P P Psm Pc] P P P P"33 3sm33eBsGRW$%& 3333t%!4*4*4*4*4* 4*  4* sm 4*4* 8D>3 #$4*4*4*4*t%! &!&!&!&!&!sm &!  &!  8D>3  &!&!&!&!R U3 -. / S(3-  288 8888&%*000"0 0 0000h&* $% .1.1'".1 RW .1.1 .1  .1 sm .1 .1.1.1.1d&* $% ! ! '"! RW ! !  ! sm !  #x}  ! ! ! ! H %7 %t % % % % % %r