o
    "4gV                     @  s   d Z ddlmZ ddlmZmZ ddl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dZG dd dejeZG dd dejeZG dd deZG dd deZdS )z)
Entry point into the adaptation system.
    )annotations)ABCabstractmethod)AnyTYPE_CHECKING   )pqabc)PyFormat)Transformer)AdaptersMap)BaseConnection\c                   @  st   e Zd ZU dZdZded< 	 ejjZ	ded< 	 d d!ddZ
d"ddZed#ddZd$ddZd%ddZd&ddZdS )'DumperzP
    Convert Python object of the type `!cls` to PostgreSQL representation.
    r   intoid	pq.FormatformatNclstypecontextabc.AdaptContext | Nonec                 C  $   || _ |  |r|j| _d S d | _d S N)r   
connectionselfr   r    r   V/var/www/html/authentication-server/venv/lib/python3.10/site-packages/psycopg/adapt.py__init__&      zDumper.__init__returnstrc              	   C  s2   dt | j dt | j d| j dt| dd	S )N<.z (oid=z) at 0xx>)r   
__module____qualname__r   id)r   r   r   r   __repr__+   s   zDumper.__repr__objr   Buffer | Nonec                 C  s   d S r   r   )r   r+   r   r   r   dump1   s   zDumper.dumpBufferc                 C  s   |  |}|du rdS | jrt| jj}||S t }||}t|vr-d| d S d| d }|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.
        Ns   NULL   's    E'   \s   \\)	r-   r   r   Escapingpgconnescape_literalescape_stringORD_BSreplace)r   r+   valueescoutrvr   r   r   quote4   s   


zDumper.quoter
   abc.DumperKeyc                 C  s   | 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   r   r   r   get_keya   s   zDumper.get_keyc                 C  s   | 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=   r   r   r   upgraden   s   zDumper.upgrader   r   r   r   r   )r!   r"   )r+   r   r!   r,   )r+   r   r!   r.   )r+   r   r   r
   r!   r<   )r+   r   r   r
   r!   r   )__name__r'   r(   __doc__r   __annotations__r   FormatTEXTr   r   r*   r   r-   r;   r>   r?   r   r   r   r   r      s   
 


-r   c                   @  s>   e Zd ZU dZejjZded< 	 ddd	d
Z	e
dddZdS )LoaderzK
    Convert PostgreSQL values with type OID `!oid` to Python objects.
    r   r   Nr   r   r   r   c                 C  r   r   )r   r   r   r   r   r   r   r   r      r    zLoader.__init__datar.   r!   r   c                 C  s   dS )z.Convert a PostgreSQL value to a Python object.Nr   )r   rH   r   r   r   load   s   zLoader.loadr   r   r   r   r   )rH   r.   r!   r   )rA   r'   r(   rB   r   rD   rE   r   rC   r   r   rI   r   r   r   r   rF   y   s   
 rF   c                      $   e Zd ZdZd	d
 fddZ  ZS )RecursiveDumperz:Dumper with a transformer to help dumping recursive types.Nr   r   r   r   c                      t  || t|| _d S r   superr   r   from_context_txr   	__class__r   r   r         zRecursiveDumper.__init__r   r@   rA   r'   r(   rB   r   __classcell__r   r   rR   r   rL          rL   c                      rK   )RecursiveLoaderz:Loader with a transformer to help loading recursive types.Nr   r   r   r   c                   rM   r   rN   rG   rR   r   r   r      rT   zRecursiveLoader.__init__r   rJ   rU   r   r   rR   r   rX      rW   rX   N)rB   
__future__r   r	   r   r   typingr   r    r   _enumsr
   _transformerr   _adapters_mapr   _connection_baser   r.   ordr5   r   rF   rL   rX   r   r   r   r   <module>   s     ^