o
    b                     @   s  d dl Z d dlZd dlmZ d dlmZmZmZ zd dlZW n e	y2   ej
d ed Y nw ddlmZmZmZmZ ddlmZ e ejdd	e je  d
ejddddejdddeg dddejdddejddejedejdejdedededdf
ddZe  ejdejddfd d!Z!e  ejej"d"dd#ej"d$dd#dejd"ed$eddfd%d&Z#e  ejej"d"dd#dejd"eddfd'd(Z$e  ejej"d"dd#dejd"eddfd)d*Z%ej d+did,ejejd-dd.d/ej"d0d1ej&d2dejd3e'd0ee( ddfd4d5Z)d6ee( d7ee(e(f de*fd8d9Z+e,d:kr@e  dS dS );    N)Popen)AnyDictListzkIt seems python-dotenv is not installed with cli option. 
Run pip install "python-dotenv[cli]" to fix this.   )dotenv_valuesget_keyset_key	unset_key)__version__z-fz--filez.envT)Z	file_okayzNLocation of the .env file, defaults to .env file in current working directory.)defaulttypehelpz-qz--quotealways)r   neverautozbWhether 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.)versionctxfilequoteexportreturnc                 C   s(   i | _ || j d< || j d< || j d< dS )zAThis script is used to set, get or unset values from a .env file.QUOTEEXPORTFILEN)obj)r   r   r   r    r   I/var/www/secure340b-portal/env/lib/python3.10/site-packages/dotenv/cli.pycli   s   

r   c                 C   sX   | j d }tj|stjd| | dt|}| D ]\}}td||f  qdS )z!Display all the stored key/value.r   Path "%s" does not exist.r   %s=%sN)	r   ospathisfileclickBadParameterr   itemsecho)r   r   dotenv_as_dictkvr   r   r   list%   s   
r,   key)requiredvaluec                 C   sZ   | j d }| j d }| j d }t|||||\}}}|r'td||f  dS td dS )zStore the given key/value.r   r   r   r!   r   N)r   r	   r%   r(   exit)r   r-   r/   r   r   r   successr   r   r   set4   s   


r2   c                 C   sP   | j d }tj|stjd| | dt||}|r"t| dS td dS )z%Retrieve the value for the given key.r   r   r    r   N)	r   r"   r#   r$   r%   r&   r   r(   r0   )r   r-   r   Zstored_valuer   r   r   getD   s   

r3   c                 C   sF   | j d }| j d }t|||\}}|rtd|  dS td dS )zRemoves the given key.r   r   zSuccessfully removed %sr   N)r   r
   r%   r(   r0   )r   r-   r   r   r1   r   r   r   unsetV   s   

r4   Zignore_unknown_options)Zcontext_settingsz--override/--no-overridezKOverride variables from the environment file with those from the .env file.)r   r   commandline)nargsr   overridec                    sn   | j d }tj|stjd| | d fddt| D }|s,td t	d t
||}t	| dS )	z/Run command with environment variables present.r   z+Invalid value for '-f' "%s" does not exist.r    c                    s,   i | ]\}}|d ur s|t jvr||qS )N)r"   environ).0r*   r+   r8   r   r   
<dictcomp>t   s    zrun.<locals>.<dictcomp>zNo command given.r   N)r   r"   r#   r$   r%   r&   r   r'   r(   r0   run_command)r   r8   r5   r   r)   retr   r;   r   rund   s   





r?   commandenvc                 C   s8   t j }|| t| ddd|d}| \}}|jS )aw  Run 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

    Tr   F)universal_newlinesbufsizeshellrA   )r"   r9   copyupdater   communicate
returncode)r@   rA   Zcmd_envp_r   r   r   r=      s   

r=   __main__)-r"   sys
subprocessr   typingr   r   r   r%   ImportErrorstderrwriter0   mainr   r   r	   r
   r   r   groupoptionr#   joingetcwdPathZChoiceZBOOLZversion_optionZpass_contextContextr   r@   r,   argumentr2   r3   r4   ZUNPROCESSEDboolstrr?   intr=   __name__r   r   r   r   <module>   sr    



,$("
"
