From f8faa29caad2d136bd924276ca4a1ac8fdf1dbb4 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Thu, 13 Jun 2019 21:29:51 -0700 Subject: [PATCH] Eliminate unused core module --- inquisitor/app.py | 3 +-- inquisitor/core.py | 42 ------------------------------------------ 2 files changed, 1 insertion(+), 44 deletions(-) delete mode 100644 inquisitor/core.py diff --git a/inquisitor/app.py b/inquisitor/app.py index a6f6533..ba79ed9 100644 --- a/inquisitor/app.py +++ b/inquisitor/app.py @@ -6,7 +6,7 @@ import logging from flask import Flask, render_template, request, jsonify # Application imports -from inquisitor import dungeon, core +from inquisitor import dungeon # Globals logger = logging.getLogger("inquisitor.app") @@ -19,7 +19,6 @@ logger.addHandler(console) app = Flask(__name__) dungeon = dungeon.Dungeon("dungeon") -itemsources = core.load_all_sources("sources") @app.route("/") diff --git a/inquisitor/core.py b/inquisitor/core.py deleted file mode 100644 index 5c4ee92..0000000 --- a/inquisitor/core.py +++ /dev/null @@ -1,42 +0,0 @@ -# Standard library imports -import importlib.util -import os -import logging - -# Globals -logger = logging.getLogger("inquisitor.core") - - -def load_source_module(source_path): - """Loads a source module and checks for necessary members.""" - logger.debug("load_source_module('{}')".format(source_path)) - spec = importlib.util.spec_from_file_location("itemsource", source_path) - itemsource = importlib.util.module_from_spec(spec) - spec.loader.exec_module(itemsource) - if not hasattr(itemsource, 'SOURCE'): - raise ImportError("SOURCE missing") - if not hasattr(itemsource, 'fetch_new'): - raise ImportError("fetch_new missing") - return itemsource - - -def load_all_sources(source_folder): - """Loads all source modules in the given folder.""" - # Navigate to the sources folder - cwd = os.getcwd() - os.chdir(source_folder) - # Load all sources - source_names = [ - filename - for filename in os.listdir() - if filename.endswith(".py")] - sources = [] - for source_name in source_names: - try: - itemsource = load_source_module(source_name) - sources.append(itemsource) - except ImportError as e: - logger.error("Error importing {}: {}".format(source_name, e)) - # Return to cwd - os.chdir(cwd) - return sources