1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
package saver2v1
import (
"fmt"
"io"
"sort"
"github.com/spdx/tools-golang/spdx"
)
func renderFile2_1(f *spdx.File2_1, w io.Writer) error {
if f.FileName != "" {
fmt.Fprintf(w, "FileName: %s\n", f.FileName)
}
if f.FileSPDXIdentifier != "" {
fmt.Fprintf(w, "SPDXID: %s\n", spdx.RenderElementID(f.FileSPDXIdentifier))
}
for _, s := range f.FileType {
fmt.Fprintf(w, "FileType: %s\n", s)
}
if f.FileChecksumSHA1 != "" {
fmt.Fprintf(w, "FileChecksum: SHA1: %s\n", f.FileChecksumSHA1)
}
if f.FileChecksumSHA256 != "" {
fmt.Fprintf(w, "FileChecksum: SHA256: %s\n", f.FileChecksumSHA256)
}
if f.FileChecksumMD5 != "" {
fmt.Fprintf(w, "FileChecksum: MD5: %s\n", f.FileChecksumMD5)
}
if f.LicenseConcluded != "" {
fmt.Fprintf(w, "LicenseConcluded: %s\n", f.LicenseConcluded)
}
for _, s := range f.LicenseInfoInFile {
fmt.Fprintf(w, "LicenseInfoInFile: %s\n", s)
}
if f.LicenseComments != "" {
fmt.Fprintf(w, "LicenseComments: %s\n", f.LicenseComments)
}
if f.FileCopyrightText != "" {
fmt.Fprintf(w, "FileCopyrightText: %s\n", textify(f.FileCopyrightText))
}
for _, aop := range f.ArtifactOfProjects {
fmt.Fprintf(w, "ArtifactOfProjectName: %s\n", aop.Name)
if aop.HomePage != "" {
fmt.Fprintf(w, "ArtifactOfProjectHomePage: %s\n", aop.HomePage)
}
if aop.URI != "" {
fmt.Fprintf(w, "ArtifactOfProjectURI: %s\n", aop.URI)
}
}
if f.FileComment != "" {
fmt.Fprintf(w, "FileComment: %s\n", f.FileComment)
}
if f.FileNotice != "" {
fmt.Fprintf(w, "FileNotice: %s\n", f.FileNotice)
}
for _, s := range f.FileContributor {
fmt.Fprintf(w, "FileContributor: %s\n", s)
}
for _, s := range f.FileDependencies {
fmt.Fprintf(w, "FileDependency: %s\n", s)
}
fmt.Fprintf(w, "\n")
// also render any snippets for this file
// get slice of Snippet identifiers so we can sort them
snippetKeys := []string{}
for k := range f.Snippets {
snippetKeys = append(snippetKeys, string(k))
}
sort.Strings(snippetKeys)
for _, sID := range snippetKeys {
s := f.Snippets[spdx.ElementID(sID)]
renderSnippet2_1(s, w)
}
return nil
}
|