
    Mh*                     t    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y)
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y)Environmentconfigr   prefixreturnNc                 .    || _         || _        i | _        y N)_config_prefixdata)selfr   r   s      b/var/www/pru.catia.catastroantioquia-mas.com/valormasv2/lib/python3.12/site-packages/invoke/env.py__init__zEnvironment.__init__   s    $&	    c                    | j                  g i       }d}t        |j                  | j                  |             |j	                         D ]N  \  }}| j                  xs d|z   }|t
        j                  v s,| j                  |t
        j                  |          P t        dj                  | 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Lahht||X./!)!1 	?GX*g5H2::%xH)=>	? 	-44TYY?@yyr   r   r   c                    i }| j                  |      }t        |d      rt        |j                        rt        |d      rs|j                         D ]^  }t	        |fi |}||gz   }| j                  ||      }|D ]"  }||v sd}	t        |	j                  |             |j                  |       ` |S ||| j                  |      <   |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 "]+xxz 
)"88x8&#.++k;?" ?Ch6-cjjo>>?
 (
)  4<HT%%h/0r   c                 @    dj                  |      j                         S )N_)joinupper)r   r   s     r   r3   zEnvironment._to_env_varX   s    xx!''))r   c                 6    | j                   }|D ]  }||   }	 |S r   )r   )r   r   r5   r6   s       r   r.   zEnvironment._path_get[   s*     ll 	Cc(C	
r   valuec                     | j                   }|d d D ]  }||vri ||<   ||   } | j                  |      }| j                  ||      }|||d   <   y )N)r   r.   _cast)r   r   r@   r5   r6   oldnews          r   r&   zEnvironment._path_setc   si     iiCR= 	C#~Cc(C	 nnX&jje$HRLr   rD   rE   c                     t        |t              r|dvS t        |t              r|S ||S t        |t        t        f      r'd}|j                  t        |            }t        |      |j                  |      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   so    c4 i''S!J[JdE]+@C**T#Y'C"3''==%%r   )__name__
__module____qualname__rJ   r   r   r   r*   r   r   r	   r!   r   r3   r.   r&   rC    r   r   r   r      s    '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      s0    
 N N N 9 f& f&r   