コード例 #1
0
    def get_from_dict(
        cls,
        raw_dict: dict,
        config_file_path: str = None,
        repo_name: str = None,
        spec_file_path: str = None,
    ) -> "PackageConfig":
        # required to avoid cyclical imports
        from packit.schema import PackageConfigSchema

        if config_file_path and not raw_dict.get("config_file_path", None):
            raw_dict.update(config_file_path=config_file_path)

        # we need to process defaults first so they get propagated to JobConfigs

        if "jobs" not in raw_dict:
            # we want default jobs to go through the proper parsing process
            raw_dict["jobs"] = get_default_jobs()

        if not raw_dict.get("specfile_path", None):
            if spec_file_path:
                raw_dict["specfile_path"] = spec_file_path
            else:
                raise PackitConfigException("Spec file was not found!")

        if not raw_dict.get("upstream_package_name", None) and repo_name:
            raw_dict["upstream_package_name"] = repo_name

        if not raw_dict.get("downstream_package_name", None) and repo_name:
            raw_dict["downstream_package_name"] = repo_name

        package_config = PackageConfigSchema().load_config(raw_dict)

        logger.debug(package_config)
        return package_config
コード例 #2
0
    def get_from_dict(
        cls,
        raw_dict: dict,
        config_file_path: Optional[str] = None,
        repo_name: Optional[str] = None,
        spec_file_path: Optional[str] = None,
    ) -> "PackageConfig":
        # required to avoid cyclical imports
        from packit.schema import PackageConfigSchema

        if config_file_path and not raw_dict.get("config_file_path", None):
            raw_dict.update(config_file_path=config_file_path)

        # we need to process defaults first so they get propagated to JobConfigs

        if "jobs" not in raw_dict:
            # we want default jobs to go through the proper parsing process
            raw_dict["jobs"] = get_default_jobs()

        if not raw_dict.get("upstream_package_name", None) and repo_name:
            raw_dict["upstream_package_name"] = repo_name

        if not raw_dict.get("downstream_package_name", None) and repo_name:
            raw_dict["downstream_package_name"] = repo_name

        if not raw_dict.get("specfile_path", None):
            if spec_file_path:
                raw_dict["specfile_path"] = spec_file_path
            else:
                # we default to downstream_package_name
                # https://packit.dev/docs/configuration/#specfile_path
                downstream_package_name = raw_dict.get("downstream_package_name", None)
                if downstream_package_name:
                    raw_dict["specfile_path"] = f"{downstream_package_name}.spec"
                # else: we could try upstream_package_name but this seems
                # like an extreme corner case

        package_config = PackageConfigSchema().load(raw_dict)

        if not package_config.specfile_path and not all(
            job.type == JobType.tests and job.skip_build for job in package_config.jobs
        ):
            raise PackitConfigException("Spec file was not found!")

        return package_config
コード例 #3
0
ファイル: package_config.py プロジェクト: packit/packit
    def get_from_dict(
        cls,
        raw_dict: dict,
        config_file_path: str = None,
        repo_name: str = None,
        spec_file_path: str = None,
    ) -> "PackageConfig":
        # required to avoid cyclical imports
        from packit.schema import PackageConfigSchema

        if config_file_path and not raw_dict.get("config_file_path", None):
            raw_dict.update(config_file_path=config_file_path)

        # we need to process defaults first so they get propagated to JobConfigs

        if "jobs" not in raw_dict:
            # we want default jobs to go through the proper parsing process
            raw_dict["jobs"] = get_default_jobs()

        if not raw_dict.get("specfile_path", None) and spec_file_path:
            raw_dict["specfile_path"] = spec_file_path

        if not raw_dict.get("upstream_package_name", None) and repo_name:
            raw_dict["upstream_package_name"] = repo_name

        if not raw_dict.get("downstream_package_name", None) and repo_name:
            raw_dict["downstream_package_name"] = repo_name

        package_config = PackageConfigSchema().load(raw_dict)

        if not package_config.specfile_path and not all(
                job.type == JobType.tests and job.metadata.skip_build
                for job in package_config.jobs):
            raise PackitConfigException("Spec file was not found!")

        return package_config