spdx_tools.spdx3.model.spdx_collection

 1# SPDX-FileCopyrightText: 2023 spdx contributors
 2#
 3# SPDX-License-Identifier: Apache-2.0
 4from abc import abstractmethod
 5from dataclasses import field
 6
 7from beartype.typing import List
 8
 9from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties
10from spdx_tools.spdx3.model import Element, ExternalMap, NamespaceMap
11
12
13@dataclass_with_properties
14class ElementCollection(Element):
15    # due to the inheritance we need to make all fields non-default in the __annotation__,
16    # the __init__ method still raises an error if required fields are not set
17    element: List[str] = field(default_factory=list)
18    root_element: List[str] = field(default_factory=list)
19    namespaces: List[NamespaceMap] = field(default_factory=list)
20    imports: List[ExternalMap] = field(default_factory=list)
21
22    @abstractmethod
23    def __init__(self):
24        pass
@dataclass_with_properties
class ElementCollection(spdx_tools.spdx3.model.element.Element):
14@dataclass_with_properties
15class ElementCollection(Element):
16    # due to the inheritance we need to make all fields non-default in the __annotation__,
17    # the __init__ method still raises an error if required fields are not set
18    element: List[str] = field(default_factory=list)
19    root_element: List[str] = field(default_factory=list)
20    namespaces: List[NamespaceMap] = field(default_factory=list)
21    imports: List[ExternalMap] = field(default_factory=list)
22
23    @abstractmethod
24    def __init__(self):
25        pass
element: list[str]
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")
root_element: list[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}")
47    def get_field(self) -> field_type:
48        return getattr(self, f"_{field_name}")