From c47b25592486cfe82b31d0ecea4cdf80414202ea Mon Sep 17 00:00:00 2001 From: Marcel Schwarz Date: Mon, 16 Dec 2019 22:51:06 +0100 Subject: [PATCH] Update IModule to AbstractModule with ABC class --- AbstractModule.py | 16 ++++++++++++++++ IModule.py | 8 -------- modules/sample/sampleModule.py | 7 +++++-- 3 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 AbstractModule.py delete mode 100644 IModule.py diff --git a/AbstractModule.py b/AbstractModule.py new file mode 100644 index 0000000..fed48da --- /dev/null +++ b/AbstractModule.py @@ -0,0 +1,16 @@ +from abc import ABC, abstractmethod + + +class AbstractModule(ABC): + """docstring for Module.""" + + def __init__(self): + super(AbstractModule, self).__init__() + + @abstractmethod + def get_command(self): + pass + + @abstractmethod + def run(self): + pass diff --git a/IModule.py b/IModule.py deleted file mode 100644 index bdc3bbb..0000000 --- a/IModule.py +++ /dev/null @@ -1,8 +0,0 @@ -class IModule(object): - """docstring for Module.""" - - def __init__(self): - super(IModule, self).__init__() - - def get_command(self): - raise NotImplementedError diff --git a/modules/sample/sampleModule.py b/modules/sample/sampleModule.py index 5fdd363..34e81e3 100644 --- a/modules/sample/sampleModule.py +++ b/modules/sample/sampleModule.py @@ -1,12 +1,15 @@ -from IModule import IModule +from AbstractModule import AbstractModule -class SampleModule(IModule): +class SampleModule(AbstractModule): """docstring for SampleModule.""" def __init__(self): super(SampleModule, self).__init__() + def run(self): + pass + def get_command(self): return [ "command 1",