Convert to packagable format

This commit is contained in:
Tim Van Baak 2020-06-02 11:49:02 -07:00
parent fac258e5f3
commit 1e93db124d
8 changed files with 29 additions and 22 deletions

View File

@ -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):

View File

@ -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__)

View File

@ -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:

View File

@ -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")

View File

@ -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)

View File

@ -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."""

View File

@ -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)
return dt.strftime(formatstr)

10
setup.py Normal file
View File

@ -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",
)