26 lines
486 B
Python
26 lines
486 B
Python
from enum import Enum
|
|
from typing import override
|
|
|
|
|
|
class Tern(Enum):
|
|
N = -1
|
|
U = 0
|
|
Y = 1
|
|
|
|
@override
|
|
def __str__(self):
|
|
if self.value == -1:
|
|
return "0"
|
|
if self.value == 1:
|
|
return "1"
|
|
return "N"
|
|
|
|
@classmethod
|
|
def from_string(cls, s: str) -> "Tern":
|
|
if s == "N":
|
|
return Tern.U
|
|
if s == "0":
|
|
return Tern.N
|
|
if s == "1":
|
|
return Tern.Y
|
|
return cls[s]
|