;iP4ddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z mZmZmZmZmZmZmZddlmZmZddlmZeedfZejeZd efd Z d eed eefd Z!Gd dZ" d/dededeed eefdZ#e dedeed eee ee effdZ$ d0dedededededeed eeeeeffdZ% d1dedededeed eeeeff dZ&deeeeefd ed eeeeffd!Z'ded eefd"Z( d2d$ed%ed&ed efd'Z) d3deed)ee ed*ed ed+edeed efd,Z* d4deed)ee ed*ed+edeed eeeeff d-Z+ded efd.Z,dS)5N) 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 ?C:\PYTHON\MyICR_Workspace\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.dictNsj : : 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_variablesdsjyy{{ 5IIKK%%'' " "DAqBJt}} ! 1 trrFc|}||vr||S|jr!td||jdS) zKey %s not found in %s.N)rDr-r#r$r+)r4rFdatas rgetz DotEnv.getssLyy{{ $;;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_keyrZs' +th ? ? ? C CJ O OOrpathc#Ktj|tjd|d5}d} t ||5}||fVdddn #1swxYwYn#t $r }|}Yd}~nd}~wwxYwdddn #1swxYwY|tj|j |dStj |j |d)NwF)moder.deleter7) pathlibPathtouchtempfileNamedTemporaryFiler; BaseExceptionshutilmovenamerunlink)r[r.destr"sourceerrs rrewritermsx  L  $# O O OSW dX... %&tn$$$ % % % % % % % % % % % % % % %   EEEEEE   } DIt$$$$$ $)s`BA4A( A4(A, ,A4/A, 0A43B4 B >BBB  BB BalwaysF 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)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 )rnautoneverzUnknown quote_mode: rnrtz'{}''z\'zexport = r7FTN) ValueErrorisalnumformatreplacermr(rrFwriter%stringendswith)r+rorprqrrr.quote value_outline_outrkrjreplacedmissing_newliner's rset_keyrs444< <<=== ( " f;\%9%9%;%;!;  !MM,"6"6sE"B"BCC   17Z77)777 009000 x 0 0 0 !NVT2<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)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.NFr7Tz/Key %s not removed from %s - key doesn't exist.) rr[existsr#r$rmr(rrFr}r%r~)r+rrqr.removedrkrjr's r unset_keyrs: 7>>+ & &"A;OOO\!!G x 0 0 04NVT2<3G3GHH 4 4G{l** 7+23333  4444444444444444 " =|[   \!! L  sAB//B36B3valuesr0cji}|D]\}}|d}nt|}i|r5tj|n4|tjdfd|D}|||<|S)Nr9c3BK|]}|VdSr2)resolve).0atomenvs r z$resolve_variables..s/AA4T\\#..AAAAAAr)rupdaterrjoin)rr0 new_valuesrhrresultatomsrs @rrBrBs,.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[rIOErrorisfiledirnameabspathrpardir)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_interactive*s~ 3   '#u"5"5 4 j$ |LLLDD"   55 4,,,,sA AAc,tjduSr2)rgettracerVrr _is_debuggerz!find_dotenv.._is_debugger4s|~~T))rfrozenFNzFile not foundr9)getattrrrgetcwd _getframerf_code co_filenamer[rf_backrrrrr:r) rrrrrr[frame current_fileframe_filenamer check_paths r find_dotenvrs---***@""@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_dotenvrRs: 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[rstatFileNotFoundErrorOSErrorS_ISFIFOst_mode)r[sts rr:r:sn w~~dt WT]] w 'uu = $ $$s8A  A )rW)rnFrW)rnrW)r8FF)NNFFTrW)NNFTrW)-r=loggingrr`rfrrrc collectionsr contextlibrtypingrrrrr r r r parserrr variablesrrTrS getLoggerrPr#rUrr(r*rZrmrrrBrrrrr:rVrrrs   ######%%%%%%PPPPPPPPPPPPPPPPPPPP))))))))&&&&&& '' (  8 $ $3t3333(7*;@QPPPPPPPPl& P P P Psm Pc] P P P P smeBsGRW$%&2% -*-*-*-*-* -*  -* sm -* 8D>3 #$-*-*-*-*f% !!!!!sm !  8D>3  !!!!B 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