コード例 #1
0
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())
コード例 #2
0
 def test_project_metadata_generation_and_parsing(self):
     generate_package_info()
     current_package = configuration.get_value(ConfigurationVariable.PACKAGE_NAME)
     metadata = get_all_packages_metadata_lines(current_package)
     self.assertIsNotNone(metadata)
     self.assertGreaterEqual(len(metadata), 1)
     self.assertIn(
         current_package, [parse_package_metadata_lines(metadata_lines).name for metadata_lines in metadata]
     )
コード例 #3
0
 def test_package_metadata_parser(self):
     generate_package_info()
     current_package = configuration.get_value(ConfigurationVariable.PACKAGE_NAME)
     parser = ProjectMetadataParser(package_name=current_package)
     metadata = parser.project_metadata
     self.assertIsNotNone(metadata)
     self.assertEqual(metadata.package_name, current_package)
     self.assertIsNotNone(metadata.project_metadata)
     self.assertEqual(metadata.project_metadata.name, current_package)
     self.assertEqual(metadata.package_name, current_package)
     self.assertIsNotNone(metadata.dependencies_metadata)
     self.assertGreaterEqual(len(metadata.dependencies_metadata), 1)
コード例 #4
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