
    Ld                        d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	m
Z
mZmZmZ 	 d dlZn5# e$ r- ej                            d            ej        d           Y nw xY wddlmZmZmZ ddlmZ  ej                     ej        d	d
ej                             ej                    d           ej        d          d           ej        ddd ej        g d          d           ej        dddej         d           ej!        e          ej"        dej#        de	de	de	ddf
d                                                                        Z$ed ej%        deee&                  fd!            Z'e$(                                ej"         ej        d"d# ej        g d$          d%          dej#        d&e)ddfd'                                    Z*e$(                                ej"         ej+        d(d)           ej+        d*d)          dej#        d(e	d*e	ddfd+                                                Z,e$(                                ej"         ej+        d(d)          dej#        d(e	ddfd,                                    Z-e$(                                ej"         ej+        d(d)          dej#        d(e	ddfd-                                    Z.e$(                    d.di/          ej"         ej        d0dd12           ej+        d3d4ej/        5          dej#        d6e)d3ee&         ddfd7                                                Z0d8ee&         d9e
e&e&f         de1fd:Z2dS );    N)contextmanager)Popen)AnyDictIOIteratorListzkIt seems python-dotenv is not installed with cli option. 
Run pip install "python-dotenv[cli]" to fix this.   )dotenv_valuesset_key	unset_key)__version__z-fz--filez.envT)	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                     |||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   s       0F:\djangOuth\env\Lib\site-packages\dotenv/cli.pyclir"      s     >>CGGG    pathc              #      K   	 t          |           5 }|V  ddd           dS # 1 swxY w Y   dS # t          $ r8}t          d| t          j                   t          d           Y d}~dS d}~ww xY w)z~
    Open a file and yield the corresponding (decoded) stream.

    Exits with error code 2 if the file cannot be opened.
    NzError opening env file: )r      )openOSErrorprintsysstderrexit)r$   streamexcs      r!   stream_filer/   %   s      $ZZ 	6LLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	   ...SZ@@@@Qs,   2 %2 )2 )2 
A4-A//A4z--formatsimple)r0   jsonshellr   zlThe format in which to display the list. Default format is simple, which displays name=value without quotes.formatc                    | j         d         }t          |          5 }t          |          }ddd           n# 1 swxY w Y   |dk    r+t          j        t          j        |dd                     dS |dk    rd	nd
}t          |          D ]?}||         }|3|dv rt          j	        |          }t          j        | | d|            @dS )z!Display all the stored key/value.r   r-   Nr1   r&   T)indent	sort_keysr   zexport  )r   r2   =)
r    r/   r   clickechor1   dumpssortedshlexr   )r   r3   r   r-   valuesprefixkvs           r!   listrC   5   s0    76?D	T		 .ff---. . . . . . . . . . . . . . . 
4:fQ$???@@@@@$00b 	/ 	/Aq	A}000AA
f-a--!--...	/ 	/   :>>key)requiredvaluec                     | j         d         }| j         d         }| j         d         }t          |||||          \  }}}|rt          j        | d|            dS t	          d           dS )zStore the given key/value.r   r   r   r9   r
   N)r    r   r:   r;   r,   )r   rE   rG   r   r   r   successs          r!   setrJ   N   s~     76?DGGEWXF!$UE6BBGS% 
c##E##$$$$$Qr#   c                    | j         d         }t          |          5 }t          |          }ddd           n# 1 swxY w Y   |                    |          }|rt	          j        |           dS t          d           dS )z%Retrieve the value for the given key.r   r5   Nr
   )r    r/   r   getr:   r;   r,   )r   rE   r   r-   r?   stored_values         r!   rL   rL   ^   s    
 76?D	T		 .ff---. . . . . . . . . . . . . . . ::c??L 
<     QrD   c                     | j         d         }| j         d         }t          |||          \  }}|rt          j        d|            dS t	          d           dS )zRemoves the given key.r   r   zSuccessfully removed r
   N)r    r   r:   r;   r,   )r   rE   r   r   rI   s        r!   unsetrO   o   sf    
 76?DGGET3..LGS 
030011111Qr#   ignore_unknown_options)context_settingsz--override/--no-overridezKOverride variables from the environment file with those from the .env file.)r   r   commandline)nargsr   overridec                 v   | j         d         }t          j                            |          st	          j        d| d|           fdt          |                                          D             }|s#t	          j        d           t          d           t          ||          }t          |           dS )	z/Run command with environment variables present.r   zInvalid value for '-f' "z" does not exist.)r   c                 @    i | ]\  }}|s|t           j        v||S )N)osenviron).0rA   rB   rU   s      r!   
<dictcomp>zrun.<locals>.<dictcomp>   s>       Q=h=!2:*=*= 	
1*=*=*=r#   zNo command given.r
   N)r    rX   r$   isfiler:   BadParameterr   itemsr;   r,   run_command)r   rU   rR   r   dotenv_as_dictrets    `    r!   runrb   }   s     76?D7>>$ 
 @@@@
 
 
 	
   #D))//11  N  
&'''Q
k>
2
2CIIIIIr#   commandenvc                     t           j                                        }|                    |           t	          | 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bufsizer2   rd   )rX   rY   copyupdater   communicate
returncode)rc   rd   cmd_envp_s        r!   r_   r_      sd    * jooGNN3g!%		 	 	A
 ==??DAq<r#   )3r1   rX   r>   r*   
contextlibr   
subprocessr   typingr   r   r   r   r	   r:   ImportErrorr+   writer,   mainr   r   r   r   r   groupoptionr$   joingetcwdPathChoiceBOOLversion_optionpass_contextContextr"   PathLikestrr/   rc   boolrC   argumentrJ   rL   rO   UNPROCESSEDrb   intr_    r#   r!   <module>r      so    				  



 % % % % % %       0 0 0 0 0 0 0 0 0 0 0 0 0 0LLLL   J I J J JCHQKKKKK
 4 3 3 3 3 3 3 3 3 3             dHbgll929;;&G&G5:---ce e e dIx5< ; ; ;<<wy y y dJ:PR R R k***?U] ?# ?c ?3 ?4 ? ? ?  +*R Ry ye e ?
 bk hr#w&7     j(5< E E EFF?@ @ @/em /T /d / / /	@ @  /& %%%$'''	U] 	 	S 	T 	 	 	 (' &%  	 %%%U]      &%   %%%u} 3 4    &%   7>??	V  
 Re.?@@@U] d c t    A@   @?*c c3h C      s   1 /A#"A#