MCPcopy Index your code
hub / github.com/RustPython/RustPython / _split_addr_prefix

Method _split_addr_prefix

Lib/ipaddress.py:529–550  ·  view source on GitHub ↗

Helper function to parse address of Network/Interface. Arg: address: Argument of Network/Interface. Returns: (addr, prefix) tuple.

(cls, address)

Source from the content-addressed store, hash-verified

527
528 @classmethod
529 def _split_addr_prefix(cls, address):
530 """Helper function to parse address of Network/Interface.
531
532 Arg:
533 address: Argument of Network/Interface.
534
535 Returns:
536 (addr, prefix) tuple.
537 """
538 # a packed address or integer
539 if isinstance(address, (bytes, int)):
540 return address, cls.max_prefixlen
541
542 if not isinstance(address, tuple):
543 # Assume input argument to be string or any object representation
544 # which converts into a formatted IP prefix string.
545 address = _split_optional_netmask(address)
546
547 # Constructing from a tuple (addr, [mask])
548 if len(address) > 1:
549 return address
550 return address[0], cls.max_prefixlen
551
552 def __reduce__(self):
553 return self.__class__, (str(self),)

Callers 4

__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80

Calls 3

isinstanceFunction · 0.85
_split_optional_netmaskFunction · 0.85
lenFunction · 0.85

Tested by

no test coverage detected