def generate_spdx_project_reports(project: SpdxProject, output_directory: Path) -> SpdxProject:
    """Generates all the SPDX reports for a given project."""
    logger.info("Generating SPDX report.")
    project.generate_tag_value_files(output_directory)
    logger.info("Generating licensing summary.")
    project.generate_licensing_summary(output_directory)
    return project
예제 #2
0
    def test_check_licence_non_compliance(self):
        metadata = ProjectMetadata("test_package")
        metadata.project_metadata = PackageMetadata({"License": "GPL 3"})

        with patch(
                "mbed_tools_ci_scripts.utils.package_helpers.ProjectMetadataParser.project_metadata",
                new_callable=PropertyMock,
        ) as mock_parser:
            mock_parser.return_value = metadata
            parser = ProjectMetadataParser("test_package")
            project = SpdxProject(parser)
            with self.assertRaisesRegex(ValueError, r".*GPL-3.0*"):
                project.check_licence_compliance()
예제 #3
0
def generate_spdx_reports(output_directory: Path) -> SpdxProject:
    """Generates all the SPDX reports for the current project."""
    logger.info("Generating package information.")
    try:
        # Trying to generate the egg for the package but this may fail. If so, continue.
        generate_package_info()
    except Exception as e:
        log_exception(logger, e)

    logger.info("Generating SPDX report.")
    project = SpdxProject(CurrentProjectMetadataParser())
    project.generate_tag_value_files(output_directory)
    return project
def get_current_spdx_project() -> SpdxProject:
    """Gets information about the current project/package."""
    logger.info("Generating package information.")
    try:
        # Trying to generate the egg for the package but this may fail. If so, continue.
        generate_package_info()
    except Exception as e:
        log_exception(logger, e)
    return SpdxProject(CurrentProjectMetadataParser())
예제 #5
0
    def test_check_licence_compliance(self):
        metadata = ProjectMetadata("test_package")
        metadata.project_metadata = PackageMetadata({"License": "Apache 2"})

        with patch(
                "mbed_tools_ci_scripts.utils.package_helpers.ProjectMetadataParser.project_metadata",
                new_callable=PropertyMock,
        ) as mock_parser:
            mock_parser.return_value = metadata
            parser = ProjectMetadataParser("test_package")
            SpdxProject(parser).check_licence_compliance()