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

Method from_text

dns/enum.py:43–57  ·  view source on GitHub ↗
(cls: Type[TIntEnum], text: str)

Source from the content-addressed store, hash-verified

41
42 @classmethod
43 def from_text(cls: Type[TIntEnum], text: str) -> TIntEnum:
44 text = text.upper()
45 try:
46 return cls[text]
47 except KeyError:
48 pass
49 value = cls._extra_from_text(text)
50 if value:
51 return value
52 prefix = cls._prefix()
53 if text.startswith(prefix) and text[len(prefix) :].isdigit():
54 value = int(text[len(prefix) :])
55 cls._check_value(value)
56 return cls(value)
57 raise cls._unknown_exception_class()
58
59 @classmethod
60 def to_text(cls: Type[TIntEnum], value: int) -> str:

Callers 1

makeMethod · 0.45

Calls 4

_check_valueMethod · 0.80
_extra_from_textMethod · 0.45
_prefixMethod · 0.45

Tested by

no test coverage detected