
    *Jf                     v   U d Z ddlmZmZ ddlmZmZmZmZ ddl	m
Z
mZ ddl	mZ ddlmZ ddlmZ erdd	lmZ ej        Zej        Z ed
          Z G d dej        e          Z G d dej        e          Zed         ed<   erej        Znddl	mZ ej        Z G d de          Z G d de          ZdS )z)
Entry point into the adaptation system.
    )ABCabstractmethod)AnyOptionalTypeTYPE_CHECKING   )pqabc)_adapters_map)PyFormat)_psycopg)BaseConnection\c                       e Zd ZU dZdZeed<   	 ej        j	        Z
ej        ed<   	 ddedeej                 fdZd	efd
Zeded	efd            Zded	efdZdeded	ej        fdZdeded	d fdZdS )DumperzP
    Convert Python object of the type `!cls` to PostgreSQL representation.
    r   oidformatNclscontextc                 4    || _         |r|j        nd | _        d S N)r   
connection)selfr   r   s      P/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/psycopg/adapt.py__init__zDumper.__init__#   $    ")3Gt 	    returnc           
          dt          |           j         dt          |           j         d| j         dt	          |           dd	S )N<.z (oid=z) at 0xx>)type
__module____qualname__r   id)r   s    r   __repr__zDumper.__repr__)   s`    4T

% 4 4T

(? 4 4X4 4&(hh34 4 4	
r   objc                     d S r    )r   r*   s     r   dumpzDumper.dump/   s    (+r   c                    |                      |          }| j        r3t          j        | j        j                  }|                    |          S t          j                    }|                    |          }t          |vrd|z   dz   S d|z   dz   }|                    d          dk    r|                    dd          }|S )z
        By default return the `dump()` value quoted and sanitised, so
        that the result can be used to build a SQL string. This works well
        for most types and you won't likely have to implement this method in a
        subclass.
           's    E'   \s   \\)	r-   r   r
   Escapingpgconnescape_literalescape_stringORD_BSreplace)r   r*   valueescoutrvs         r   quotezDumper.quote2   s     		#? 	-+do455C%%e,,, kmm&&  #:$$ SL4'U##u,,E7++B	r   c                     | j         S )a  
        Implementation of the `~psycopg.abc.Dumper.get_key()` member of the
        `~psycopg.abc.Dumper` protocol. Look at its definition for details.

        This implementation returns the `!cls` passed in the constructor.
        Subclasses needing to specialise the PostgreSQL type according to the
        *value* of the object dumped (not only according to to its type)
        should override this class.

        )r   r   r*   r   s      r   get_keyzDumper.get_key]   s     xr   c                     | S )a/  
        Implementation of the `~psycopg.abc.Dumper.upgrade()` member of the
        `~psycopg.abc.Dumper` protocol. Look at its definition for details.

        This implementation just returns `!self`. If a subclass implements
        `get_key()` it should probably override `!upgrade()` too.
        r,   r=   s      r   upgradezDumper.upgradej   s	     r   r   )__name__r&   r'   __doc__r   int__annotations__r
   FormatTEXTr   r%   r   r   AdaptContextr   strr)   r   r   Bufferr-   r;   r   	DumperKeyr>   r@   r,   r   r   r   r      s.          CLLL2	FBI&&&(
 
D 
8C4D+E 
 
 
 

# 
 
 
 
 +++++ ^+) ) ) ) ) )V3  S]    3  X      r   r   c                       e Zd ZU dZej        j        Zej        ed<   	 d
de	de
ej                 fdZededefd	            ZdS )LoaderzK
    Convert PostgreSQL values with type OID `!oid` to Python objects.
    r   Nr   r   c                 4    || _         |r|j        nd | _        d S r   )r   r   )r   r   r   s      r   r   zLoader.__init__}   r   r   datar   c                     dS )z.Convert a PostgreSQL value to a Python object.Nr,   )r   rN   s     r   loadzLoader.load   s	     	r   r   )rA   r&   r'   rB   r
   rE   rF   r   rD   rC   r   r   rG   r   r   rI   r   rP   r,   r   r   rL   rL   u   s           	FBI&&&(
 
C 
(33C*D 
 
 
 
  C    ^  r   rL   zabc.TransformerTransformer)
_transformc                   D     e Zd ZdZddedeej                 f fdZ xZ	S )RecursiveDumperz:Dumper with a transformer to help dumping recursive types.Nr   r   c                     t                                          ||           t                              |          | _        d S r   superr   rQ   from_context_tx)r   r   r   	__class__s      r   r   zRecursiveDumper.__init__   6    g&&&++G44r   r   )
rA   r&   r'   rB   r%   r   r   rG   r   __classcell__rZ   s   @r   rT   rT      s^        DD5 5D 58C4D+E 5 5 5 5 5 5 5 5 5 5r   rT   c                   D     e Zd ZdZddedeej                 f fdZ xZ	S )RecursiveLoaderz:Loader with a transformer to help loading recursive types.Nr   r   c                     t                                          ||           t                              |          | _        d S r   rV   )r   r   r   rZ   s      r   r   zRecursiveLoader.__init__   r[   r   r   )
rA   r&   r'   rB   rC   r   r   rG   r   r\   r]   s   @r   r_   r_      s^        DD5 5C 5(33C*D 5 5 5 5 5 5 5 5 5 5r   r_   N)rB   r   r   r   typingr   r   r   r    r
   r   _enumsr   _cmoduler   r   r   AdaptersMaprI   ordr5   r   rL   rD   rQ   rR   rT   r_   r,   r   r   <module>rg      s     $ # # # # # # # 5 5 5 5 5 5 5 5 5 5 5 5               ( ( ( ( ( (       +******'		TZ Z Z Z ZSZ Z Z Zz    SZ   ( #$ $ $ $  )&KK(K5 5 5 5 5f 5 5 55 5 5 5 5f 5 5 5 5 5r   