fddlZddlZddlZddlZddlmZddlmZddlm Z m Z m Z m Z m Z  ddlZddlmZmZmZddlmZd Zej4ej6d d eej8d dej6dddej:gddej6dddej<dej>eej@dejBde de de ddf dZ"ed ejFde e e$fd!Z%e"jMej@ej6d"d#ej:gd$d%dejBd&e'ddfd'Z(e"jMej@ejRd(d )ejRd*d )dejBd(e d*e ddfd+Z*e"jMej@ejRd(d )dejBd(e ddfd,Z+e"jMej@ejRd(d )dejBd(e ddfd-Z,e"jMd.d i/ej@ej6d0d d12ejRd3d4ejZ5dejBd6e'd3e e$ddfd7Z.d8e e$d9e e$e$fde/fd:Z0y#e$r1ej j#dej$dY#wxYw);N)contextmanager)Popen)AnyDictIOIteratorListzkIt seems python-dotenv is not installed with cli option. Run pip install "python-dotenv[cli]" to fix this.) dotenv_valuesset_key unset_key) __version__c tj}tjj |d}|S#t$rYywxYw)zZ Return a path for the ${pwd}/.env file. If pwd does not exist, return None. Nz.env)osgetcwdFileNotFoundErrorpathjoin)cwdrs S/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/dotenv/cli.py enumerate_envrsA iik 77<<V $D K s8 AAz-fz--fileT) file_okayzNLocation of the .env file, defaults to .env file in current working directory.)defaulttypehelpz-qz--quotealways)rneverautozbWhether to quote or not the variable values. Default mode is always. This does not affect parsing.z-ez--exportFz;Whether to write the dot file as an executable bash script.)versionctxfilequoteexportreturnc|||d|_y)zAThis script is used to set, get or unset values from a .env file.)QUOTEEXPORTFILEN)obj)r r!r"r#s rclir*"s>CGrc#K t|5}|dddy#1swYyxYw#t$r3}td|tjt dYd}~yd}~wwxYww)z~ Open a file and yield the corresponding (decoded) stream. Exits with error code 2 if the file cannot be opened. NzError opening env file: )r!)openOSErrorprintsysstderrexit)rstreamexcs r stream_filer63s[ $Z 6L     (.SZZ@ QsCA( ))A(&)A() A%)A A( A%%A(z--formatsimple)r7jsonshellr#zlThe format in which to display the list. Default format is simple, which displays name=value without quotes.formatc|jd}t|5}t|}ddd|dk(r,tjt j ddy|dk(rd nd }tD]?}||}| |d vrtj|}tj||d |Ay#1swYxYw) z!Display all the stored key/value.r(r4Nr8r-T)indent sort_keysr#zexport )r#r9=) r)r6r clickechor8dumpssortedshlexr")r r:r!r4valuesprefixkvs rlistrJCs 776?D T .ff-. 4::fQ$?@$0bAq A}00 AA fXaS!-.  ..s B88Ckey)requiredvaluec|jd}|jd}|jd}t|||||\}}}|rtj|d|yt dy)zStore the given key/value.r(r&r'r@r N)r)r rArBr3)r rKrMr!r"r#successs rsetrP\sg 776?D GGG E WWX F!$UE6BGS% cU!E7#$ Qr+c|jd}t|5}t|}dddj|}|rt j |yt dy#1swY>xYw)z%Retrieve the value for the given key.r(r<Nr )r)r6r getrArBr3)r rKr!r4rF stored_values rrRrRls_ 776?D T .ff-.::c?L <  Q..s A%%A.c|jd}|jd}t|||\}}|rtjd|yt dy)zRemoves the given key.r(r&zSuccessfully removed r N)r)r rArBr3)r rKr!r"rOs runsetrU}sO 776?D GGG ET3.LGS *3%01 Qr+ignore_unknown_options)context_settingsz--override/--no-overridezKOverride variables from the environment file with those from the .env file.)rr commandline)nargsroverridec|jd}tjj|st j d|d|t |jDcic]\}}||s|tjvr|| }}}|s t jdtdt||}t|ycc}}w)z/Run command with environment variables present.r(zInvalid value for '-f' "z" does not exist.)r NzNo command given.r ) r)rrisfilerA BadParameterr itemsenvironrBr3 run_command)r r[rXr!rHrIdotenv_as_dictrets rrunrds 776?D 77>>$   (.? @  $D)//1 Q =h!2::*= 1N  &' Q k> 2CIs&#Ccommandenvctjj}|j|t |ddd|}|j \}}|j S)awRun command in sub process. Runs the command in a sub process with the variables from `env` added in the current environment variables. Parameters ---------- command: List[str] The command and it's parameters env: Dict The additional environment variables Returns ------- int The return code of the command TrF)universal_newlinesbufsizer9rf)rr`copyupdater communicate returncode)rerfcmd_envp_s rrarasS*jjooG NN3 g!%  A ==?DAq <<r+)1r8rrEr1 contextlibr subprocessrtypingrrrrr rA ImportErrorr2writer3mainr r r rrrgroupoptionPathChoiceBOOLversion_option pass_contextContextr*PathLikestrr6reboolrJargumentrPrRrU UNPROCESSEDrdintrar+rrs %00 43    dHmo5::-cedIx5<< ;<wydJ::PRk*?U]]?#?c?3?4?+Rye?  bkk hr#w&7   j(5<< EF?@/emm/T/d/ @ /&%$' U]]  S T (& % U]]   & %u}}34&7>?   V  Re.?.?@U]]dctA @*cc3hC{JJIJ CHHQKsL2MM