diff --git a/AbstractModule.py b/AbstractModule.py deleted file mode 100644 index 4dbdbf0..0000000 --- a/AbstractModule.py +++ /dev/null @@ -1,12 +0,0 @@ -from abc import ABC, abstractmethod - - -class AbstractModule(ABC): - """docstring for Module.""" - - def __init__(self): - super(AbstractModule, self).__init__() - - @abstractmethod - def run(self): - pass diff --git a/main.py b/main.py index 6d82db2..5c5f966 100644 --- a/main.py +++ b/main.py @@ -1,20 +1,17 @@ -import importlib -import os import fire +from modules.helloworld.HelloWorld import HelloWorld +from modules.install.ToolsInstaller import ToolsInstaller +from modules.swap.SwapModule import SwapModule +from modules.systemupdate.Systemupdate import Systemupdate +from modules.vim.VimModule import VimModule -def load_modules(): - print("Loading modules") - loaded_modules = {} - for folder in os.listdir("./modules"): - try: - curr_module = importlib.import_module('.' + folder, package="modules") - loaded_modules[folder] = curr_module.get_module() - except AttributeError: - pass - print("Modules loaded successfully.\n") - return loaded_modules +modules = { + "helloworld": HelloWorld, + "install": ToolsInstaller, + "swap": SwapModule, + "update": Systemupdate, + "vim": VimModule +} - -modules = load_modules() fire.Fire(modules) diff --git a/modules/helloworld/helloWorld.py b/modules/helloworld/HelloWorld.py similarity index 55% rename from modules/helloworld/helloWorld.py rename to modules/helloworld/HelloWorld.py index cda03ab..c30b036 100644 --- a/modules/helloworld/helloWorld.py +++ b/modules/helloworld/HelloWorld.py @@ -1,12 +1,6 @@ -from AbstractModule import AbstractModule - - -class HelloWorld(AbstractModule): +class HelloWorld: """docstring for SampleModule.""" - def __init__(self): - super(HelloWorld, self).__init__() - def run(self): print("This shows that your installation is working correctly.") print("You can now start using the tool.") diff --git a/modules/helloworld/__init__.py b/modules/helloworld/__init__.py index 604b6e5..e69de29 100644 --- a/modules/helloworld/__init__.py +++ b/modules/helloworld/__init__.py @@ -1,5 +0,0 @@ -from .helloWorld import HelloWorld - - -def get_module(): - return HelloWorld() diff --git a/modules/program-installer/module.py b/modules/install/ToolsInstaller.py similarity index 76% rename from modules/program-installer/module.py rename to modules/install/ToolsInstaller.py index d798e95..0a0d408 100644 --- a/modules/program-installer/module.py +++ b/modules/install/ToolsInstaller.py @@ -1,17 +1,14 @@ import json import subprocess -from AbstractModule import AbstractModule - -class CmdToolsModule(AbstractModule): +class ToolsInstaller: def __init__(self): - super().__init__() - with open("modules/program-installer/programs.json") as config_file: + with open("modules/install/programs.json") as config_file: self.programs_json = json.load(config_file) - def run(self): + def basic_tools(self): """Install the most basic tools!""" print("Try to install basic Command-line tools") diff --git a/modules/install/__init__.py b/modules/install/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/modules/program-installer/programs.json b/modules/install/programs.json similarity index 100% rename from modules/program-installer/programs.json rename to modules/install/programs.json diff --git a/modules/program-installer/__init__.py b/modules/program-installer/__init__.py deleted file mode 100644 index cb3e108..0000000 --- a/modules/program-installer/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .module import CmdToolsModule - - -def get_module(): - return CmdToolsModule() diff --git a/modules/swap/module.py b/modules/swap/SwapModule.py similarity index 97% rename from modules/swap/module.py rename to modules/swap/SwapModule.py index cd342bc..88d8c50 100644 --- a/modules/swap/module.py +++ b/modules/swap/SwapModule.py @@ -1,7 +1,6 @@ import subprocess from typing import List -from AbstractModule import AbstractModule from PyInquirer import prompt @@ -9,10 +8,7 @@ def _run_shell_command(cmd: List[str]) -> str: return subprocess.check_output(cmd).decode("UTF-8").strip() -class SwapModule(AbstractModule): - - def __init__(self): - super().__init__() +class SwapModule: def run(self): actions = { diff --git a/modules/swap/__init__.py b/modules/swap/__init__.py index 907d911..e69de29 100644 --- a/modules/swap/__init__.py +++ b/modules/swap/__init__.py @@ -1,5 +0,0 @@ -from .module import SwapModule - - -def get_module(): - return SwapModule() diff --git a/modules/systemupdate/systemupdate.py b/modules/systemupdate/Systemupdate.py similarity index 84% rename from modules/systemupdate/systemupdate.py rename to modules/systemupdate/Systemupdate.py index 9e9d072..fe8a81d 100644 --- a/modules/systemupdate/systemupdate.py +++ b/modules/systemupdate/Systemupdate.py @@ -1,9 +1,7 @@ import subprocess -from AbstractModule import AbstractModule - -class Systemupdate(AbstractModule): +class Systemupdate: def run(self): print("Running update") diff --git a/modules/systemupdate/__init__.py b/modules/systemupdate/__init__.py index 15f905e..e69de29 100644 --- a/modules/systemupdate/__init__.py +++ b/modules/systemupdate/__init__.py @@ -1,5 +0,0 @@ -from .systemupdate import Systemupdate - - -def get_module(): - return Systemupdate() diff --git a/modules/vim/module.py b/modules/vim/VimModule.py similarity index 97% rename from modules/vim/module.py rename to modules/vim/VimModule.py index cd52635..8cf26ce 100644 --- a/modules/vim/module.py +++ b/modules/vim/VimModule.py @@ -5,10 +5,8 @@ from pathlib import Path from PyInquirer import prompt -from AbstractModule import AbstractModule - -class VimModule(AbstractModule): +class VimModule: def __init__(self): super().__init__() self._debugFlag = False diff --git a/modules/vim/__init__.py b/modules/vim/__init__.py index cfc3d35..e69de29 100644 --- a/modules/vim/__init__.py +++ b/modules/vim/__init__.py @@ -1,5 +0,0 @@ -from .module import VimModule - - -def get_module(): - return VimModule()