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