def yaml_include(loader, node): """Include another YAML file.""" debug = Scope("Util.Config.yaml_loader") filename = loader.construct_scalar(node) filename = find_resource(filename + '.yaml') with open(filename) as include_fp: data = yaml.load(include_fp) debug.log("Include-Config '%s' geladen" % filename) return data
def load_config_file(self, name): """ lädt die Config mit dem namen name im recourcenpfad und im homedir die config aus dem homedir überschreibt dabei die values aus dem recource dir """ default_name = find_resource(name + ".yaml") with open(default_name) as default_fp: config = yaml.load(default_fp) self.debug.log("Default-Config '%s' geladen" % default_name) try: if not DO_NOT_LOAD_HOME_CONFIG: home_name = os.path.expanduser("~/%s.yaml" % name) with open(home_name) as home_fp: config = self.recursive_update(config, yaml.load(home_fp)) self.debug.log("Config '%s' mit spezifischen Werten geladen" % home_name) except IOError: # keine config im homeordner, einfach ignorieren pass def log_config(conf, confdebug): """ Send contents of the dict conf to the Scope confdebug """ for (key, value) in conf.items(): # the config might contain subsections (also dicts) if isinstance(value, dict): log_config(value, confdebug.sub(key)) else: confdebug.log(key, repr(value)) #send the loaded config to the debugger log_config(config, self.debug.sub(name)) #conf = HelperDict(config) # TODO: Das will wieder schöner gemacht werde # das ist ddraußen weil das dumpen damit probleme macht, und es # nicht so viel bringt #conf.set_debug(self.debug) #return conf return config
def __init__(self): self.joints = load_joints_from_yaml(find_resource("config/joints.yaml")) self.config = get_config()