
    !\iX                        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  SSK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,S r-\R\                  " SS9\ " S S5      5       5       r/  S(S jr0S\Rb                  ;  a  \" 5       Re                  5       r3\3(       a  \!Ri                  S\35        \" S\35        Od\" 5       Rk                  S 5      (       a  \!Ri                  S!5        O7\" 5       Rm                  5       r3\3(       a  \" S\35        \!Ri                  S"\35        S#\Rb                  ;   a  \Rb                  S#   r3\" \35        gS$\Rb                  ;   a  \Rb                  S$   r3\" \35        g\" 5       Re                  5       (       a0  \" 5       Re                  5       r3\!Ri                  S%\35        \" \35        g\" 5       Ro                  5       (       a  \!Ri                  S&5        g\" 5       Rm                  5       r3\3(       a  \!Ri                  S'\35        \" \35        gg))zRasterio's GDAL/AWS environment    )wrapstotal_ordering)getfullargspecN)GDALEnvget_gdal_configset_gdal_configGDALDataFinderPROJDataFinderset_proj_data_search_path)gdal_version)EnvErrorGDALVersionErrorRasterioDeprecationWarning)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    O/var/www/html/kml_chatgpt/mouzaenv/lib/python3.13/site-packages/rasterio/env.py__init__ThreadEnv.__init__   s    	2 $(     )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 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.

Rasterio'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
-------
.. code-block:: python

    with rasterio.Env(GDAL_CACHEMAX=128000000) as env:
        # All drivers are registered, GDAL's raster block cache
        # size is set to 128 MB.
        # 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.$ )zPDefault configuration options

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

Returns
-------
dict
FT)GTIFF_IMPLICIT_JPEG_OVRRASTERIO_ENVr$   clss    r   default_optionsEnv.default_options`   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U;   d  SU;   a  [	        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        OYS[        R                  ;   a6  S[        R                  ;   a"  [        R                  " 5       U l        S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 rasterio.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 rasterio.open("https://example.com/a.tif") as src:
...         print(src.profile)

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

>>> import boto3
>>> from rasterio.session import AWSSession
>>> boto3_session = boto3.Session(...)
>>> with Env(AWSSession(boto3_session)):
...     with rasterio.open("s3://mybucket/a.tif") as src:
...         print(src.profile)

aws_access_key_idNzdPassing abstract session keyword arguments is deprecated. Pass a Rasterio 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.zQPassing a boto3 session is deprecated. Pass a Rasterio AWSSession object instead.session)r0   r1   r2   r3   profile_nameaws_unsignedT)popwarningswarnr   r   
isinstancer   aws_or_dummyr7   osenvironfrom_environ_session_from_environr   copyoptionscontext_options)
r   r7   r9   r8   session_classrD   r0   r1   r2   r3   s
             r   r   Env.__init__q   sG   b $KK(;TB MM=* !(,CT J#KK(;TBkk-67*'72DE E  gw//1.
 "..w?"L,,"//"3&;"3'))+DL !BJJ.3Jbjj3X"//1DL)-D& (>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&   r-   update)r,   argskwargsrD   s       r   from_defaultsEnv.from_defaults   s1    ( %%'  D$G$$r   c                     U R                   R                  5        VVs0 s H  u  pUR                  S5      (       d  M  X_M!     snn$ s  snnf )NAWS_)rE   items
startswith)r   kvs      r   aws_creds_from_context_options"Env.aws_creds_from_context_options   s<    !%!5!5!;!;!=V!=fAU!=VVVs
   AAc                 *   U R                   R                  5       nU R                  R                  " S0 UD6  [	        S0 UD6  [        U SS5      (       a@  U R                  5       nU(       d  gU R                  R                  " S0 UD6  [	        S0 UD6  g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

rB   FNr$   )r7   get_credential_optionsrD   rI   setenvgetattrrT   )r   	cred_optsparent_context_credss      r   credentializeEnv.credentialize   s     LL779	(i(40%88 $(#F#F#H 'LL7"67*)* 9r   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.
)r_   r   _dump_open_datasetsr   s    r   rc   Env._dump_open_datasets  s    
 zz--//r   c                 >    [         R                  R                  5       $ )zCReturns contents of /vsimem/.

For debugging and testing purposes.
)r_   r   _dump_vsimemr   s    r   rf   Env._dump_vsimem  s    
 zz&&((r   c                 @   [         R                  SU 5        [        R                  c  [         R                  S5        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         [         R                  SU 5        U $ s  snf )	NzEntering env context: %rzStarting outermost envFr*   	normalizeTzEntered env context: %rr$   )logdebugr_   r   _has_parent_envr   rD   keysr   defenvrE   getenvrX   r\   )r   rR   	probe_envkeyvals        r   	__enter__Env.__enter__  s    		,d3::II./#(D  )+E%$(LL$5$5$7O$7q;N$7IO %cU;?58E--c2 !
 "T\\"#%D #'D #)8D "T\\"		+T2! Ps   +	D8Dc                    [         R                  SU 5        [        5         U R                  (       a   [	        5         [        S0 U R                  D6  Ov[         R                  S5        [        R                  (       aA  [        R                  R                  5       u  pE[        XESS9  [        R                  (       a  MA  S [        l        [         R                  SU 5        g )NzExiting env context: %rzExiting outermost envFri   zExited env context: %rr$   )rk   rl   delenvrm   ro   rX   rE   r_   r   popitemr   )r   exc_typeexc_valexc_tbrr   rs   s         r   __exit__Env.__exit__7  s    		+T2H*T))*II-. ++ 44<<>E: +++ )-E%		*D1r   )rm   rB   rE   rD   r7   )NNN)r   r    r!   r"   __doc__classmethodr-   r   r>   r   rL   rT   r\   r`   rc   rf   rt   r|   r#   r$   r   r   r&   r&   =   sm     D 
 
   $%d&33c"J % %.W+0$0)82r   r&   c                     [         R                  (       a%  [        R                  S[         R                  5        Ol[        R                  S5        [	        5       [         l        [         R                  R
                  " S0 U D6  [        R                  S[         R                  5        [         R                  R                  5         g)z*Create a default environment if necessary.zGDAL environment exists: %rNo GDAL environment existszNew GDAL environment %r createdNr$   )r_   r   rk   rl   r   update_config_optionsstartrD   s    r   ro   ro   H  sl    zz		/<		./Y


((373		-uzz	;	JJr   c                      [         R                  (       d  [        S5      e[        R	                  S[         R                  5        [         R                  R
                  R                  5       $ )z!Get a mapping of current options.r   z$Got a copy of environment %r options)r_   r   r   rk   rl   rD   rC   r$   r   r   rp   rp   U  sA    ::344		8%**Ezz!!&&((r   c                  4    [        [        R                  5      $ r   )boolr_   r   r$   r   r   hasenvr   ^  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$   )r_   r   r   r   r   s    r   rX   rX   b  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   b   #    U  H%  o[         R                  R                  5       ;   v   M'     g 7fr   )r_   r   get_config_options).0rr   s     r   	<genexpr>hascreds.<locals>.<genexpr>l  s.       *L  ]KUX1N1N1P*P  ]Ks   -/)r4   r5   )r;   r<   r   r_   r   allr$   r   r   hascredsr   j  sE    MM=?YZ::T!  Lc  *L  ]K  *L  'L  Lr   c                     [         R                  (       d  [        S5      e[         R                  R                  5         [        R                  S[         R                  5        [         R                  R                  5         S[         l        g)z+Delete options in the existing environment.r   zCleared existing %r optionsN)r_   r   r   clear_config_optionsrk   rl   stopr$   r   r   rw   rw   o  sM    ::344

'')		/<	JJOOEJr   c                   &    \ rS rSrS rS rS rSrg)NullContextManageriz  c                     g r   r$   r   s    r   r   NullContextManager.__init__|      r   c                     U $ r   r$   r   s    r   rt   NullContextManager.__enter__  s    r   c                     g r   r$   )r   rJ   s     r   r|   NullContextManager.__exit__  r   r   r$   N)r   r    r!   r"   r   rt   r|   r#   r$   r   r   r   r   z  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

)r_   r   r   r&   rL   r$   r   r   env_ctx_if_neededr     s#     zz!##  ""r   c                 0   ^  [        T 5      U 4S j5       nU$ )zTA decorator that ensures an env exists before a function
calls any GDAL C functions.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   )r_   r   r&   rL   )rJ   kwdsfs     r   wrapperensure_env.<locals>.wrapper  s?    ::d#d##""$$'$' %$$s   A
Ar   r   r   s   ` r   
ensure_envr     s"     1X( ( Nr   c                 N    [         R                  " S[        5        [        U 5      $ )z0DEPRECATED alias for ensure_env_with_credentialsz.Please use ensure_env_with_credentials instead)r;   r<   r   ensure_env_with_credentials)r   s    r   ensure_env_credentialledr     s    MMBD^_&q))r   c                 0   ^  [        T 5      U 4S j5       nU$ )a)  Ensures a config environment exists and is credentialized

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".

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   r6   )r_   r   r&   rL   getr=   strr   cls_from_pathr   rp   r   )rJ   r   env_ctorfp_argsession_clsr7   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   r   r     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                 f   [        X5      (       a  U$ [        U[        5      (       a  U " U6 $ [        U[        5      (       af  [        R                  " SU5      nU(       d  [        SR                  U5      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+z;value 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)
r=   r   r   research
ValueErrorformatgroupsplit	TypeError)r,   inputmatchr   r   s        r   parseGDALVersion.parse  s     e!!LeU##;s## IIlE2E !!'0 0 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((r   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"   r~   attrib
validatorsinstance_ofr   r   r   r   r   r   r   r   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> ) )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$ )a1  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
--------

.. code-block:: python

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

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

.. code-block:: python

    @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.

.. code-block:: python

    @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aG  T
T:  Ga@  Tc%  [        SR                  T[        T5      T	5      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;   a]  Tc0  TU;  d  UT   UT   :w  a  [        SR                  TTTT	5      5      eO*UT   T;   a!  [        SR                  TUT   TTT	5      5      eT" U 0 UD6$ )NzGDAL version must be {} {}{}z-usage of parameter "{}" requires GDAL {} {}{}z'parameter "{}={}" requires GDAL {} {}{})r   r   r   
getargspecrC   rJ   rI   dictziplendefaultsreversed)rJ   r   argspec	full_kwdsr   r   
inequalityis_max_versionparamreasonr   valuesversions        r   r   8require_gdal_version.<locals>.decorator.<locals>.wrapper\  sb   7">#'(9=*6==&Gf>? ?
 %Q- IIK	<<$$T#gll:CI.F*M%NO###C .9I9I0J%L  MH  "HI%~ 0 )% 0HUO C"2!//5v$):w0"#  !D #5)V3.++16 %y'7Wf,  d#d##r   r   )	r   r   r   r   r   r   r   r   r   s	   ` r   	decorator'require_gdal_version.<locals>.decorator[  s&    	q)	$ )	$ 
)	$V r   )r   r=   r   listsetr   r   r   )r   r   r   r   r   r   r   r   s   ````` @@r   require_gdal_versionr    s    p =JL L &5$"455LN N (G!!#G 7*J$r&]&F- -^ r   	GDAL_DATAz$GDAL data found in package: path=%r.zgdalvrt.xsdz0GDAL 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 )8r~   	functoolsr   r   inspectr   r   loggingr?   r   	threadingr;   r   rasterio._envr   r   r   r	   r
   r   rasterio._versionr   rasterio.errorsr   r   r   rasterio.sessionr   r   r_   r   	getLoggerr   rk   r&   ro   rp   r   rX   r   rw   r   r   r   r   r   sr   r  r@   search_wheelpathrl   	find_filer   has_datar$   r   r   <module>r     sF   % + 0  	 	     + R R 2(	 (< 	!H2 H2V
)4L
	 	#
**Z d< <  <~ KP "ut bjj ((*D		8$?T* 
		#	#M	2	2		DE &&(K.IIDdK"**::k"Dd#2::::j!Dd#""$$((*DII4d;d#   II@A ""$D		@$G!$' r   