o
    RDi                     @  s"  d dl mZ d dlZd dlZd dlZd dlmZmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ dd	lmZ e	eZ	 G d
d dZG dd deZG dd deZG dd deZG dd deZeeef Zd%ddZd&ddZd'd!d"Zd&d#d$Ze \ZZZ e \Z!Z"e \Z#Z$Z%dS )(    )annotationsN)PackageNotFoundErrordistribution)	getLogger)
ModuleType)Union)Requirement   )errorsc                   @  s   e Zd ZdZdZdd ZdS )MissingOptionalDependencyzA class to replace missing dependencies.

    The only thing this class is supposed to do is raise a MissingDependencyError when __getattr__ is called.
    This will be triggered whenever module.member is going to be called.
    znot setc                 C  s   t | j)N)r
   MissingDependencyError	_dep_name)selfitem r   T/var/www/Datamplify/venv/lib/python3.10/site-packages/snowflake/connector/options.py__getattr__#   s   z%MissingOptionalDependency.__getattr__N)__name__
__module____qualname____doc__r   r   r   r   r   r   r      s    r   c                   @     e Zd ZdZdZdS )MissingPandasz9The class is specifically for pandas optional dependency.pandasNr   r   r   r   r   r   r   r   r   r   '       r   c                   @  r   )MissingKeyringz6The class is specifically for sso optional dependency.keyringNr   r   r   r   r   r   -   r   r   c                   @  r   )MissingBotocorez7The class is specifically for boto optional dependency.botocoreNr   r   r   r   r   r   3   r   r   c                   @  r   )MissingBoto3z8The class is specifically for boto3 optional dependency.boto3Nr   r   r   r   r   r    9   r   r    dep_namestrinstalled_verexpected_verr   returnNonec                 C  s   t jd| ||dd d S )NzgYou have an incompatible version of '{}' installed ({}), please install a version that adheres to: '{}'   )
stacklevel)warningswarnformat)r"   r$   r%   r   r   r   warn_incompatible_depB   s
   

r-   /tuple[ModuleLikeObject, ModuleLikeObject, bool]c               
   C  s  z|t d} ddlm} t d}dtjvrdtjd< zAtd}td}|jdg }d	}|D ]}t	|}|j
d	urK|j
d
dirK|jdkrK|} nq/|j}	|j|	s[td|	| W n tyv }
 ztd|
  W Y d	}
~
nd	}
~
ww | |dfW S  ty   t t df Y S w )a
  This function tries importing the following packages: pandas, pyarrow.

    If available it returns pandas and pyarrow packages with a flag of whether they were imported.
    It also warns users if they have an unsupported pyarrow version installed if possible.
    r   r   )	DataFramepyarrowARROW_DEFAULT_MEMORY_POOLsystemzsnowflake-connector-pythonzRequires-DistNextrazSCannot determine if compatible pyarrow is installed because of missing package(s): TF)	importlibimport_moduler   r/   osenvironr   metadataget_allr   markerevaluatenameversion	specifiercontainsr-   r   loggerinfoImportErrorr   )r   r/   r0   pyarrow_distsnowflake_connector_distdependenciespandas_pyarrow_extra
dependencydepinstalled_pyarrow_versioner   r   r    _import_or_missing_pandas_optionL   sL   





rK   tuple[ModuleLikeObject, bool]c                  C  s2   z
t d} | dfW S  ty   t df Y S w )zThis function tries importing the following packages: keyring.

    If available it returns keyring package with a flag of whether it was imported.
    r   TF)r4   r5   rB   r   )r   r   r   r   !_import_or_missing_keyring_option   s   

rM   c                  C  sB   zt d} t d}| |dfW S  ty    t t df Y S w )zIThis function tries importing the following packages: botocore and boto3.r   r!   TF)r4   r5   rB   r   r    )r   r!   r   r   r   _import_or_missing_boto_option   s   

rN   )r"   r#   r$   r#   r%   r   r&   r'   )r&   r.   )r&   rL   )&
__future__r   r4   r6   r*   importlib.metadatar   r   loggingr   typesr   typingr   packaging.requirementsr    r
   r   r@   r   r   r   r   r    ModuleLikeObjectr-   rK   rM   rN   r   r0   installed_pandasr   installed_keyringr   r!   installed_botor   r   r   r   <module>   s2    	



5

