fB/ddlZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z mZmZmZmZmZmZddlmZmZddlmZeedfZej6eZd eed eefd ZGd d Z d(dededeed eefdZ e dedeed eee ee effdZ! d)dedededede"deed eee"eeffdZ# d*dedededeed eee"eff dZ$deeeeefde"d eeeeffdZ%ded eefdZ& d+ded e"d!e"d efd"Z' d,deed#ee ed$e"de"d%e"deed e"fd&Z( d-deed#ee ed$e"d%e"deed e eeeff d'Z)y).N) OrderedDict)contextmanager)IODictIterableIteratorMappingOptionalTupleUnion)Binding parse_stream)parse_variableszos.PathLike[str]mappingsreturnc#K|D]<}|jr*tjd|jj|>yw)Nz;Python-dotenv could not parse statement starting at line %s)errorloggerwarningoriginalline)rmappings T/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dotenv/main.pywith_warn_for_invalid_linesrs< == NNM  %%  sAAceZdZ ddeedeeededeedededdfd Ze de eefd Z de eeeffd Z de eeeeffd Zdefd ZdedeefdZy)DotEnvN dotenv_pathstreamverboseencoding interpolateoverridercf||_||_d|_||_||_||_||_yN)rr_dictr r!r"r#)selfrrr r!r"r#s r__init__zDotEnv.__init__$s7/:)/ 9= $ '/ !,& c#K|jrXtjj|jr/t |j|j 5}|dddy|j |j y|jr$tjd|jxsdtjdy#1swYyxYww)Nr!z3Python-dotenv could not find configuration file %s..env) rospathisfileopenr!rr rinfoioStringIO)r'rs r _get_streamzDotEnv._get_stream5s   t/?/? @d&&? 6    [[ $++ || I$$.++b/ !  sACC A,C CCc|jr |jS|j}|jr1tt ||j |_|jSt||_|jS)zReturn dotenv as dict)r#)r&parser"rresolve_variablesr#)r' raw_valuess rdictz DotEnv.dictDsc :::: ZZ\   $%6zDMM%Z[DJzz%Z0DJzzr)c#K|j5}tt|D])}|j|j|jf+ dddy#1swYyxYwwr%)r5rrkeyvalue)r'rrs rr7z DotEnv.parseRsZ     566|F7KL;;*!++w}}44M 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)r:itemsr.environr#)r'kvs rset_as_environment_variablesz#DotEnv.set_as_environment_variablesXsXyy{IIK%%'DAqBJJt}}} ! 1 ( r)r<c|j}||vr||S|jr!tjd||jy)z zKey %s not found in %s.N)r:r rrr)r'r<datas rgetz DotEnv.getgsAyy{ $;9  << NN4c4;K;K Lr))NFNTT)__name__ __module__ __qualname__r StrPathrstrboolr(rrr5rr:r r7rCrFr)rrr#s%)"& 'g&'C!' ' 3- '  '' '" "Xbg. " " d3 -. 5xc8C=&8 9:5 d  s x} r)rr 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!)rrF)rrNr!s rget_keyrPus +th ? C CJ OOr)r/c#Ktj|jtjd|d5}d} t ||5}||fdddddd!tjj|ytjj|d#1swYVxYw#t $r }|}Yd}~id}~wwxYw#1swYrxYww)NwF)moder!deleter+) pathlibPathtouchtempfileNamedTemporaryFiler1 BaseExceptionshutilmovenamer.unlink)r/r!destrsourceerrs rrewriterbs  LL  $ $# OSW dX. %&tn$ % } DIIt$ $)) % % E  sY>+ &A;O\!!G x 04NVT2<3GHG{{l* 7++223 I4 H,Xcd\!! L  44s ACCvaluesr#cHi}|D]\}}|d}nt|}i|r1jtjj|n0j|jtjdj fd|D}|||<|S)Nr-c3@K|]}|jywr%)resolve).0atomenvs r z$resolve_variables..sA4T\\#.As)rupdater.r@join)rr# new_valuesr]r=resultatomsrs @rr8r8s,.J u =F#E*E,.C 2::& :& :& 2::&WWA5AAF! 4 r)c#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) r.r/r}IOErrorr0dirnameabspathrpardir)r/last_dir current_dir parent_dirs r _walk_to_rootrs 77>>$ /00 ww~~dwwt$H''//$'K k !WW__RWW\\+rww~~%NO +Z+ k !s C1C64C6filenameraise_error_if_not_foundusecwdcjd}|s|sttddrtj}n tj}t }|j j|k(s3tjj|j jsh|jJ|j}|j j|k(r4tjj|j jsh|j j}tjjtjj|}t|D]E}tjj||} tjj| sC| 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 c\ tddddg}t|d S#t$rYywxYw)z> Decide whether this is running in a REPL or IPython notebook __main__N__file__)fromlistF) __import__ModuleNotFoundErrorhasattr)mains r_is_interactivez$find_dotenv.._is_interactives? j$ |LD4,,,#  s  ++frozenFzFile not foundr-)getattrsysr.getcwd _getframerf_code co_filenamer/r}f_backrrrrr0r) rrrrr/frame current_fileframe_filenamer check_paths r find_dotenvrs/-"gc8U&Cyy{  ll&&,6bggnn LL $ $? <<+ ++LLE ll&&,6bggnn LL $ $? 11wwrww~>? &WW\\'84 77>>* % '  &'' r)rr r"c`| | t}t||||||}|jS)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. rrr r"r#r!)rrrC)rrr r#r"r!dotenvs r load_dotenvrAsB0v~!m  F  . . 00r)c\| | 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)rrr:)rrr r"r!s r dotenv_valuesrgs=.v~!m    df r))utf-8)rhFr)rhr)r,FF)NNFFTr)NNFTr)*r3loggingr.rUr[rrX collectionsr contextlibrtypingrrrrr r r r parserrr variablesrrKrJ getLoggerrGrrrrPrbrLrzrr8rrrrrMr)rrs%   #%*& '' (   8 $(7*;@QOOj& P P Psm Pc] P smeBsGRW$%&2% .*.*.*.* .*  .* sm .* 8D>3 #$.*h% !!!!sm !  8D>3  !> U3 -. / S(3-  288 8&%*++"+ + +^&* $% #1'"#1 RW #1#1 #1  #1 sm #1 #1N&* $% ! '"! RW ! !  ! sm !  #x}  ! r)