o aj @sZdZddlmZmZmZmZmZdadadddZ ddZ ddd Z dd d Z d d Z dS)z>Implementation of the ipaddres-based network types adaptation )new_typenew_array_type register_typeregister_adapter QuotedStringNcCsRddlatdur tatD]}t||q tjtjtjtjfD]}t|t qdS)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 rN) ipaddress_casters _make_castersr IPv4Interface IPv6Interface IPv4Network IPv6Networkradapt_ipaddress) conn_or_cursctr5/usr/lib/python3/dist-packages/psycopg2/_ipaddress.pyregister_ipaddress%s  rcCs<tddt}tdd|}tddt}tdd|}||||gS) N)ieINET)izINET[])iCIDR)izCIDR[])rcast_interfacer cast_network)inetainetcidracidrrrrr Bs     r cC|durdStt|SN)r ip_interfacestrscurrrrrLsrcCrr)r ip_networkr r!rrrrSsrcCs tt|Sr)rr )objrrrrYs rr)__doc__psycopg2.extensionsrrrrrrrrr rrrrrrrs