B *®«]q ã@sfdZddlmZmZmZmZmZddlmZda da ddd„Z dd„Z dd d „Z dd d „Zd d„ZdS)z>Implementation of the ipaddres-based network types adaptation é)Únew_typeÚnew_array_typeÚ register_typeÚregister_adapterÚ QuotedString)Ú text_typeNcCsZddlatdkrtƒaxtD]}t||ƒqWx&tjtjtjtjgD]}t|t ƒqDWdS)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_castersrZ IPv4InterfaceZ IPv6InterfaceZ IPv4NetworkZ IPv6NetworkrÚadapt_ipaddress)Z conn_or_cursÚcÚt©rúF/opt/alt/python37/lib64/python3.7/site-packages/psycopg2/_ipaddress.pyÚregister_ipaddress%s  rcCs<tddtƒ}tdd|ƒ}tddtƒ}tdd|ƒ}||||gS) N)ieZINET)izINET[])iŠZCIDR)i‹zCIDR[])rÚcast_interfacerÚ cast_network)ZinetZainetZcidrZacidrrrrr Bs     r cCs|dkr dSt t|ƒ¡S)N)rZ ip_interfacer)ÚsÚcurrrrrLsrcCs|dkr dSt t|ƒ¡S)N)rZ ip_networkr)rrrrrrSsrcCs tt|ƒƒS)N)rÚstr)Úobjrrrr Ysr )N)N)N)Ú__doc__Zpsycopg2.extensionsrrrrrZpsycopg2.compatrrr rr rrr rrrrÚs