Xj[9ddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZmZmZmZmZmZddlmZmZddlmZeedfZej6eZd efd Zd eed eefd Z Gd dZ! d+dededeed eefdZ"e d,dedeeded eee ee effdZ# d-dedededededeeded eeeeeffdZ$ d.dedededeeded eeeeff dZ%deeeeefded eeeeffdZ&ded eefd Z' d/d!ed"ed#ed efd$Z( d0deed%ee ed&eded'edeed efd(Z) d1deed%ee ed&ed'edeed e eeeff d)Z*ded efd*Z+y)2N) OrderedDict)contextmanager)IODictIterableIteratorMappingOptionalTupleUnion)Binding parse_stream)parse_variableszos.PathLike[str]returncrdtjvrytjdj}|dvS)z8 Determine if dotenv loading has been disabled. PYTHON_DOTENV_DISABLEDF>1tyyestrue)osenvironcasefold)values _/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/dotenv/main.py_load_dotenv_disabledrs7 rzz1 JJ/ 0 9 9 ;E 2 22mappingsc#K|D]<}|jr*tjd|jj|>yw)Nz;python-dotenv could not parse statement starting at line %s)errorloggerwarningoriginalline)r mappings rwith_warn_for_invalid_linesr( sA == NNM  %%  sAAceZdZ ddeedeeededeedededdfd Ze de eefd Z de eeeffd Z de eeeeffd Zdefd ZdedeefdZy)DotEnvN dotenv_pathstreamverboseencoding interpolateoverridercf||_||_d|_||_||_||_||_yN)r+r,_dictr-r.r/r0)selfr+r,r-r.r/r0s r__init__zDotEnv.__init__+s7/:)/ 9= $ '/ !,& rc#K|jrDt|jr/t|j|j5}|dddy|j|jy|j r$t jd|jxsdtjdy#1swYyxYww)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    01A1A Bd&&? 6    [[ $++ || I$$.++b/ !  sACB6 A,C6B?;Cc|jr |jS|j}|jr1tt ||j |_|jSt||_|jS)zReturn dotenv as dict)r0)r3parser/rresolve_variablesr0)r4 raw_valuess rdictz DotEnv.dictKse :::: ZZ\   $!*t}}EDJ zz%Z0DJzzrc#K|j5}tt|D])}|j|j|jf+ dddy#1swYyxYwwr2)r?r(rkeyr)r4r,r's rrAz DotEnv.parse[s^     566|F7KL 5;;*!++w}}44 5 5 5 5s!A*$AA A*A'#A*c|jsy|jjD]:\}}|tjvr |js%|(|tj|<<y)zI Load the current dotenv as system environment variable. FT)rDitemsrrr0)r4kvs rset_as_environment_variablesz#DotEnv.set_as_environment_variablesas]yy{IIK%%' "DAqBJJt}}} ! 1  " rrFc|j}||vr||S|jr!tjd||jy) zKey %s not found in %s.N)rDr-r#r$r+)r4rFdatas rgetz DotEnv.getps?yy{ $;9  << NN4c4;K;K Lr)NFNTT)__name__ __module__ __qualname__r StrPathrstrboolr5rrr?rrDr rArKrOrrr*r**s%)"& 'g&'C!' ' 3- '  '' '" "Xbg. " "d3 -. 5xc8C=&8 9:5 d  s x} rr*r+ key_to_getr.c<t|d|j|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+rWr.s rget_keyrY}s +th ? C CJ OOrpathfollow_symlinksc #K|rtjj|} t||} tj|}t j |jrt j|jnd} tjd|ddtjj!tjj#|5}t%j&|j(}d} |5||fdddddd0 |tj*|tj,|yj/d|d#t$r|jwxYw#t$rtjd}d}YwxYw#1swYxYw#t$r } | }Yd} ~ d} ~ wwxYw#1swYxYw#t$rj/dwxYww) Nr7r9wFz.tmp_)moder.deleteprefixdirT) missing_ok)rrZrealpathr;lstatstatS_ISREGst_modeS_IMODE BaseExceptioncloseFileNotFoundErrorr=r>tempfileNamedTemporaryFiledirnameabspathpathlibPathnamechmodreplaceunlink) rZr.r[source path_stat original_modedest dest_pathr"errs rrewriter|s ww%th7 I<< 1 12 Y../   $ $  GGOOBGGOOD1 2   LL+   %tn$ %  } (M2 JJy$ ' D)E  LLN   R  % % E ,      -  s"G5 E>AE AG5"G F1F% F1 G5.G G5 E;;E>> F"G5!F""G5%F. *F11 G:G<G GG  GG5G22G5 key_to_set value_to_set quote_modeexportc|dvrtd||dk(xs|dk(xr|j }|r"dj|jdd}n|}|r d|d |d } n|d |d } t ||| 5\} } d } d } t t | D]p}|j|k(r| j| d } &| j|jj|jjjd  } r| s$| r| jd | j| dddd ||fS#1swYxYw)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`. )alwaysautoneverzUnknown quote_mode: rrz'{}''z\'zexport = r.r[FTN) ValueErrorisalnumformatrtr|r(rrFwriter%stringendswith)r+r}r~rrr.r[quote value_outline_outrvryreplacedmissing_newliner's rset_keyrsn$44/ |<== ( " f;\%9%9%;!;  MM,"6"6sE"BC   ZL)B7 \9+R0 x Q!V 2<3GH MG{{j( 8$ 7++223&-&6&6&=&=&F&Ft&L"L  M 4 JJx !!$ \ ))%!!s :B5D<<E key_to_unsetctjj|stj d|d|fSd}t |||5\}}t t|D]9}|j|k(rd}|j|jj; ddd|stj d||d|fS||fS#1swY*xYw)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.) rrZexistsr#r$r|r(rrFrr%r) r+rrr.r[removedrvryr's r unset_keyrs" 77>>+ &A;O\!!G x Q4V 2<3GH 4G{{l* 7++223  4 4  =|[ \!! L  !44s ACCvaluesr0cHi}|D]\}}|d}nt|}i|r1jtjj|n0j|jtjdj fd|D}|||<|S)Nr9c3@K|]}|jywr2)resolve).0atomenvs r z$resolve_variables..3sA4T\\#.As)rupdaterrjoin)rr0 new_valuesrrrresultatomsrs @rrBrB!s,.J" e =F#E*E,.C 2::& :& :& 2::&WWA5AAF! 4" rc#Ktjj|s tdtjj |rtjj |}d}tjj |}||k7rd|tjj tjj|tjj}||}}||k7rcyyw)zL Yield directories starting from the given directory up to the root zStarting path not foundN) rrZrIOErrorisfilernrorpardir)rZlast_dir current_dir parent_dirs r _walk_to_rootr:s 77>>$ /00 ww~~dwwt$H''//$'K k !WW__RWW\\+rww~~%NO +Z+ k !s C1C64C6filenameraise_error_if_not_foundusecwdcVd}d}|s|s|sttddrtj}n tj}t }|j j|k(s3tjj|j jsh|jJ|j}|j j|k(r4tjj|j jsh|j j}tjjtjj|}t|D]1} tjj| |} t| s/| cS|r t!dy)z Search in increasingly higher folders for the given file Returns path to the file if found, or an empty string otherwise cttdsttdry tddddg}t|d S#t$rYywxYw) z._is_interactiveWsU 3 '#u"5 j$ |LD4,,,#  sA A  A c.tjduSr2)rgettracerVrr _is_debuggerz!find_dotenv.._is_debuggeras||~T))rfrozenFzFile not foundr9)getattrrrgetcwd _getframerf_code co_filenamerZrf_backrnrorrr:r) rrrrrrZframe current_fileframe_filenamern check_paths r find_dotenvrLs5-*"lnXu8Uyy{  ll&&,6bggnn LL $ $? <<+ ++LLE ll&&,6bggnn LL $ $? 11wwrww~>? &WW\\'84 J '   &'' rr,r-r/ctrtjdy| | t}t ||||||}|j 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 variableFr+r,r-r/r0r.)rr#debugrr*rK)r+r,r-r0r/r.dotenvs r load_dotenvrs\: a v~!m  F  . . 00rc\| | t}t||||d|jS)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. Tr)rr*rD)r+r,r-r/r.s r dotenv_valuesrs=.v~!m    df rctjj|ry tj|}tj |jS#tt f$rYywxYw)zN Return True if `path` exists and is either a regular file or a FIFO. TF)rrZrrerkOSErrorS_ISFIFOrg)rZsts rr:r:sW ww~~d WWT] == $$ w 'sAA('A()utf-8)F)rFrF)rrF)r8FF)NNFFTr)NNFTr),r=loggingrrprerrl collectionsr contextlibrtypingrrrrr r r r parserrr variablesrrTrS getLoggerrPr#rUrr(r*rYr|rrrBrrrrr:rVrrrsh   #%PPP)& '' (   8 $3t3(7*;@QPPl& P P Psm Pc] P"3 3sm33eBsGRW$%& 33t%!4*4*4*4* 4*  4* sm 4*4* 8D>3 #$4*t%! &!&!&!&!sm &!  &!  8D>3  &!R U3 -. / S(3-  288 8&%*00"0 0 0h&* $% .1'".1 RW .1.1 .1  .1 sm .1 .1d&* $% ! '"! RW ! !  ! sm !  #x}  ! H %7 %t %r