2024-07-09 23:09:11 +00:00
|
|
|
import dataclasses
|
|
|
|
|
2024-07-09 23:15:47 +00:00
|
|
|
|
2024-07-09 23:09:11 +00:00
|
|
|
class JunkComparisonException(BaseException):
|
2024-07-09 23:15:47 +00:00
|
|
|
def __str__(self):
|
|
|
|
return 'Attempting to perform calculations involving junk values.'
|
2015-12-19 15:55:14 +00:00
|
|
|
|
|
|
|
|
2024-07-09 23:09:11 +00:00
|
|
|
@dataclasses.dataclass
|
2015-12-19 15:55:14 +00:00
|
|
|
class Junk:
|
2024-07-09 23:09:11 +00:00
|
|
|
represents: str | None = None
|
2015-12-19 15:55:14 +00:00
|
|
|
|
2024-07-09 23:15:47 +00:00
|
|
|
def __str__(self):
|
2024-07-09 23:09:11 +00:00
|
|
|
return '[{}]'.format(self.represents or 'junk')
|
2015-12-19 15:55:14 +00:00
|
|
|
|
2024-07-09 23:15:47 +00:00
|
|
|
def __repr__(self):
|
2018-02-06 19:56:33 +00:00
|
|
|
return self.__str__()
|
2015-12-19 15:55:14 +00:00
|
|
|
|
2024-07-09 23:15:47 +00:00
|
|
|
def __format__(self, format):
|
2024-07-09 23:09:11 +00:00
|
|
|
return self.__str__()
|
|
|
|
|
2024-07-09 23:15:47 +00:00
|
|
|
def __add__(self, other):
|
2018-02-06 19:56:33 +00:00
|
|
|
return self
|
2015-12-19 15:55:14 +00:00
|
|
|
|
2024-07-09 23:15:47 +00:00
|
|
|
def __radd__(self, other):
|
2018-02-06 19:56:33 +00:00
|
|
|
return self
|
2015-12-19 15:55:14 +00:00
|
|
|
|
2024-07-09 23:15:47 +00:00
|
|
|
def __sub__(self, other):
|
2018-02-06 19:56:33 +00:00
|
|
|
return self
|
2015-12-19 15:55:14 +00:00
|
|
|
|
2024-07-09 23:15:47 +00:00
|
|
|
def __rsub__(self, other):
|
2018-02-06 19:56:33 +00:00
|
|
|
return self
|