From 9a4ce98f2dd348cee2c8f875696783619e6c11af Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Wed, 16 Mar 2016 13:49:28 +0100 Subject: [PATCH] Split setuptools from twitools --- setuptools.py | 11 +++++++++++ twitools.py | 25 ++++++++----------------- 2 files changed, 19 insertions(+), 17 deletions(-) create mode 100644 setuptools.py diff --git a/setuptools.py b/setuptools.py new file mode 100644 index 0000000..e806b8c --- /dev/null +++ b/setuptools.py @@ -0,0 +1,11 @@ +import configparser + +class SetupException(Exception): + def __str__(self): + return "Seems like config.cfg has not been created yet. Run setup.py to do so." + +def getSetting(section, setting): + config = configparser.RawConfigParser() + config.read('config.cfg') + return config.get(section, setting) + diff --git a/twitools.py b/twitools.py index 4acb4f1..b2a3914 100644 --- a/twitools.py +++ b/twitools.py @@ -1,37 +1,28 @@ -import configparser, tweepy - -class SetupException(Exception): - def __str__(self): - return "Seems like config.cfg has not been created yet. Run setup.py to do so." - -def getSetting(section, setting): - config = configparser.RawConfigParser() - config.read('config.cfg') - return config.get(section, setting) +import setuptools, tweepy def cke(): try: return getSetting("Twitter", "cke") except: - raise SetupException() + raise setuptools.SetupException() def cse(): try: - return getSetting("Twitter", "cse") + return setuptools.getSetting("Twitter", "cse") except: - raise SetupException() + raise setuptools.SetupException() def ato(): try: - return getSetting("Twitter", "ato") + return setuptools.getSetting("Twitter", "ato") except: - raise SetupException() + raise setuptools.SetupException() def ase(): try: - return getSetting("Twitter", "ase") + return setuptools.getSetting("Twitter", "ase") except: - raise SetupException() + raise setuptools.SetupException() def user(): return twObject().whoami()