
    j                    `    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	dS )	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dS )Capabilitiesz\
    An object to check if a feature is supported by the libpq available on the client.
    returnNonec                    i | _         d S )N)_cache)selfs    `/DATA/AppData/hermes/projects/honcho/.venv/lib/python3.11/site-packages/psycopg/_capabilities.py__init__zCapabilities.__init__   s    &(    Fcheckboolc                2    |                      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  r   _has_featurer   r   s     r   has_full_protocol_versionz&Capabilities.has_full_protocol_version   s(       /u ! 
 
 	
r   c                2    |                      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UUr   c                2    |                      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QQr   c                2    |                      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NNr   c                2    |                      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                2    |                      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KKr   c                2    |                      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                2    |                      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                2    |                      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   featurestrwant_versionintc                    	 | j         |         }n0# t          $ r# |                     ||          }|| j         |<   Y nw xY w|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   KeyError_get_unsupported_messager   )r   r.   r0   r   msgs        r   r   zCapabilities._has_feature\   s    	'+g&CC 	' 	' 	'//FFC#&DK   	'  	4 	#C(((5s    *==c           
        t          j                    |k     rVd| d|                                  dt          j        t          j                               dt          j        |           d	S t           j        |k     rGd| dt           j         dt          j        t           j                   dt          j        |           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.   r0   s      r   r4   z%Capabilities._get_unsupported_messager   s     :<<,&&  <@<N<N<P<P (66  ,.+<\+J+J   !L00? ? ?,.K? ?')'89M'N'N? ? %l33	? ? ? 2r   c                L    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   r8   s     r   r9   zCapabilities._libpq_source   s0    ;(""#/<9GC'CCC%%r   N)r
   r   )F)r   r   r
   r   )r.   r/   r0   r1   r   r   r
   r   )r.   r/   r0   r1   r
   r/   )r
   r/   )__name__
__module____qualname____doc__r   r   r   r   r"   r$   r&   r)   r+   r-   r   r4   r9    r   r   r	   r	      sr        ) ) ) )

 

 

 

 

V V V V VR R R R RO O O O OR R R R RL L L L LR R R R R
 
 
 
 
V V V V V   ,   4& & & & & &r   r	   N)
rD   
__future__r   r7   r   r   errorsr   r	   capabilitiesrE   r   r   <module>rI      s     # " " " " "         % % % % % %E& E& E& E& E& E& E& E&R |~~r   