def from_filename(cls, filename): "Initialize an instance of RunMode from the configuration file (JSON format)" defaults = cls._defaults.copy() d = json_load(filename) # Put default values if they are not in d. for (k,v) in defaults.items(): if k not in d: d[k] = v return cls(d)
def json_load(cls, filename): return cls.from_dict(json_load(filename))