o
    "4gQ                     @  sL   d Z ddlmZ ddlmZ ddlmZ ddlmZ G dd dZe Z	d	S )
z
psycopg capabilities objects
    )annotations   )pq)_cmodule)NotSupportedErrorc                   @  s   e Zd ZdZd"ddZd#d$d	d
Zd#d$ddZd#d$ddZd#d$ddZd#d$ddZ	d#d$ddZ
d#d$ddZd%ddZd&ddZd'dd Zd!S )(Capabilitiesz\
    An object to check if a feature is supported by the libpq available on the client.
    returnNonec                 C  s
   i | _ d S )N)_cache)self r   ^/var/www/html/authentication-server/venv/lib/python3.10/site-packages/psycopg/_capabilities.py__init__   s   
zCapabilities.__init__Fcheckboolc                 C     | j dd|dS )z~Check if the `PGconn.encrypt_password()` method is implemented.

        The feature requires libpq 10.0 and greater.
        zpq.PGconn.encrypt_password()i r   _has_featurer   r   r   r   r   has_encrypt_password      z!Capabilities.has_encrypt_passwordc                 C  r   )zCheck if the `ConnectionInfo.hostaddr` attribute is implemented.

        The feature requires libpq 12.0 and greater.
        zConnection.info.hostaddri r   r   r   r   r   r   has_hostaddr   r   zCapabilities.has_hostaddrc                 C  r   )z~Check if the :ref:`pipeline mode <pipeline-mode>` is supported.

        The feature requires libpq 14.0 and greater.
        zConnection.pipeline()" r   r   r   r   r   r   has_pipeline$   r   zCapabilities.has_pipelinec                 C  r   )zCheck if the `pq.PGconn.set_trace_flags()` method is implemented.

        The feature requires libpq 14.0 and greater.
        zPGconn.set_trace_flags()r   r   r   r   r   r   r   has_set_trace_flags+   r   z Capabilities.has_set_trace_flagsc                 C  r   )z}Check if the `Connection.cancel_safe()` method is implemented.

        The feature requires libpq 17.0 and greater.
        zConnection.cancel_safe() r   r   r   r   r   r   has_cancel_safe2   r   zCapabilities.has_cancel_safec                 C  r   )zCheck if `Cursor.stream()` can handle a `size` parameter value
        greater than 1 to retrieve results by chunks.

        The feature requires libpq 17.0 and greater.
        z4Cursor.stream() with 'size' parameter greater than 1r   r   r   r   r   r   r   has_stream_chunked9   s   zCapabilities.has_stream_chunkedc                 C  r   )zCheck if the `pq.PGconn.send_closed_prepared()` method is implemented.

        The feature requires libpq 17.0 and greater.
        zPGconn.send_close_prepared()r   r   r   r   r   r   r   has_send_close_preparedC   r   z$Capabilities.has_send_close_preparedfeaturestrwant_versionintc                 C  sD   || j v r| j | }n| ||}|| j |< |sdS |r t|dS )z
        Check is a version is supported.

        If `check` is true, raise an exception with an explicative message
        explaining why the feature is not supported.

        The expletive messages, are left to the user.
        TF)r
   _get_unsupported_messager   )r   r    r"   r   msgr   r   r   r   J   s   
	
zCapabilities._has_featurec              
   C  sz   t  |k rd| d|   dt t   dt | d	S t j|k r;d| dt j dt t j dt | d	S dS )	z
        Return a descriptinve message to describe why a feature is unsupported.

        Return an empty string if the feature is supported.
        zthe feature 'z<' is not available: the client libpq version (imported from z) is z%; the feature requires libpq version z	 or newerz,' is not available: you are using a psycopg[z)] libpq wrapper built with libpq version  )r   version_libpq_sourceversion_pretty__build_version____impl__)r   r    r"   r   r   r   r$   `   s&   

z%Capabilities._get_unsupported_messagec                 C  s"   t jdkrtjp	d}d| S dS )z5Return a string reporting where the libpq comes from.binaryunknownz$the psycopg[binary] package version zsystem libraries)r   r+   r   __version__)r   r'   r   r   r   r(   z   s   


zCapabilities._libpq_sourceN)r   r	   )F)r   r   r   r   )r    r!   r"   r#   r   r   r   r   )r    r!   r"   r#   r   r!   )r   r!   )__name__
__module____qualname____doc__r   r   r   r   r   r   r   r   r   r$   r(   r   r   r   r   r      s    



r   N)
r2   
__future__r   r&   r   r   errorsr   r   capabilitiesr   r   r   r   <module>   s    
v