forked from spdx/tools-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnippet.py
More file actions
44 lines (39 loc) · 1.87 KB
/
snippet.py
File metadata and controls
44 lines (39 loc) · 1.87 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
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from dataclasses import field
from beartype.typing import List, Optional, Tuple, 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 SpdxNoAssertion, SpdxNone
@dataclass_with_properties
class Snippet:
spdx_id: str
file_spdx_id: str
byte_range: Tuple[int, int]
line_range: Optional[Tuple[int, int]] = None
license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None
license_info_in_snippet: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None
license_comment: Optional[str] = None
copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None
comment: Optional[str] = None
name: Optional[str] = None
attribution_texts: List[str] = field(default_factory=list)
def __init__(
self,
spdx_id: str,
file_spdx_id: str,
byte_range: Tuple[int, int],
line_range: Optional[Tuple[int, int]] = None,
license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None,
license_info_in_snippet: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] | None = None,
license_comment: Optional[str] = None,
copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None,
comment: Optional[str] = None,
name: Optional[str] = None,
attribution_texts: List[str] | None = None,
):
attribution_texts = [] if attribution_texts is None else attribution_texts
license_info_in_snippet = [] if license_info_in_snippet is None else license_info_in_snippet
check_types_and_set_values(self, locals())