예제 #1
0
    def generate_spdx_file(self) -> File:
        """Generates the SPDX file.

        SPDX File example:
        FileName: ./tests/test_mbed_targets.py
        SPDXID: SPDXRef-cb9cce30c285e6083c2d19a463cbe592
        FileChecksum: SHA1: d3db49873bd2b1cab45bf81e7d88617dea6caaff
        LicenseConcluded: NOASSERTION
        FileCopyrightText: NONE

        Returns:
            the corresponding file
        """
        source_file = File(determine_spdx_value(self.unix_relative_path))
        source_file.type = FileType.SOURCE
        source_file.comment = determine_spdx_value(None)
        source_file.chk_sum = Algorithm("SHA1", self.sha1_check_sum)
        source_file.conc_lics = License.from_identifier(
            str(determine_spdx_value(self.licence)))
        source_file.spdx_id = f"SPDXRef-{self.id}"
        source_file.copyright = determine_spdx_value(self.copyright)
        source_file.add_lics(
            License.from_identifier(str(determine_spdx_value(self.licence))))
        return source_file
예제 #2
0
    from spdx.checksum import Algorithm
    from spdx.utils import SPDXNone, NoAssert, UnKnown

    doc = Document()
    doc.version = Version(1, 2)
    doc.comment = 'Example Document'
    doc.data_license = License.from_identifier('CC0-1.0')
    doc.creation_info.add_creator(Person('Alice', '*****@*****.**'))
    doc.creation_info.set_created_now()
    review = Review(Person('Joe', None))
    review.set_review_date_now()
    review.comment = 'Joe reviewed this document'
    doc.add_review(review)
    # File
    testfile1 = File('TestFile1')
    testfile1.type = FileType.BINARY
    testfile1.comment = 'This is a test file.'
    testfile1.chk_sum = Algorithm('SHA1',
                                  'c537c5d99eca5333f23491d47ededd083fefb7ad')
    testfile1.conc_lics = License.from_identifier('BSD-2-Clause')
    testfile1.add_lics(License.from_identifier('BSD-2-Clause'))
    testfile1.copyright = SPDXNone()
    testfile1.add_artifact('name', 'TagWriteTest')
    testfile1.add_artifact('home', UnKnown())
    testfile1.add_artifact('uri', 'http://tagwritetest.test')

    testfile2 = File('TestFile2')
    testfile2.type = FileType.SOURCE
    testfile2.comment = 'This is a test file.'
    testfile2.chk_sum = Algorithm('SHA1',
                                  'bb154f28d1cf0646ae21bb0bec6c669a2b90e113')
예제 #3
0
    from spdx.checksum import Algorithm
    from spdx.utils import SPDXNone, NoAssert, UnKnown

    doc = Document()
    doc.version = Version(1, 2)
    doc.comment = 'Example Document'
    doc.data_license = License.from_identifier('CC0-1.0')
    doc.creation_info.add_creator(Person('Alice', '*****@*****.**'))
    doc.creation_info.set_created_now()
    review = Review(Person('Joe', None))
    review.set_review_date_now()
    review.comment = 'Joe reviewed this document'
    doc.add_review(review)
    # File
    testfile1 = File('TestFile1')
    testfile1.type = FileType.BINARY
    testfile1.comment = 'This is a test file.'
    testfile1.chk_sum = Algorithm('SHA1', 'c537c5d99eca5333f23491d47ededd083fefb7ad')
    testfile1.conc_lics = License.from_identifier('BSD-2-Clause')
    testfile1.add_lics(License.from_identifier('BSD-2-Clause'))
    testfile1.copyright = SPDXNone()
    testfile1.add_artifact('name', 'TagWriteTest')
    testfile1.add_artifact('home', UnKnown())
    testfile1.add_artifact('uri', 'http://tagwritetest.test')

    testfile2 = File('TestFile2')
    testfile2.type = FileType.SOURCE
    testfile2.comment = 'This is a test file.'
    testfile2.chk_sum = Algorithm('SHA1', 'bb154f28d1cf0646ae21bb0bec6c669a2b90e113')
    testfile2.conc_lics = License.from_identifier('Apache-2.0')
    testfile2.add_lics(License.from_identifier('Apache-2.0'))