
    Ri*                     |    d Z ddlZddlmZmZmZmZmZmZm	Z	 ddl
mZmZ ddlmZ erddlmZ  G d d	          ZdS )
a.  
Environment variable configuration loading class.

Using a class here doesn't really model anything but makes state passing (in a
situation requiring it) more convenient.

This module is currently considered private/an implementation detail and should
not be included in the Sphinx API documentation.
    N)TYPE_CHECKINGAnyDictIterableListMappingSequence   )UncastableEnvVarAmbiguousEnvVar)debug)Configc                       e Zd ZdddeddfdZdeeef         fdZdee         d	e	ee
e         f         deeef         fd
Zdee         defdZdee         ddfdZde
e         deddfdZdededefdZdS )Environmentconfigr   prefixreturnNc                 0    || _         || _        i | _        d S N)_config_prefixdata)selfr   r   s      B/srv/django_bis/venv311/lib/python3.11/site-packages/invoke/env.py__init__zEnvironment.__init__   s    $&			    c                    |                      g i           }d}t          |                    | j        |                     |                                D ]E\  }}| j        pd|z   }|t
          j        v r&|                     |t
          j        |                    Ft          d                    | j                             | j        S )z
        Return a nested dict containing values from `os.environ`.

        Specifically, values whose keys map to already-known configuration
        settings, allowing us to perform basic typecasting.

        See :ref:`env-vars` for details.
        )key_pathenv_varsz>Scanning for env vars according to prefix: {!r}, mapping: {!r} zObtained env var config: {!r})	_crawlr   formatr   itemsosenviron	_path_setr   )r   r   menv_varr   real_vars         r   loadzEnvironment.load   s     ;;R;88Lahht|X..///!)!1!1 	? 	?GX*g5H2:%%xH)=>>>-44TY??@@@yr   r   r   c                    i }|                      |          }t          |d          rt          |j                  rt          |d          r|                                D ]m}t	          |fi |}||gz   }|                     ||          }|D ]*}||v r$d}	t          |	                    |                    +|                    |           nn||| 	                    |          <   |S )a  
        Examine config at location ``key_path`` & return potential env vars.

        Uses ``env_vars`` dict to determine if a conflict exists, and raises an
        exception if so. This dict is of the following form::

            {
                'EXPECTED_ENV_VAR_HERE': ['actual', 'nested', 'key_path'],
                ...
            }

        Returns another dictionary of new keypairs as per above.
        keys__getitem__zFound >1 source for {})
	_path_gethasattrcallabler,   dictr!   r   r"   update_to_env_var)
r   r   r   new_varsobjkeymerged_varsmerged_pathcrawlederrs
             r   r!   zEnvironment._crawl0   s     *,nnX&& C  	<""	< ]++	<
 xxzz 
) 
)"888x88&#.++k;??" ? ?Ch6-cjjoo>>> ' ((((
) 4<HT%%h//0r   c                 P    d                     |                                          S )N_)joinupper)r   r   s     r   r3   zEnvironment._to_env_varX   s     xx!!'')))r   c                 .    | j         }|D ]
}||         }|S r   )r   )r   r   r5   r6   s       r   r.   zEnvironment._path_get[   s*     l 	 	Cc(CC
r   valuec                     | j         }|d d         D ]}||vri ||<   ||         }|                     |          }|                     ||          }|||d         <   d S )N)r   r.   _cast)r   r   r@   r5   r6   oldnews          r   r&   zEnvironment._path_setc   sw     iCRC= 	 	C#~~Cc(CCnnX&&jje$$HRLr   rD   rE   c                 2   t          |t                    r|dvS t          |t                    r|S ||S t          |t          t          f          r3d}|                    t          |                    }t          |          |                    |          S )N)0r    z,Can't adapt an environment string into a {}!)	
isinstanceboolstrlisttupler"   typer   	__class__)r   rD   rE   r:   s       r   rC   zEnvironment._casto   s    c4   	&i''S!! 		&J[JdE]++ 	&@C**T#YY''C"3'''==%%%r   )__name__
__module____qualname__rJ   r   r   r   r*   r   r   r	   r!   r   r3   r.   r&   rC    r   r   r   r      sI       'x ' ' ' ' ' '
d38n    *&S	&-4S(3-5G-H&	c3h& & & &P*HSM *c * * * *(3- H    
 (3- 
  
  
  
  
  
 & &3 &3 & & & & & &r   r   )__doc__r$   typingr   r   r   r   r   r   r	   
exceptionsr   r   utilr   r   r   r   rR   r   r   <module>rW      s     
			 N N N N N N N N N N N N N N N N N N 9 9 9 9 9 9 9 9       f& f& f& f& f& f& f& f& f& f&r   