spdx_tools.spdx.model.snippet

 1# SPDX-FileCopyrightText: 2022 spdx contributors
 2#
 3# SPDX-License-Identifier: Apache-2.0
 4from dataclasses import field
 5
 6from beartype.typing import List, Optional, Tuple, Union
 7from license_expression import LicenseExpression
 8
 9from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties
10from spdx_tools.common.typing.type_checks import check_types_and_set_values
11from spdx_tools.spdx.model import SpdxNoAssertion, SpdxNone
12
13
14@dataclass_with_properties
15class Snippet:
16    spdx_id: str
17    file_spdx_id: str
18    byte_range: Tuple[int, int]
19    line_range: Optional[Tuple[int, int]] = None
20    license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None
21    license_info_in_snippet: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None
22    license_comment: Optional[str] = None
23    copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None
24    comment: Optional[str] = None
25    name: Optional[str] = None
26    attribution_texts: List[str] = field(default_factory=list)
27
28    def __init__(
29        self,
30        spdx_id: str,
31        file_spdx_id: str,
32        byte_range: Tuple[int, int],
33        line_range: Optional[Tuple[int, int]] = None,
34        license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None,
35        license_info_in_snippet: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None,
36        license_comment: Optional[str] = None,
37        copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None,
38        comment: Optional[str] = None,
39        name: Optional[str] = None,
40        attribution_texts: List[str] = None,
41    ):
42        attribution_texts = [] if attribution_texts is None else attribution_texts
43        license_info_in_snippet = [] if license_info_in_snippet is None else license_info_in_snippet
44        check_types_and_set_values(self, locals())
@dataclass_with_properties
class Snippet:
15@dataclass_with_properties
16class Snippet:
17    spdx_id: str
18    file_spdx_id: str
19    byte_range: Tuple[int, int]
20    line_range: Optional[Tuple[int, int]] = None
21    license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None
22    license_info_in_snippet: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None
23    license_comment: Optional[str] = None
24    copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None
25    comment: Optional[str] = None
26    name: Optional[str] = None
27    attribution_texts: List[str] = field(default_factory=list)
28
29    def __init__(
30        self,
31        spdx_id: str,
32        file_spdx_id: str,
33        byte_range: Tuple[int, int],
34        line_range: Optional[Tuple[int, int]] = None,
35        license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None,
36        license_info_in_snippet: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None,
37        license_comment: Optional[str] = None,
38        copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None,
39        comment: Optional[str] = None,
40        name: Optional[str] = None,
41        attribution_texts: List[str] = None,
42    ):
43        attribution_texts = [] if attribution_texts is None else attribution_texts
44        license_info_in_snippet = [] if license_info_in_snippet is None else license_info_in_snippet
45        check_types_and_set_values(self, locals())
Snippet( spdx_id: str, file_spdx_id: str, byte_range: tuple[int, int], line_range: Optional[tuple[int, int]] = None, license_concluded: Union[boolean.boolean.Expression, spdx_tools.spdx.model.spdx_no_assertion.SpdxNoAssertion, spdx_tools.spdx.model.spdx_none.SpdxNone, NoneType] = None, license_info_in_snippet: list[typing.Union[boolean.boolean.Expression, spdx_tools.spdx.model.spdx_no_assertion.SpdxNoAssertion, spdx_tools.spdx.model.spdx_none.SpdxNone]] = None, license_comment: Optional[str] = None, copyright_text: Union[str, spdx_tools.spdx.model.spdx_no_assertion.SpdxNoAssertion, spdx_tools.spdx.model.spdx_none.SpdxNone, NoneType] = None, comment: Optional[str] = None, name: Optional[str] = None, attribution_texts: list[str] = None)
29    def __init__(
30        self,
31        spdx_id: str,
32        file_spdx_id: str,
33        byte_range: Tuple[int, int],
34        line_range: Optional[Tuple[int, int]] = None,
35        license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None,
36        license_info_in_snippet: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None,
37        license_comment: Optional[str] = None,
38        copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None,
39        comment: Optional[str] = None,
40        name: Optional[str] = None,
41        attribution_texts: List[str] = None,
42    ):
43        attribution_texts = [] if attribution_texts is None else attribution_texts
44        license_info_in_snippet = [] if license_info_in_snippet is None else license_info_in_snippet
45        check_types_and_set_values(self, locals())
spdx_id: str
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")
file_spdx_id: str
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")
byte_range: tuple[int, int]
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")
line_range: Optional[tuple[int, int]]
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")
license_concluded: Union[boolean.boolean.Expression, spdx_tools.spdx.model.spdx_no_assertion.SpdxNoAssertion, spdx_tools.spdx.model.spdx_none.SpdxNone, NoneType]
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")
license_info_in_snippet: list[typing.Union[boolean.boolean.Expression, spdx_tools.spdx.model.spdx_no_assertion.SpdxNoAssertion, spdx_tools.spdx.model.spdx_none.SpdxNone]]
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")
license_comment: Optional[str]
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")
comment: Optional[str]
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")
name: Optional[str]
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")
attribution_texts: list[str]
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")