def load_unit(path): with open(path, 'rb') as f: data = pickle.load(f) conf = make_conf(dict_to_object(data['conf'])) unit = TimeUnit(conf, data=data['unit']) return unit
def make_conf(*args, **kwargs): """ 1. get_conf(conf_module) 2. get_conf(key=value, ...) :return: conf with default values added (where needed) """ conf = object_to_dict(default_conf) if len(args) == 1: dict_conf = object_to_dict(args[0]) else: dict_conf = kwargs conf.update(dict_conf) return dict_to_object(conf)