mirror of https://gitlab.com/pamhyr/pamhyr2
Checker: Add abstract checker class.
parent
9d4e51bf22
commit
768a743f0f
|
|
@ -0,0 +1,63 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
from Model.Except import NotImplementedMethodeError
|
||||||
|
|
||||||
|
class STATUS(Enum):
|
||||||
|
UNKNOWN = -1
|
||||||
|
OK = 0
|
||||||
|
WARNING = 1
|
||||||
|
ERROR = 2
|
||||||
|
|
||||||
|
class AbstractModelChecker(object):
|
||||||
|
def __init__(self):
|
||||||
|
self._name = ""
|
||||||
|
self._description = ""
|
||||||
|
|
||||||
|
self._status = STATUS.UNKNOWN
|
||||||
|
self._summary = "Unknown"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def description(self):
|
||||||
|
return self._description
|
||||||
|
|
||||||
|
# Checker status
|
||||||
|
|
||||||
|
def is_unknown(self):
|
||||||
|
return self._status == STATUS.UNKNOWN
|
||||||
|
|
||||||
|
def is_ok(self):
|
||||||
|
return self._status == STATUS.OK
|
||||||
|
|
||||||
|
def is_warning(self):
|
||||||
|
return self._status == STATUS.WARNING
|
||||||
|
|
||||||
|
def is_error(self):
|
||||||
|
return self._status == STATUS.ERROR
|
||||||
|
|
||||||
|
# Abstract function
|
||||||
|
|
||||||
|
def run(self, study):
|
||||||
|
"""Run checker function
|
||||||
|
|
||||||
|
Args:
|
||||||
|
study: The study to check
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Return true if study is valid for this checker, false
|
||||||
|
otherelse
|
||||||
|
"""
|
||||||
|
raise NotImplementedMethodeError(self, self.run)
|
||||||
|
|
||||||
|
def summary(self):
|
||||||
|
"""Return summary message
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Return summary string
|
||||||
|
"""
|
||||||
|
raise NotImplementedMethodeError(self, self.summary)
|
||||||
Loading…
Reference in New Issue