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

Method make

dns/enum.py:72–89  ·  view source on GitHub ↗

Convert text or a value into an enumerated type, if possible. *value*, the ``int`` or ``str`` to convert. Raises a class-specific exception if a ``str`` is provided that cannot be converted. Raises ``ValueError`` if the value is out of range. Returns an en

(cls: Type[TIntEnum], value: int | str)

Source from the content-addressed store, hash-verified

70
71 @classmethod
72 def make(cls: Type[TIntEnum], value: int | str) -> TIntEnum:
73 """Convert text or a value into an enumerated type, if possible.
74
75 *value*, the ``int`` or ``str`` to convert.
76
77 Raises a class-specific exception if a ``str`` is provided that
78 cannot be converted.
79
80 Raises ``ValueError`` if the value is out of range.
81
82 Returns an enumeration from the calling class corresponding to the
83 value, if one is defined, or an ``int`` otherwise.
84 """
85
86 if isinstance(value, str):
87 return cls.from_text(value)
88 cls._check_value(value)
89 return cls(value)
90
91 @classmethod
92 def _maximum(cls):

Callers 15

_as_rdataclassMethod · 0.45
_as_rdatatypeMethod · 0.45
from_textFunction · 0.45
from_wire_parserFunction · 0.45
register_typeFunction · 0.45
from_flagsFunction · 0.45
_make_dnskeyFunction · 0.45
resolve_nameMethod · 0.45
getMethod · 0.45
_deleteMethod · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 2

_check_valueMethod · 0.80
from_textMethod · 0.45

Tested by 7

testDigestToBigMethod · 0.36
testNSEC3HashTooBigMethod · 0.36
test_unknown_rcodeMethod · 0.36
test_nsap_ptr_typeMethod · 0.36