(cls: Type[TIntEnum], text: str)
| 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: |
no test coverage detected