From 1e93db124d2c5749544e7bb8ed5629df58b20ab4 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 2 Jun 2020 11:49:02 -0700 Subject: [PATCH] Convert to packagable format --- inquisitor/__main__.py | 6 +++--- inquisitor/app.py | 5 ++--- inquisitor/cli.py | 14 +++++++------- inquisitor/error.py | 4 ++-- inquisitor/importer.py | 6 ++---- inquisitor/loader.py | 4 ++-- inquisitor/timestamp.py | 2 +- setup.py | 10 ++++++++++ 8 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 setup.py diff --git a/inquisitor/__main__.py b/inquisitor/__main__.py index 05c9297..e536f17 100644 --- a/inquisitor/__main__.py +++ b/inquisitor/__main__.py @@ -2,12 +2,12 @@ import argparse # Application imports -import cli -import configs +from inquisitor import cli +from inquisitor import configs from signal import signal, SIGPIPE, SIG_DFL -signal(SIGPIPE, SIG_DFL) +signal(SIGPIPE, SIG_DFL) def parse_args(valid_commands): diff --git a/inquisitor/app.py b/inquisitor/app.py index ce98a32..ccfa262 100644 --- a/inquisitor/app.py +++ b/inquisitor/app.py @@ -6,9 +6,8 @@ import traceback from flask import Flask, render_template, request, jsonify # Application imports -from configs import logger, DUNGEON_PATH -import loader -import timestamp +from inquisitor.configs import logger, DUNGEON_PATH +from inquisitor import loader, timestamp # Globals app = Flask(__name__) diff --git a/inquisitor/cli.py b/inquisitor/cli.py index 416c393..ef3f763 100644 --- a/inquisitor/cli.py +++ b/inquisitor/cli.py @@ -6,7 +6,7 @@ import os import random # Application imports -from configs import logger, DUNGEON_PATH, SOURCES_PATH +from inquisitor.configs import logger, DUNGEON_PATH, SOURCES_PATH def command_update(args): @@ -30,7 +30,7 @@ def command_update(args): logger.error("Couldn't find sources. Set INQUISITOR_SOURCES or cd to parent folder of ./sources") # Update sources - from importer import update_sources + from inquisitor.importer import update_sources update_sources(*args.source) return 0 @@ -58,7 +58,7 @@ def command_deactivate(args): return -1 # Deactivate all items in each source. - from loader import load_items + from inquisitor.loader import load_items for source_name in args.source: path = os.path.join(DUNGEON_PATH, source_name) if not os.path.isdir(path): @@ -112,7 +112,7 @@ def command_add(args): logger.error("Source '{}' does not exist".format(source)) return -1 - from importer import populate_new + from inquisitor.importer import populate_new item = { 'id': '{:x}'.format(random.getrandbits(16 * 4)), 'source': 'inquisitor' @@ -142,8 +142,8 @@ def command_feed(args): return -1 import shutil - import loader - import timestamp + from inquisitor import loader + from inquisitor import timestamp items, errors = loader.load_active_items() if not items and not errors: @@ -187,7 +187,7 @@ def command_feed(args): def command_run(args): """Run the default Flask server.""" try: - from app import app + from inquisitor.app import app app.run() return 0 except Exception as e: diff --git a/inquisitor/error.py b/inquisitor/error.py index dbddd84..0270e4a 100644 --- a/inquisitor/error.py +++ b/inquisitor/error.py @@ -3,8 +3,8 @@ import logging import json import random -import timestamp -from configs import DUNGEON_PATH, logger +from inquisitor import timestamp +from inquisitor.configs import DUNGEON_PATH, logger logger = logging.getLogger("inquisitor") diff --git a/inquisitor/importer.py b/inquisitor/importer.py index fa9fb7b..ba26905 100644 --- a/inquisitor/importer.py +++ b/inquisitor/importer.py @@ -4,10 +4,8 @@ import importlib.util import json import sys -import error -from configs import SOURCES_PATH, DUNGEON_PATH, logger -import loader -import timestamp +from inquisitor import loader, timestamp, error +from inquisitor.configs import SOURCES_PATH, DUNGEON_PATH, logger def update_sources(*source_names): sys.path.append(SOURCES_PATH) diff --git a/inquisitor/loader.py b/inquisitor/loader.py index 1d10d57..44d06b1 100644 --- a/inquisitor/loader.py +++ b/inquisitor/loader.py @@ -1,8 +1,8 @@ import os import json -from configs import DUNGEON_PATH -import error +from inquisitor.configs import DUNGEON_PATH +from inquisitor import error class WritethroughDict(): """A wrapper for a dictionary saved to the disk.""" diff --git a/inquisitor/timestamp.py b/inquisitor/timestamp.py index 73a633b..111bc43 100644 --- a/inquisitor/timestamp.py +++ b/inquisitor/timestamp.py @@ -6,4 +6,4 @@ def now(): def stamp_to_readable(ts, formatstr="%Y-%m-%d %H:%M:%S"): dt = datetime.datetime.fromtimestamp(ts) - return dt.strftime(formatstr) \ No newline at end of file + return dt.strftime(formatstr) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..07ae4e1 --- /dev/null +++ b/setup.py @@ -0,0 +1,10 @@ +import setuptools + +setuptools.setup( + name="inquisitor", + version="0.0.1", + author="Tim Van Baak", + description="An arbitrary feed aggregator", + packages=setuptools.find_packages(), + python_requires=">=3.6", +) \ No newline at end of file