diff --git a/setuptools/__init__.py b/setuptools/__init__.py index 25f5bf4..98274c3 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -2,19 +2,53 @@ import configparser, csv, datetime, html.parser, itertools, os, sqlite3, sys, tw class SetupException(Exception): def __str__(self): - return "Seems like config.cfg has not been created yet. Run setup.py to do so." + return "Seems like config.cfg has not been created yet or contains serious errors. Run setup.py to create it." -def getSetting(section, setting): +def getSetting(section, setting, path = "config.cfg"): config = configparser.RawConfigParser() - config.read('config.cfg') + config.read(path) return config.get(section, setting) +def dbtype(): + try: + return getSetting("Database", "type") + except: + return 0 # for SQLite3 + +### Must only be called AFTER dbtype()! ### + +def dbhost(): + try: + return getSetting("Database", "host") + except: + raise SetupException() + +def dbuser(): + try: + return getSetting("Database", "user") + except: + raise SetupException() + +def dbpass(): + try: + return getSetting("Database", "pass") + except: + raise SetupException() + +def dbname(): + try: + return getSetting("Database", "name") + except: + raise SetupException() + def dbpath(): try: return getSetting("Database", "path") except: - return "Database.db" + return SetupException() + +### def cke(): try: