Added class Condition
parent
4799352c82
commit
d02a1beb9e
14
action.py
14
action.py
|
|
@ -14,6 +14,16 @@ class Action(ABC):
|
|||
pass
|
||||
|
||||
|
||||
class Condition(ABC):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
|
||||
@abc.abstractmethod
|
||||
def execute(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
class LoggMessageAction(Action):
|
||||
|
||||
def execute(self, *args, **kwargs):
|
||||
|
|
@ -44,7 +54,7 @@ class CompressAction(Action):
|
|||
pass
|
||||
|
||||
|
||||
class IsFileExistsAction(Action):
|
||||
class IsFileExistsCondition(Condition):
|
||||
|
||||
def execute(self, *args, **kwargs):
|
||||
path = self.kwargs.get('path')
|
||||
|
|
@ -55,7 +65,7 @@ class IsFileExistsAction(Action):
|
|||
return os.path.exists(path)
|
||||
|
||||
|
||||
class IsDirectoryEmptyAction(Action):
|
||||
class IsDirectoryEmptyCondition(Condition):
|
||||
|
||||
def execute(self, *args, **kwargs):
|
||||
path = self.kwargs.get('path')
|
||||
|
|
|
|||
4
app.py
4
app.py
|
|
@ -8,13 +8,13 @@ from logger import Logger
|
|||
class App:
|
||||
|
||||
def __init__(self):
|
||||
Logger.set_log_file('//testdata/log.txt')
|
||||
Logger.set_log_file('testdata/log.txt')
|
||||
self._config = Config()
|
||||
|
||||
def start(self):
|
||||
self._config.read_config()
|
||||
self._config.add_entry(Entry('myTest',
|
||||
IsDirectoryEmptyAction(path='//emptydir', entry='myTest'),
|
||||
IsDirectoryEmptyCondition(path='emptydir', entry='myTest'),
|
||||
LoggMessageAction('success', entry='myTest'),
|
||||
LoggMessageAction('fail', entry='myTest')))
|
||||
|
||||
|
|
|
|||
6
entry.py
6
entry.py
|
|
@ -1,11 +1,11 @@
|
|||
from action import Action
|
||||
from action import Action, Condition
|
||||
|
||||
|
||||
class Entry:
|
||||
|
||||
def __init__(self, name: str, action: Action, success: Action, fail: Action):
|
||||
def __init__(self, name: str, condition: Condition, success: Action, fail: Action):
|
||||
self._name = name
|
||||
self._action = action
|
||||
self._action = condition
|
||||
self._success = success
|
||||
self._fail = fail
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue