forked from spdx/tools-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
document.py
83 lines (74 loc) · 2.79 KB
/
document.py
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
82
83
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from dataclasses import field
from datetime import datetime
from beartype.typing import List, Optional
from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties
from spdx_tools.common.typing.type_checks import check_types_and_set_values
from spdx_tools.spdx.model import (
Actor,
Annotation,
ExternalDocumentRef,
ExtractedLicensingInfo,
File,
Package,
Relationship,
Snippet,
Version,
)
@dataclass_with_properties
class CreationInfo:
spdx_version: str
spdx_id: str
name: str
document_namespace: str
creators: List[Actor]
created: datetime
creator_comment: Optional[str] = None
data_license: str = "CC0-1.0"
external_document_refs: List[ExternalDocumentRef] = field(default_factory=list)
license_list_version: Optional[Version] = None
document_comment: Optional[str] = None
def __init__(
self,
spdx_version: str,
spdx_id: str,
name: str,
document_namespace: str,
creators: List[Actor],
created: datetime,
creator_comment: Optional[str] = None,
data_license: str = "CC0-1.0",
external_document_refs: List[ExternalDocumentRef] = None,
license_list_version: Optional[Version] = None,
document_comment: Optional[str] = None,
):
external_document_refs = [] if external_document_refs is None else external_document_refs
check_types_and_set_values(self, locals())
@dataclass_with_properties
class Document:
creation_info: CreationInfo
packages: List[Package] = field(default_factory=list)
files: List[File] = field(default_factory=list)
snippets: List[Snippet] = field(default_factory=list)
annotations: List[Annotation] = field(default_factory=list)
relationships: List[Relationship] = field(default_factory=list)
extracted_licensing_info: List[ExtractedLicensingInfo] = field(default_factory=list)
def __init__(
self,
creation_info: CreationInfo,
packages: List[Package] = None,
files: List[File] = None,
snippets: List[Snippet] = None,
annotations: List[Annotation] = None,
relationships: List[Relationship] = None,
extracted_licensing_info: List[ExtractedLicensingInfo] = None,
):
packages = [] if packages is None else packages
files = [] if files is None else files
snippets = [] if snippets is None else snippets
annotations = [] if annotations is None else annotations
relationships = [] if relationships is None else relationships
extracted_licensing_info = [] if extracted_licensing_info is None else extracted_licensing_info
check_types_and_set_values(self, locals())