def normalize(self, x): ''' Take in an IP address as a string, integer, or IPAddress object, and convert it to an integer. ''' if not ak.isSupportedInt(x): x = int(_ip_address(x)) if x < 0: raise ValueError("Not an IP address: {}".format(_ip_address(x))) return x
def format(self, x): ''' Format a single integer IP address as a string. ''' if not ak.isSupportedInt(x): raise TypeError("Argument must be an integer scalar") return str(_ip_address(int(x)))
def _is_ip_address(address): try: _ip_address(_unicode(address)) return True except (ValueError, UnicodeError): return False
def ip_address(x): try: x = x.decode('ascii') except AttributeError: pass return _ip_address(x)
def ip_address(q): return _ip_address(q)
def _is_ip_address(address): try: _ip_address(address) return True except (ValueError, UnicodeError): # noqa: B014 return False