3 ¢báWª ã @sjdZddlZddlZddlZejZy ejZWnek rDdZYnXdd„Zdd„Z dd „Z d d „Z dS) z*Generic Internet address helper functions.éNi'cCs0|tkrtjj|ƒS|tkr(tjj|ƒSt‚dS)a*Convert the textual form of a network address into its binary form. @param family: the address family @type family: int @param text: the textual address @type text: string @raises NotImplementedError: the address family specified is not implemented. @rtype: string N)ÚAF_INETÚdnsÚipv4Ú inet_atonÚAF_INET6Úipv6ÚNotImplementedError)ÚfamilyÚtext©r ú/usr/lib/python3.6/inet.pyÚ inet_pton&s   r cCs0|tkrtjj|ƒS|tkr(tjj|ƒSt‚dS)a/Convert the binary form of a network address into its textual form. @param family: the address family @type family: int @param address: the binary address @type address: string @raises NotImplementedError: the address family specified is not implemented. @rtype: string N)rrrZ inet_ntoarrr)r Zaddressr r r Ú inet_ntop:s   rcCsLytjj|ƒtStk rFytjj|ƒtSt‚YnXYnXdS)záDetermine the address family of a textual-form network address. @param text: the textual address @type text: string @raises ValueError: the address family cannot be determined from the input. @rtype: int N)rrrrÚ ExceptionrrÚ ValueError)r r r r Úaf_for_addressMs  rcCsty$ttjj|ƒdƒ}|dko$|dkStk rnyttjj|ƒdƒ}|dkStk rht‚YnXYnXdS)zÄIs the textual-form network address a multicast address? @param text: the textual address @raises ValueError: the address family cannot be determined from the input. @rtype: bool réàéïéÿN)Úordrrrrrr)r Úfirstr r r Ú is_multicast`sr) Ú__doc__ZsocketZdns.ipv4rZdns.ipv6rrÚAttributeErrorr rrrr r r r Ús