Procházet zdrojové kódy

Merge branch 'develop' into feature/wikitools-core

tags/v0.1^2
Ben Kurtovic před 13 roky
rodič
revize
7639b76d1c
2 změnil soubory, kde provedl 14 přidání a 3 odebrání
  1. +3
    -0
      .gitignore
  2. +11
    -3
      core/config.py

+ 3
- 0
.gitignore Zobrazit soubor

@@ -4,6 +4,9 @@
# Ignore bot-specific config file: # Ignore bot-specific config file:
config.json config.json


# Ignore OS X's crud:
*.DS_Store

# Ignore pydev's nonsense: # Ignore pydev's nonsense:
.project .project
.pydevproject .pydevproject


+ 11
- 3
core/config.py Zobrazit soubor

@@ -13,7 +13,8 @@ from within config's three global variables and one function:
* config.components - a list of enabled components * config.components - a list of enabled components
* config.wiki - a dict of config information for wiki-editing * config.wiki - a dict of config information for wiki-editing
* config.irc - a dict of config information for IRC * 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 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 # set our three easy-config-access global variables to None
components, wiki, irc = (None, None, 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(): def load_config():
"""Load data from our JSON config file (config.json) into _config.""" """Load data from our JSON config file (config.json) into _config."""
global _config global _config
@@ -58,7 +66,7 @@ def verify_config():
if choice.lower().startswith("y"): if choice.lower().startswith("y"):
return make_new_config() return make_new_config()
else: else:
exit()
exit(1)


def parse_config(key): def parse_config(key):
"""Store data from our config file in three global variables for easy """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: try:
data = _config["schedule"] data = _config["schedule"]
except KeyError: except KeyError:
data = []
return [] # nothing is in our schedule
for event in data: for event in data:
do = True do = True
for key, value in now.items(): for key, value in now.items():


Načítá se…
Zrušit
Uložit