1
|
1 |
|
import logging |
2
|
|
|
|
3
|
1 |
|
logger = logging.getLogger(__name__) |
4
|
|
|
|
5
|
|
|
|
6
|
1 |
|
class Code: |
7
|
1 |
|
def __init__(self, code, description): |
8
|
1 |
|
self.code = code |
9
|
1 |
|
self.description = description |
10
|
|
|
|
11
|
1 |
|
def __str__(self): |
12
|
1 |
|
if self.description is None: |
13
|
1 |
|
return self.code |
14
|
1 |
|
if isinstance(self.description, list): |
15
|
1 |
|
return str(self.code) + " - " + "; ".join(self.description) |
16
|
1 |
|
return str(self.code) + " - " + str(self.description) |
17
|
|
|
|
18
|
|
|
def __repr__(self): |
19
|
|
|
# return '%s.%s(%s)' % (self.__class__.__module__, |
20
|
|
|
# self.__class__.__qualname__, |
21
|
|
|
# f'{repr(self.code)}, {repr(self.description)}') |
22
|
|
|
|
23
|
|
|
return '%s(%s)' % ( |
24
|
|
|
self.__class__.__qualname__, |
25
|
|
|
f'{repr(self.code)}, {repr(self.description)}' |
26
|
|
|
) |
27
|
|
|
|
28
|
1 |
|
def __eq__(self, other): |
29
|
1 |
|
if isinstance(other, Code): |
30
|
1 |
|
return self.code == other.code |
31
|
1 |
|
return self.code == other |
32
|
|
|
|
33
|
1 |
|
def __ne__(self, other): |
34
|
1 |
|
if isinstance(other, Code): |
35
|
|
|
return self.code != other.code |
36
|
1 |
|
return self.code != other |
37
|
|
|
|
38
|
1 |
|
def __lt__(self, other): |
39
|
|
|
if isinstance(other, Code): |
40
|
|
|
return self.code < other.code |
41
|
|
|
return self.code < other |
42
|
|
|
|
43
|
1 |
|
def __le__(self, other): |
44
|
|
|
if isinstance(other, Code): |
45
|
|
|
return self.code <= other.code |
46
|
|
|
return self.code <= other |
47
|
|
|
|
48
|
1 |
|
def __gt__(self, other): |
49
|
|
|
if isinstance(other, Code): |
50
|
|
|
return self.code > other.code |
51
|
|
|
return self.code > other |
52
|
|
|
|
53
|
1 |
|
def __ge__(self, other): |
54
|
|
|
if isinstance(other, Code): |
55
|
|
|
return self.code >= other.code |
56
|
|
|
return self.code >= other |
57
|
|
|
|
58
|
1 |
|
def __hash__(self): |
59
|
1 |
|
return self.code.__hash__() |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
|