
    iD                    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                  v    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
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    u/var/www/html/hwPaymentPortal-be-dev/hw-payment-portal-api/venv/lib/python3.12/site-packages/psycopg/_capabilities.py__init__zCapabilities.__init__   s	    &(    c                *    | j                  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 check_has_feature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 and 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 and greater.
        zConnection.pipeline()" r   r   r   s     r   has_pipelinezCapabilities.has_pipeline#   s    
   !8& NNr   c                *    | j                  dd|      S )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   s     r   has_set_trace_flagsz Capabilities.has_set_trace_flags*   r   r   c                *    | j                  dd|      S )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   s     r   has_cancel_safezCapabilities.has_cancel_safe1   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 and greater.
        z4Cursor.stream() with 'size' parameter greater than 1r!   r   r   r   s     r   has_stream_chunkedzCapabilities.has_stream_chunked8   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 and greater.
        zPGconn.send_close_prepared()r!   r   r   r   s     r   has_send_close_preparedz$Capabilities.has_send_close_preparedB   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_featureI   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_message_   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   r2   r   __version__)r   r.   s     r   r/   zCapabilities._libpq_sourcey   s.    ;;("#//<9G9'CC%r   N)returnNone)F)r   boolr7   r9   )r)   strr*   intr   r9   r7   r9   )r)   r:   r*   r;   r7   r:   )r7   r:   )__name__
__module____qualname____doc__r   r   r   r   r   r"   r$   r&   r   r(   r/    r   r   r	   r	      sD    )VRORR
V,4&r   r	   N)
r?   
__future__r   r-   r   r   errorsr   r	   capabilitiesr@   r   r   <module>rD      s+    #  %r& r&l ~r   