
    9hj                     V    S r SSKJrJrJrJrJr  SqSqS	S jr	S r
S	S jrS	S jrS rg)
z>Implementation of the ipaddres-based network types adaptation
    )new_typenew_array_typeregister_typeregister_adapterQuotedStringNc                    SSK q [        c
  [        5       q[         H  n[        X5        M     [         R                  [         R
                  [         R                  [         R                  4 H  n[        U[        5        M     g)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ts      E/var/www/html/env/lib/python3.13/site-packages/psycopg2/_ipaddress.pyregister_ipaddressr   %   sb       ?a&  %%y'>'>##Y%:%:<O,<    c                      [        SS[        5      n [        SSU 5      n[        SS[        5      n[        SSU5      nXX#/$ )	N)ie  INET)i  zINET[])i  CIDR)i  zCIDR[])r   cast_interfacer   cast_network)inetainetcidracidrs       r   r   r   B   sE    FFN3D7Hd3EFFL1D68T2E%%r   c                 F    U c  g [         R                  [        U 5      5      $ N)r	   ip_interfacestrscurs     r   r   r   L   s    y!!#a&))r   c                 F    U c  g [         R                  [        U 5      5      $ r!   )r	   
ip_networkr#   r$   s     r   r   r   S   s    yA''r   c                 *    [        [        U 5      5      $ r!   )r   r#   )objs    r   r   r   Y   s    C!!r   r!   )__doc__psycopg2.extensionsr   r   r   r   r   r	   r
   r   r   r   r   r    r   r   <module>r.      s=   4M M 	 -:&*("r   