
    DhT                         S r SSKJrJr  SSKJr  SSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKJrJrJrJrJrJrJrJrJr  SSKJrJrJr  SSKJrJr   " S S	\	R:                  5      r\" 5       r\R>                  " \ 5      r! " S
 S5      r"S r#S r$S r%S r&S r'S r( " S S5      r)S r*S r+S r,\RZ                  " SS9\ " S S5      5       5       r. S&S jr/S\R`                  ;  a  \" 5       Rc                  5       r2\2(       a  \!Rg                  S\25        \" S\25        Od\" 5       Ri                  S5      (       a  \!Rg                  S5        O7\" 5       Rk                  5       r2\2(       a  \" S\25        \!Rg                  S \25        S!\R`                  ;   a  \R`                  S!   r2\" \25        gS"\R`                  ;   a  \R`                  S"   r2\" \25        g\" 5       Rc                  5       (       a0  \" 5       Rc                  5       r2\!Rg                  S#\25        \" \25        g\" 5       Rm                  5       (       a  \!Rg                  S$5        g\" 5       Rk                  5       r2\2(       a  \!Rg                  S%\25        \" \25        gg)'zFiona's GDAL/AWS environment    )wrapstotal_ordering)getfullargspecN)	GDALDataFinderGDALEnvPROJDataFindercalc_gdal_version_numget_gdal_configget_gdal_release_nameget_gdal_version_numset_gdal_configset_proj_data_search_path)EnvErrorFionaDeprecationWarningGDALVersionError)SessionDummySessionc                       \ rS rSrS rSrg)	ThreadEnv   c                      S U l         S U l        g N)_env_discovered_optionsselfs    \C:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\fiona/env.py__init__ThreadEnv.__init__   s    	4 $(     )r   r   N)__name__
__module____qualname____firstlineno__r   __static_attributes__ r    r   r   r      s    (r    r   c                       \ rS rSrSr\S 5       rSSS\R                  4S jr	\S 5       r
S rS	 rS
 rS rSS jrSrg)Env@   a}  Abstraction for GDAL and AWS configuration

The GDAL library is stateful: it has a registry of format drivers,
an error stack, and dozens of configuration options.

Fiona's approach to working with GDAL is to wrap all the state
up using a Python context manager (see PEP 343,
https://www.python.org/dev/peps/pep-0343/). When the context is
entered GDAL drivers are registered, error handlers are
configured, and configuration options are set. When the context
is exited, drivers are removed from the registry and other
configurations are removed.

Example:

    with fiona.Env(GDAL_CACHEMAX=512) as env:
        # All drivers are registered, GDAL's raster block cache
        # size is set to 512MB.
        # Commence processing...
        ...
        # End of processing.

    # At this point, configuration options are set to their
    # previous (possible unset) values.

A boto3 session or boto3 session constructor arguments
`aws_access_key_id`, `aws_secret_access_key`, `aws_session_token`
may be passed to Env's constructor. In the latter case, a session
will be created as soon as needed. AWS credentials are configured
for GDAL as needed.
c                     SSSS.$ )zQDefault configuration options

Parameters
----------
None

Returns
-------
dict

TF)CHECK_WITH_INVERT_PROJGTIFF_IMPLICIT_JPEG_OVR	FIONA_ENVr&   clss    r   default_optionsEnv.default_optionsa   s     '+',
 	
r    NFc           	         UR                  SS5      nU(       a  [        R                  " S[        5        UR                  SS5      nUR                  SS5      nUR                  SS5      n	SS1R	                  U5      (       d  [        S	5      eU(       aK  [        U[        5      (       d/  [        R                  " S
[        5        [        R                  " US9nXl	        OU(       d  U(       d  U(       a  [        R                  " UUUU	UUS9U l	        O^SS1R                  [        R                  R                  5       5      (       a  [        R                  " 5       U l	        O[        5       U l	        UR!                  5       U l        0 U l        g)a  Create a new GDAL/AWS environment.
Note: this class is a context manager. GDAL isn't configured
until the context is entered via `with fiona.Env():`

Parameters
----------
session : optional
    A Session object.
aws_unsigned : bool, optional
    Do not sign cloud requests.
profile_name : str, optional
    A shared credentials profile name, as per boto3.
session_class : Session, optional
    A sub-class of Session.
**options : optional
    A mapping of GDAL configuration options, e.g.,
    `CPL_DEBUG=True, CHECK_WITH_INVERT_PROJ=False`.

Returns
-------
Env

Notes
-----
We raise EnvError if the GDAL config options
AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY are given. AWS
credentials are handled exclusively by boto3.

Examples
--------
>>> with Env(CPL_DEBUG=True, CPL_CURL_VERBOSE=True):
...     with fiona.open("zip+https://example.com/a.zip") as col:
...         print(col.profile)

For access to secured cloud resources, a Fiona Session or a
foreign session object may be passed to the constructor.

>>> import boto3
>>> from fiona.session import AWSSession
>>> boto3_session = boto3.Session(...)
>>> with Env(AWSSession(boto3_session)):
...     with fiona.open("zip+s3://example/a.zip") as col:
...         print(col.profile

aws_access_key_idNzaPassing abstract session keyword arguments is deprecated. Pass a Fiona AWSSession object instead.aws_secret_access_keyaws_session_tokenregion_nameAWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYzdGDAL's AWS config options can not be directly set. AWS credentials are handled exclusively by boto3.zNPassing a boto3 session is deprecated. Pass a Fiona AWSSession object instead.session)r3   r4   r5   r6   profile_nameaws_unsigned)popwarningswarnr   
isdisjointr   
isinstancer   aws_or_dummyr:   issubsetosenvironkeysfrom_environr   copyoptionscontext_options)
r   r:   r<   r;   session_classrI   r3   r4   r5   r6   s
             r   r   Env.__init__t   sJ   j $KK(;TBMM:' !(,CT J#KK(;TBkk-6#%<=HHQQD 
  gw//d+ "..w?"L,,"//"3&;"3'))DL "#:;DDRZZ__EVWW"//1DL (>DL||~!r    c                 d    [         R                  5       nUR                  " S0 UD6  [        U0 UD6$ )a  Create an environment with default config options

Parameters
----------
args : optional
    Positional arguments for Env()
kwargs : optional
    Keyword arguments for Env()

Returns
-------
Env

Notes
-----
The items in kwargs will be overlaid on the default values.

r&   )r(   r0   update)r/   argskwargsrI   s       r   from_defaultsEnv.from_defaults   s1    ( %%'  D$G$$r    c                     U R                   R                  5       nU R                  R                  " S0 UD6  [	        S0 UD6  g)zGet credentials and configure GDAL

Note well: this method is a no-op if the GDAL environment
already has credentials, unless session is not None.

Returns
-------
None

Nr&   )r:   get_credential_optionsrI   rN   setenv)r   	cred_optss     r   credentializeEnv.credentialize   s6     LL779	(i(r    c                 >    [         R                  R                  5       $ )z'Return a mapping of registered drivers.)localr   driversr   s    r   r[   Env.drivers  s    zz!!##r    c                 >    [         R                  R                  5       $ )zTWrites descriptions of open datasets to stderr

For debugging and testing purposes.
)rZ   r   _dump_open_datasetsr   s    r   r^   Env._dump_open_datasets  s    
 zz--//r    c                    [         R                  c  SU l        0 [         l        U R                  R                  5        Vs1 s H  oS:w  d  M
  UiM     nnU H%  n[        USS9nUc  M  U[         R                  U'   M'     [        S0 U R                  D6  0 U l        O+SU l        [        5       U l        [        S0 U R                  D6  U R                  5         U $ s  snf )NFRASTERIO_ENV	normalizeTr&   )rZ   r   _has_parent_envr   rI   rF   r
   defenvrJ   getenvrU   rW   )r   k	probe_envkeyvals        r   	__enter__Env.__enter__  s    ::#(D  )+E%$(LL$5$5$7O$7q;N$7IO %cU;?58E--c2 !
 "T\\"#%D #'D #)8D "T\\" Ps    	CCc                 <   [        5         U R                  (       a   [        5         [        S0 U R                  D6  g [
        R                  (       aA  [
        R                  R                  5       u  pE[        XESS9  [
        R                  (       a  MA  S [
        l        g )NFrb   r&   )	delenvrd   re   rU   rJ   rZ   r   popitemr   )r   exc_typeexc_valexc_tbri   rj   s         r   __exit__Env.__exit__&  si    H*T))* ++ 44<<>E: +++ )-E%r    )rd   rJ   rI   r:   )NNN)r!   r"   r#   r$   __doc__classmethodr0   r   rB   r   rQ   rW   r[   r^   rk   rs   r%   r&   r    r   r(   r(   @   sd    @ 
 
( **f"P % %.$00-r    r(   c                      [         R                  (       d3  [        5       [         l        [         R                  R                  " S0 U D6  [         R                  R	                  5         g)z*Create a default environment if necessary.Nr&   )rZ   r   r   update_config_optionsstartrI   s    r   re   re   5  s7    ::Y


((373	JJr    c                      [         R                  (       d  [        S5      e[         R                  R                  R	                  5       $ )z!Get a mapping of current options.No GDAL environment exists)rZ   r   r   rI   rH   r&   r    r   rf   rf   >  s.    ::344zz!!&&((r    c                  4    [        [        R                  5      $ r   )boolrZ   r   r&   r    r   hasenvr   F  s    

r    c                      [         R                  (       d  [        S5      e[         R                  R                  " S0 U D6  g)z(Set options in the existing environment.r|   Nr&   )rZ   r   r   rx   rz   s    r   rU   rU   J  s*    ::344

((373r    c                      [         R                  " S[        5        [        R                  S L=(       a    [        S S 5       5      $ )Nz)Please use Env.session.hascreds() insteadc              3   d   #    U  H&  nU[         R                  R                  5       ;   v   M(     g 7fr   )rZ   r   get_config_options).0ri   s     r   	<genexpr>hascreds.<locals>.<genexpr>T  s)      *AC 	uzz,,..As   .0)r7   r8   )r>   r?   r   rZ   r   allr&   r    r   hascredsr   R  s<    MM=?VW::T! c *A* ' r    c                      [         R                  (       d  [        S5      e[         R                  R                  5         [         R                  R	                  5         S[         l        g)z+Delete options in the existing environment.r|   N)rZ   r   r   clear_config_optionsstopr&   r    r   rn   rn   Z  s:    ::344

'')	JJOOEJr    c                   &    \ rS rSrS rS rS rSrg)NullContextManagerie  c                     g r   r&   r   s    r   r   NullContextManager.__init__f      r    c                     U $ r   r&   r   s    r   rk   NullContextManager.__enter__i  s    r    c                     g r   r&   )r   rO   s     r   rs   NullContextManager.__exit__l  r   r    r&   N)r!   r"   r#   r$   r   rk   rs   r%   r&   r    r   r   r   e  s    r    r   c                  h    [         R                  (       a
  [        5       $ [        R	                  5       $ )zZReturn an Env if one does not exist

Returns
-------
Env or a do-nothing context manager

)rZ   r   r   r(   rQ   r&   r    r   env_ctx_if_neededr   p  s#     zz!##  ""r    c                 0   ^  [        T 5      U 4S j5       nU$ )a4  A decorator that ensures an env exists before a function
calls any GDAL C functions.

Parameters
----------
f : function
    A function.

Returns
-------
A function wrapper.

Notes
-----
If there is already an existing environment, the wrapper does
nothing and immediately calls f with the given arguments.

c                     > [         R                  (       a  T" U 0 UD6$ [        R                  5          T" U 0 UD6sS S S 5        $ ! , (       d  f       g = fr   )rZ   r   r(   rQ   )rO   rP   fs     r   wrapperensure_env.<locals>.wrapper  s?    ::d%f%%""$$)&) %$$s   A
Ar   r   r   s   ` r   
ensure_envr   ~  s"    ( 1X* * Nr    c                 0   ^  [        T 5      U 4S j5       nU$ )a  Ensures a config environment exists and has credentials.

Parameters
----------
f : function
    A function.

Returns
-------
A function wrapper.

Notes
-----
The function wrapper checks the first argument of f and
credentializes the environment if the first argument is a URI with
scheme "s3".

If there is already an existing environment, the wrapper does
nothing and immediately calls f with the given arguments.

c                    > [         R                  (       a  [        nO[        R                  nUR	                  SS 5      =(       d    U S   n[        U[        5      (       aW  [        R                  " U5      n[         R                  (       a$  UR                  [        5       5      (       a  [        nU" 5       nO
[        5       nU" US9   T" U 0 UD6sS S S 5        $ ! , (       d  f       g = f)Nfpr   r9   )rZ   r   r(   rQ   getrA   strr   cls_from_pathr   rf   r   )rO   kwdsenv_ctorfp_argsession_clsr:   r   s         r   r   ,ensure_env_with_credentials.<locals>.wrapper  s    ::H((H$%0afc""!//7Kzzk2268<<*!mG #nGg&d#d# '&&s   C
C(r   r   s   ` r   ensure_env_with_credentialsr     s"    . 1X$ $, Nr    T)slotsc                       \ rS rSrSr\R                  " S\R                  R                  \	5      S9r
\R                  " S\R                  R                  \	5      S9rS rS rS rS r\S	 5       r\S
 5       rS rSrg)GDALVersioni  zConvenience class for obtaining GDAL major and minor version
components and comparing between versions.  This is highly
simplistic and assumes a very normal numbering scheme for versions
and ignores everything except the major and minor components.

r   )default	validatorc                 t    U R                   U R                  4[        UR                   UR                  5      :H  $ r   majorminortupler   others     r   __eq__GDALVersion.__eq__  s)    

DJJ'5ekk+JJJr    c                 t    U R                   U R                  4[        UR                   UR                  5      :  $ r   r   r   s     r   __lt__GDALVersion.__lt__  s)    

DJJ'%U[[*IIIr    c                 <    SU R                    SU R                   S3$ )NzGDALVersion(major=z, minor=)r   r   r   s    r   __repr__GDALVersion.__repr__  s    #DJJ<x

|1EEr    c                 8    U R                    SU R                   3$ )N.r   r   s    r   __str__GDALVersion.__str__  s    **Qtzzl++r    c                 N   [        X5      (       a  U$ [        U[        5      (       a  U " U6 $ [        U[        5      (       aZ  [        R                  " SU5      nU(       d  [        SU 35      eS UR                  5       R                  S5       5       u  p4U " X4S9$ [        S5      e)z
Parses input tuple or string to GDALVersion. If input is a GDALVersion
instance, it is returned.

Parameters
----------
input: tuple of (major, minor), string, or instance of GDALVersion

Returns
-------
GDALVersion instance

z	^\d+\.\d+z9value does not appear to be a valid GDAL version number: c              3   8   #    U  H  n[        U5      v   M     g 7fr   )int)r   cs     r   r   $GDALVersion.parse.<locals>.<genexpr>  s     E,DqCFF,Ds   r   r   z5GDALVersion can only be parsed from a string or tuple)	rA   r   r   research
ValueErrorgroupsplit	TypeError)r/   inputmatchr   r   s        r   parseGDALVersion.parse  s     e!!LeU##;s## IIlE2E $g'  FEKKM,?,?,DELEU00OPPr    c                 4    U R                  [        5       5      $ )z*Return GDALVersion of current GDAL runtime)r   r   r.   s    r   runtimeGDALVersion.runtime  s     yy.011r    c                 @    U R                   R                  U5      nX:  $ r   )	__class__r   r   s     r   at_leastGDALVersion.at_least  s    $$U+}r    r&   N)r!   r"   r#   r$   ru   attrib
validatorsinstance_ofr   r   r   r   r   r   r   rv   r   r   r   r%   r&   r    r   r   r     s     GGA)D)DS)IJEGGA)D)DS)IJEKJF, Q Q@ 2 2r    r   c                 &  ^ ^^^^^^ Tb9  Tc  [        S5      e[        T[        [        [        45      (       d  [        S5      e[
        R                  T 5      m [
        R                  5       mTT :  a  SOSmT(       a  ST 3OTmUUUUUUU 4S jnU$ )a  A decorator that ensures the called function or parameters are supported
by the runtime version of GDAL.  Raises GDALVersionError if conditions
are not met.

Examples:

    @require_gdal_version('2.2')
    def some_func():

calling `some_func` with a runtime version of GDAL that is < 2.2 raises a
GDALVersionError.


    @require_gdal_version('2.2', param='foo')
    def some_func(foo='bar'):

calling `some_func` with parameter `foo` of any value on GDAL < 2.2 raises
a GDALVersionError.


    @require_gdal_version('2.2', param='foo', values=('bar',))
    def some_func(foo=None):

calling `some_func` with parameter `foo` and value `bar` on GDAL < 2.2
raises a GDALVersionError.


Parameters
------------
version: tuple, string, or GDALVersion
param: string (optional, default: None)
    If `values` are absent, then all use of this parameter with a value
    other than default value requires at least GDAL `version`.
values: tuple, list, or set (optional, default: None)
    contains values that require at least GDAL `version`.  `param`
    is required for `values`.
is_max_version: bool (optional, default: False)
    if `True` indicates that the version provided is the maximum version
    allowed, instead of requiring at least that version.
reason: string (optional: default: '')
    custom error message presented to user in addition to message about
    GDAL version.  Use this to provide an explanation of what changed
    if necessary context to the user.

Returns
---------
wrapped function

z8require_gdal_version: param must be provided with valuesz:require_gdal_version: values must be a tuple, list, or setz>=z<=
c           	      @   >^  [        T 5      U UUUUUUU4S j5       nU$ )Nc                    > T
T:  a  T(       a  T(       Ga)  T
T:  Ga"  Tc  [        ST ST T	 35      e[        T5      nUR                  5       nUR                  (       a:  UR	                  [        [        UR                  S [        U 5       U 5      5      5        UR                  (       a<  [        [        [        UR                  5      [        UR                  5      5      5      nO0 nTU;   aQ  Tc)  TU;  d  UT   UT   :w  a  [        ST ST ST T	 35      eO%UT   T;   a  [        ST SUT    ST ST T	 3	5      eT" U 0 UD6$ )NzGDAL version must be  zusage of parameter "z" requires GDAL zparameter "=)
r   r   rH   rO   rN   dictziplendefaultsreversed)rO   r   argspec	full_kwdsr   r   
inequalityis_max_versionparamreasonr   valuesversions        r   r   8require_gdal_version.<locals>.decorator.<locals>.wrapperU  st   '!.7W#4 =*/
|1WIfXN 
 )+ IIK	<<$$T#gll;SY.G*N%OP###HW\\2HW=M=M4NO H  "HI%~ 0%e,?"2"6ug >((2|1WIfX!G#  @ #5)V3.)%)E2B1C D$$.<q	&C 
 d#d##r    r   )	r   r   r   r   r   r   r   r   r   s	   ` r   	decorator'require_gdal_version.<locals>.decoratorT  s&    	q(	$ (	$ 
(	$T r    )r   rA   r   listsetr   r   r   )r   r   r   r   r   r   r   r   s   ````` @@r   require_gdal_versionr     s    h =WXX&5$"455L  (G!!#G 7*J$r&]&F, ,\ r    	GDAL_DATAz$GDAL data found in package: path=%r.z
header.dxfz0GDAL data files are available at built-in paths.z,GDAL data found in other locations: path=%r.	PROJ_DATAPROJ_LIBz$PROJ data found in package: path=%r.z0PROJ data files are available at built-in paths.z,PROJ data found in other locations: path=%r.)NNF )7ru   	functoolsr   r   inspectr   loggingrD   r   	threadingr>   r   
fiona._envr   r   r   r	   r
   r   r   r   r   fiona.errorsr   r   r   fiona.sessionr   r   rZ   r   	getLoggerr!   logr(   re   rf   r   rU   r   rn   r   r   r   r   sr   r   rE   search_wheelpathdebug	find_filer   has_datar&   r    r   <module>r     s@   " + "  	 	   
 
 
 M L /(	 (> 	!r- r-j)4 #>.b d? ?  ?F DFpj bjj ((*D		8$?T* 
		#	#L	1	1		DE &&(K.IIDdK"**::k"Dd#2::::j!Dd#""$$((*DII4d;d#   II@A ""$D		@$G!$' r    