From f1171ed45229f1187a65e098c5c6e388935a2e15 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Wed, 27 Jul 2011 01:05:42 -0400 Subject: [PATCH] Committing changes made while working on feature/wikitools-core that don't apply to wikitools: Adding .DS_Store to .gitignore (pesky OS X) Adding a is_config_loaded() function to core/config.py Some cleanup in core/config.py: doc clarification, misc fixes... --- .gitignore | 3 +++ core/config.py | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 1e66a11..bc67eea 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ # Ignore bot-specific config file: config.json +# Ignore OS X's crud: +*.DS_Store + # Ignore pydev's nonsense: .project .pydevproject diff --git a/core/config.py b/core/config.py index 411c187..b2c7cdf 100644 --- a/core/config.py +++ b/core/config.py @@ -13,7 +13,8 @@ from within config's three global variables and one function: * config.components - a list of enabled components * config.wiki - a dict of config information for wiki-editing * config.irc - a dict of config information for IRC -* config.schedule() - returns a list of tasks scheduled to run now +* config.schedule() - returns a list of tasks scheduled to run at a given + time """ import json @@ -30,6 +31,13 @@ _config = None # holds data loaded from our config file # set our three easy-config-access global variables to None components, wiki, irc = (None, None, None) +def is_config_loaded(): + """Return True if our config file has already been loaded, and False if it + hasn't.""" + if _config is not None: + return True + return False + def load_config(): """Load data from our JSON config file (config.json) into _config.""" global _config @@ -58,7 +66,7 @@ def verify_config(): if choice.lower().startswith("y"): return make_new_config() else: - exit() + exit(1) def parse_config(key): """Store data from our config file in three global variables for easy @@ -120,7 +128,7 @@ def schedule(minute, hour, month_day, month, week_day): try: data = _config["schedule"] except KeyError: - data = [] + return [] # nothing is in our schedule for event in data: do = True for key, value in now.items():