MCPcopy Create free account
hub / github.com/comaps/comaps / Check

Class Check

tools/python/maps_generator/checks/check.py:50–94  ·  view source on GitHub ↗

Base class for any checks. Usual flow: # Create check object. check = AnyCheck("ExampleCheck") # Do work. check.check() # Get results and process them raw_result = check.get_result() process_result(raw_result) # or print result check.

Source from the content-addressed store, hash-verified

48
49
50class Check(ABC):
51 """
52 Base class for any checks.
53 Usual flow:
54
55 # Create check object.
56 check = AnyCheck("ExampleCheck")
57 # Do work.
58 check.check()
59
60 # Get results and process them
61 raw_result = check.get_result()
62 process_result(raw_result)
63
64 # or print result
65 check.print()
66 """
67 def __init__(self, name: str):
68 self.name = name
69
70 def print(self, silent_if_no_results=False, filt=None, file=sys.stdout):
71 s = self.formatted_string(silent_if_no_results, filt)
72 if s:
73 print(s, file=file)
74
75 @abstractmethod
76 def check(self):
77 """
78 Performs a logic of the check.
79 """
80 pass
81
82 @abstractmethod
83 def get_result(self) -> Any:
84 """
85 Returns a raw result of the check.
86 """
87 pass
88
89 @abstractmethod
90 def formatted_string(self, silent_if_no_results=False, *args, **kwargs) -> str:
91 """
92 Returns a formatted string of a raw result of the check.
93 """
94 pass
95
96
97class CompareCheckBase(Check, ABC):

Callers 1

UNIT_TESTFunction · 0.50

Calls

no outgoing calls

Tested by 1

UNIT_TESTFunction · 0.40