Commit cbe5c612 by Bridger Maxwell

Used dictionary update for cleaner course settings code.

parent 201f0939
...@@ -64,11 +64,11 @@ global_settings_json = """ ...@@ -64,11 +64,11 @@ global_settings_json = """
class Settings(object): class Settings(object):
def __init__(self): def __init__(self):
#Load the global settings as a dictionary # Load the global settings as a dictionary
global_settings = json.loads(global_settings_json) global_settings = json.loads(global_settings_json)
#Load the course settings as a dictionary # Load the course settings as a dictionary
course_settings = {} course_settings = {}
try: try:
with open( settings.DATA_DIR + "/course_settings.json") as course_settings_file: with open( settings.DATA_DIR + "/course_settings.json") as course_settings_file:
...@@ -78,15 +78,13 @@ class Settings(object): ...@@ -78,15 +78,13 @@ class Settings(object):
log.warning("Unable to load course settings file from " + str(settings.DATA_DIR) + "/course_settings.json") log.warning("Unable to load course settings file from " + str(settings.DATA_DIR) + "/course_settings.json")
#First, set the properties from the global settings on ourselves # Override any global settings with the course settings
global_settings.update(course_settings)
# Now, set the properties from the course settings on ourselves
for setting in global_settings: for setting in global_settings:
setting_value = global_settings[setting] setting_value = global_settings[setting]
setattr(self, setting, setting_value) setattr(self, setting, setting_value)
#Now, set the properties from the course settings on ourselves, possibly overriding global values
for setting in course_settings:
setting_value = course_settings[setting]
setattr(self, setting, setting_value)
# Here is where we should parse any configurations, so that we can fail early # Here is where we should parse any configurations, so that we can fail early
self.GRADER = graders.grader_from_conf(self.GRADER) self.GRADER = graders.grader_from_conf(self.GRADER)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment