forked from spdx/tools-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.py
More file actions
68 lines (60 loc) · 2.69 KB
/
file.py
File metadata and controls
68 lines (60 loc) · 2.69 KB
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
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from dataclasses import field
from enum import Enum, auto
from beartype.typing import List, Optional, Union
from license_expression import LicenseExpression
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 Checksum, SpdxNoAssertion, SpdxNone
class FileType(Enum):
SOURCE = auto()
BINARY = auto()
ARCHIVE = auto()
APPLICATION = auto()
AUDIO = auto()
IMAGE = auto()
TEXT = auto()
VIDEO = auto()
DOCUMENTATION = auto()
SPDX = auto()
OTHER = auto()
@dataclass_with_properties
class File:
name: str
spdx_id: str
checksums: List[Checksum]
file_types: List[FileType] = field(default_factory=list)
license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None
license_info_in_file: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = field(default_factory=list)
license_comment: Optional[str] = None
copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None
comment: Optional[str] = None
notice: Optional[str] = None
contributors: List[str] = field(default_factory=list)
attribution_texts: List[str] = field(default_factory=list)
# Deprecated properties that should be replaced during parsing:
# - file dependencies: replace by a DEPENDENCY_OF relationship (or one of the more precise versions)
# - artifact of (3 properties): replace by an external package reference and a GENERATED_FROM relationship
# between the file and this package
def __init__(
self,
name: str,
spdx_id: str,
checksums: List[Checksum],
file_types: List[FileType] | None = None,
license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None,
license_info_in_file: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] | None = None,
license_comment: Optional[str] = None,
copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None,
comment: str | None = None,
notice: Optional[str] = None,
contributors: List[str] | None = None,
attribution_texts: List[str] | None = None,
):
file_types = [] if file_types is None else file_types
license_info_in_file = [] if license_info_in_file is None else license_info_in_file
contributors = [] if contributors is None else contributors
attribution_texts = [] if attribution_texts is None else attribution_texts
check_types_and_set_values(self, locals())