MCPcopy Create free account
hub / github.com/rthalley/dnspython / split

Method split

dns/name.py:754–772  ·  view source on GitHub ↗

Split a name into a prefix and suffix names at the specified depth. *depth* is an ``int`` specifying the number of labels in the suffix Raises ``ValueError`` if *depth* was not >= 0 and <= the length of the name. Returns the tuple ``(prefix, suffix)``.

(self, depth: int)

Source from the content-addressed store, hash-verified

752 return self.relativize(other)
753
754 def split(self, depth: int) -> Tuple["Name", "Name"]:
755 """Split a name into a prefix and suffix names at the specified depth.
756
757 *depth* is an ``int`` specifying the number of labels in the suffix
758
759 Raises ``ValueError`` if *depth* was not >= 0 and <= the length of the
760 name.
761
762 Returns the tuple ``(prefix, suffix)``.
763 """
764
765 l = len(self.labels)
766 if depth == 0:
767 return (self, dns.name.empty)
768 elif depth == l:
769 return (dns.name.empty, self)
770 elif depth < 0 or depth > l:
771 raise ValueError("depth must be >= 0 and <= the length of the name")
772 return (Name(self[:-depth]), Name(self[-depth:]))
773
774 def concatenate(self, other: "Name") -> "Name":
775 """Return a new name which is the concatenation of self and other.

Callers 15

_from_textFunction · 0.45
_splitMethod · 0.45
_tuple_from_textFunction · 0.45
_version_checkFunction · 0.45
inet_atonFunction · 0.45
read_resolv_confMethod · 0.45
from_textMethod · 0.45
to_textMethod · 0.45
inet_atonFunction · 0.45
from_valueMethod · 0.45
from_valueMethod · 0.45

Calls 1

NameClass · 0.85

Tested by 5

testSplit1Method · 0.36
testSplit2Method · 0.36
testSplit3Method · 0.36
testSplit4Method · 0.36
badMethod · 0.36