def load_config(path, config_cache): config = None abs_path = os.path.abspath( os.path.join(WorkingDirectory.current_directory(), path) ) WorkingDirectory.push(os.path.dirname(path)) # check the cache first if config_cache.contains(abs_path): return config_cache.get(abs_path) # need to load it from disk if os.path.exists(abs_path): with open(abs_path, "rb") as file: try: data_dict = json.load(file) except: logging.info("error reading %s" % abs_path) raise config_cache.set(abs_path, data_dict) config = handle_includes(config_cache, data_dict, CONFIG_TYPE_MAP) else: raise Exception( "load_config: config \"%s\" does not exist" % abs_path ) WorkingDirectory.pop() return config