
    2i                    R    d Z ddlmZ ddlmZmZ ddlmZ  G d d      Z e       Z	y)	z
psycopg capabilities objects
    )annotations   )_cmodulepq)NotSupportedErrorc                      e Zd ZdZddZdddZdddZdddZdddZdddZ	dddZ
ddd	Zddd
ZdddZddZddZddZy)Capabilitiesz\
    An object to check if a feature is supported by the libpq available on the client.
    c                    i | _         y )N)_cache)selfs    T/var/www/html/secretsanta/venv/lib/python3.12/site-packages/psycopg/_capabilities.py__init__zCapabilities.__init__   s	    &(    c                *    | j                  dd|      S )zCheck if the `PGconn.full_protocol_version()` method is implemented.

        If the method is implemented, then `ConnectionInfo.full_protocol_version`
        will return a meaningful value.

        The feature requires libpq 18.0 and greater.
        z!pq.PGconn.full_protocol_version()i  check_has_featurer   r   s     r   has_full_protocol_versionz&Capabilities.has_full_protocol_version   s#       /u ! 
 	
r   c                *    | j                  dd|      S )z}Check if the `PGconn.encrypt_password()` method is implemented.

        The feature requires libpq 10.0 or greater.
        zpq.PGconn.encrypt_password()i r   r   r   s     r   has_encrypt_passwordz!Capabilities.has_encrypt_password!       
   !?u UUr   c                *    | j                  dd|      S )z~Check if the `ConnectionInfo.hostaddr` attribute is implemented.

        The feature requires libpq 12.0 or greater.
        zConnection.info.hostaddri r   r   r   s     r   has_hostaddrzCapabilities.has_hostaddr(       
   !;V5 QQr   c                *    | j                  dd|      S )z}Check if the :ref:`pipeline mode <pipeline-mode>` is supported.

        The feature requires libpq 14.0 or greater.
        zConnection.pipeline()" r   r   r   s     r   has_pipelinezCapabilities.has_pipeline/   s    
   !8& NNr   c                *    | j                  dd|      S )zCheck if the `pq.PGconn.set_trace_flags()` method is implemented.

        The feature requires libpq 14.0 or greater.
        zPGconn.set_trace_flags()r   r   r   r   s     r   has_set_trace_flagsz Capabilities.has_set_trace_flags6   r   r   c                *    | j                  dd|      S )z|Check if the `pq.PGconn.used_gssapi` attribute is implemented.

        The feature requires libpq 16.0 or greater.
        zPGconn.used_gssapii q r   r   r   s     r   has_used_gssapizCapabilities.has_used_gssapi=   s    
   !5vU KKr   c                *    | j                  dd|      S )z|Check if the `Connection.cancel_safe()` method is implemented.

        The feature requires libpq 17.0 or greater.
        zConnection.cancel_safe() r   r   r   s     r   has_cancel_safezCapabilities.has_cancel_safeD   r   r   c                *    | j                  dd|      S )zCheck if `Cursor.stream()` can handle a `size` parameter value
        greater than 1 to retrieve results by chunks.

        The feature requires libpq 17.0 or greater.
        z4Cursor.stream() with 'size' parameter greater than 1r%   r   r   r   s     r   has_stream_chunkedzCapabilities.has_stream_chunkedK   s$       BFRW ! 
 	
r   c                *    | j                  dd|      S )zCheck if the `pq.PGconn.send_closed_prepared()` method is implemented.

        The feature requires libpq 17.0 or greater.
        zPGconn.send_close_prepared()r%   r   r   r   s     r   has_send_close_preparedz$Capabilities.has_send_close_preparedU   r   r   c                    || j                   v r| j                   |   }n!| j                  ||      }|| j                   |<   |sy|rt        |      y)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   featurewant_versionr   msgs        r   r   zCapabilities._has_feature\   sU     dkk!++g&C//FC#&DKK #C((r   c           
        t        j                         |k  rUd| d| j                          dt        j                  t        j                                dt        j                  |       d	S t         j                  |k  rQd| dt         j
                   dt        j                  t         j                         dt        j                  |       d	S y)	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.   s      r   r,   z%Capabilities._get_unsupported_messager   s     ::<,&y )<<@<N<N<P;Q R((67 8++-+<+<\+J*K	 !!L0y ),,.KK= 9'')'8'89M9M'N&O P%%l34I	? r   c                \    t         j                  dk(  rt        j                  xs d}d| S y)z5Return a string reporting where the libpq comes from.binaryunknownz$the psycopg[binary] package version zsystem libraries)r   r6   r   __version__)r   r2   s     r   r3   zCapabilities._libpq_source   s.    ;;("#//<9G9'CC%r   N)returnNone)F)r   boolr;   r=   )r-   strr.   intr   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,   r3    r   r   r	   r	      sO    )

VRORLR
V,4&r   r	   N)
rC   
__future__r   r1   r   r   errorsr   r	   capabilitiesrD   r   r   <module>rH      s+    #  %E& E&R ~r   