def get_from_dict(cls, raw_dict: dict, validate=True) -> "JobConfig": if validate and not JobConfig.is_dict_valid(raw_dict): raise Exception(f"Job config not valid.") trigger_raw, release_to, metadata = exclude_from_dict( raw_dict, "trigger", "release_to") return JobConfig(trigger=TriggerType[trigger_raw], release_to=release_to, metadata=metadata)
def get_from_dict(cls, raw_dict: dict, validate=True) -> PackageConfig: if validate and not PackageConfig.is_dict_valid(raw_dict): raise Exception("Package config not valid.") specfile_path, synced_files, raw_jobs, metadata = exclude_from_dict( raw_dict, "specfile_path", "synced_files", "jobs") return PackageConfig( specfile_path=specfile_path, synced_files=synced_files, jobs=[ JobConfig.get_from_dict(raw_job, validate=False) for raw_job in raw_jobs ], metadata=metadata, )
def get_from_dict(cls, raw_dict: dict, validate=True) -> "PackageConfig": if validate: PackageConfig.validate_dict(raw_dict) specfile_path, synced_files, raw_jobs, metadata = exclude_from_dict( raw_dict, "specfile_path", "synced_files", "jobs") raw_jobs = raw_jobs or [] pc = PackageConfig( specfile_path=specfile_path, synced_files=synced_files, jobs=[ JobConfig.get_from_dict(raw_job, validate=False) for raw_job in raw_jobs ], metadata=metadata, ) return pc