o
    -gj                     @   sZ   d Z ddlmZmZmZmZmZ dadadddZ	dd Z
ddd	Zdd
dZdd ZdS )z>Implementation of the ipaddres-based network types adaptation
    )new_typenew_array_typeregister_typeregister_adapterQuotedStringNc                 C   sR   ddl a tdu rt atD ]}t||  qt jt jt jt jfD ]}t|t	 qdS )a  
    Register conversion support between `ipaddress` objects and `network types`__.

    :param conn_or_curs: the scope where to register the type casters.
        If `!None` register them globally.

    After the function is called, PostgreSQL :sql:`inet` values will be
    converted into `~ipaddress.IPv4Interface` or `~ipaddress.IPv6Interface`
    objects, :sql:`cidr` values into into `~ipaddress.IPv4Network` or
    `~ipaddress.IPv6Network`.

    .. __: https://www.postgresql.org/docs/current/static/datatype-net-types.html
    r   N)
	ipaddress_casters_make_castersr   IPv4InterfaceIPv6InterfaceIPv4NetworkIPv6Networkr   adapt_ipaddress)conn_or_cursct r   T/var/www/html/django-vendor/venv/lib/python3.10/site-packages/psycopg2/_ipaddress.pyregister_ipaddress%   s   r   c                  C   s<   t ddt} tdd| }t ddt}tdd|}| |||gS )	N)ie  INET)i  zINET[])i  CIDR)i  zCIDR[])r   cast_interfacer   cast_network)inetainetcidracidrr   r   r   r	   B   s
   r	   c                 C      | d u rd S t t| S N)r   ip_interfacestrscurr   r   r   r   L   s   r   c                 C   r   r   )r   
ip_networkr    r!   r   r   r   r   S   s   r   c                 C   s   t t| S r   )r   r    )objr   r   r   r   Y   s   r   r   )__doc__psycopg2.extensionsr   r   r   r   r   r   r   r   r	   r   r   r   r   r   r   r   <module>   s    



