U mf @sddZddlZddlmZddlZeedddZeeefeddd Z eeefedd d Z dS) zIPv4 helper functions.N)Union)addressreturncCs4t|dkrtjjd|d|d|d|dfS)zConvert an IPv4 address in binary form to text form. *address*, a ``bytes``, the IPv4 address in binary form. Returns a ``str``. z %u.%u.%u.%ur)lendns exception SyntaxError)rr 6/opt/hc_python/lib/python3.8/site-packages/dns/ipv4.py inet_ntoas r)textrcCst|ts|}n|}|d}t|dkr6tjj|D]8}|sNtjjt|dkr:|dt dkr:tjjq:zdd|D}t j d |WSt k rtjjYnXd S) zConvert an IPv4 address in text form to binary form. *text*, a ``str`` or ``bytes``, the IPv4 address in textual form. Returns a ``bytes``. .rrr0cSsg|] }t|qSr )int).0partr r r =szinet_aton..BBBBN)r) isinstancebytesencodesplitr r r r isdigitordstructpack Exception)rZbtextpartsrbr r r inet_aton's      r#cCstjtj|S)zVerify that *address* is a valid text form IPv4 address and return its canonical text form. *text*, a ``str`` or ``bytes``, the IPv4 address in textual form. Raises ``dns.exception.SyntaxError`` if the text is not valid. )r Zipv4rr#)rr r r canonicalizeCs r$) __doc__rtypingrZ dns.exceptionr rstrrr#r$r r r rs