spdx_tools.spdx.model.file
1# SPDX-FileCopyrightText: 2022 spdx contributors 2# 3# SPDX-License-Identifier: Apache-2.0 4from dataclasses import field 5from enum import Enum, auto 6 7from beartype.typing import List, Optional, Union 8from license_expression import LicenseExpression 9 10from spdx_tools.common.typing.dataclass_with_properties import dataclass_with_properties 11from spdx_tools.common.typing.type_checks import check_types_and_set_values 12from spdx_tools.spdx.model import Checksum, SpdxNoAssertion, SpdxNone 13 14 15class FileType(Enum): 16 SOURCE = auto() 17 BINARY = auto() 18 ARCHIVE = auto() 19 APPLICATION = auto() 20 AUDIO = auto() 21 IMAGE = auto() 22 TEXT = auto() 23 VIDEO = auto() 24 DOCUMENTATION = auto() 25 SPDX = auto() 26 OTHER = auto() 27 28 29@dataclass_with_properties 30class File: 31 name: str 32 spdx_id: str 33 checksums: List[Checksum] 34 file_types: List[FileType] = field(default_factory=list) 35 license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None 36 license_info_in_file: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = field(default_factory=list) 37 license_comment: Optional[str] = None 38 copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None 39 comment: Optional[str] = None 40 notice: Optional[str] = None 41 contributors: List[str] = field(default_factory=list) 42 attribution_texts: List[str] = field(default_factory=list) 43 44 # Deprecated properties that should be replaced during parsing: 45 # - file dependencies: replace by a DEPENDENCY_OF relationship (or one of the more precise versions) 46 # - artifact of (3 properties): replace by an external package reference and a GENERATED_FROM relationship 47 # between the file and this package 48 49 def __init__( 50 self, 51 name: str, 52 spdx_id: str, 53 checksums: List[Checksum], 54 file_types: List[FileType] = None, 55 license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None, 56 license_info_in_file: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None, 57 license_comment: Optional[str] = None, 58 copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None, 59 comment: str = None, 60 notice: Optional[str] = None, 61 contributors: List[str] = None, 62 attribution_texts: List[str] = None, 63 ): 64 file_types = [] if file_types is None else file_types 65 license_info_in_file = [] if license_info_in_file is None else license_info_in_file 66 contributors = [] if contributors is None else contributors 67 attribution_texts = [] if attribution_texts is None else attribution_texts 68 check_types_and_set_values(self, locals())
class
FileType(enum.Enum):
16class FileType(Enum): 17 SOURCE = auto() 18 BINARY = auto() 19 ARCHIVE = auto() 20 APPLICATION = auto() 21 AUDIO = auto() 22 IMAGE = auto() 23 TEXT = auto() 24 VIDEO = auto() 25 DOCUMENTATION = auto() 26 SPDX = auto() 27 OTHER = auto()
SOURCE =
<FileType.SOURCE: 1>
BINARY =
<FileType.BINARY: 2>
ARCHIVE =
<FileType.ARCHIVE: 3>
APPLICATION =
<FileType.APPLICATION: 4>
AUDIO =
<FileType.AUDIO: 5>
IMAGE =
<FileType.IMAGE: 6>
TEXT =
<FileType.TEXT: 7>
VIDEO =
<FileType.VIDEO: 8>
DOCUMENTATION =
<FileType.DOCUMENTATION: 9>
SPDX =
<FileType.SPDX: 10>
OTHER =
<FileType.OTHER: 11>
Inherited Members
- enum.Enum
- name
- value
@dataclass_with_properties
class
File:
30@dataclass_with_properties 31class File: 32 name: str 33 spdx_id: str 34 checksums: List[Checksum] 35 file_types: List[FileType] = field(default_factory=list) 36 license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None 37 license_info_in_file: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = field(default_factory=list) 38 license_comment: Optional[str] = None 39 copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None 40 comment: Optional[str] = None 41 notice: Optional[str] = None 42 contributors: List[str] = field(default_factory=list) 43 attribution_texts: List[str] = field(default_factory=list) 44 45 # Deprecated properties that should be replaced during parsing: 46 # - file dependencies: replace by a DEPENDENCY_OF relationship (or one of the more precise versions) 47 # - artifact of (3 properties): replace by an external package reference and a GENERATED_FROM relationship 48 # between the file and this package 49 50 def __init__( 51 self, 52 name: str, 53 spdx_id: str, 54 checksums: List[Checksum], 55 file_types: List[FileType] = None, 56 license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None, 57 license_info_in_file: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None, 58 license_comment: Optional[str] = None, 59 copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None, 60 comment: str = None, 61 notice: Optional[str] = None, 62 contributors: List[str] = None, 63 attribution_texts: List[str] = None, 64 ): 65 file_types = [] if file_types is None else file_types 66 license_info_in_file = [] if license_info_in_file is None else license_info_in_file 67 contributors = [] if contributors is None else contributors 68 attribution_texts = [] if attribution_texts is None else attribution_texts 69 check_types_and_set_values(self, locals())
File( name: str, spdx_id: str, checksums: list[spdx_tools.spdx.model.checksum.Checksum], file_types: list[FileType] = 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_file: 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: str = None, notice: Optional[str] = None, contributors: list[str] = None, attribution_texts: list[str] = None)
50 def __init__( 51 self, 52 name: str, 53 spdx_id: str, 54 checksums: List[Checksum], 55 file_types: List[FileType] = None, 56 license_concluded: Optional[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None, 57 license_info_in_file: List[Union[LicenseExpression, SpdxNoAssertion, SpdxNone]] = None, 58 license_comment: Optional[str] = None, 59 copyright_text: Optional[Union[str, SpdxNoAssertion, SpdxNone]] = None, 60 comment: str = None, 61 notice: Optional[str] = None, 62 contributors: List[str] = None, 63 attribution_texts: List[str] = None, 64 ): 65 file_types = [] if file_types is None else file_types 66 license_info_in_file = [] if license_info_in_file is None else license_info_in_file 67 contributors = [] if contributors is None else contributors 68 attribution_texts = [] if attribution_texts is None else attribution_texts 69 check_types_and_set_values(self, locals())
checksums: list[spdx_tools.spdx.model.checksum.Checksum]
file_types: list[FileType]
license_concluded: Union[boolean.boolean.Expression, spdx_tools.spdx.model.spdx_no_assertion.SpdxNoAssertion, spdx_tools.spdx.model.spdx_none.SpdxNone, NoneType]
license_info_in_file: list[typing.Union[boolean.boolean.Expression, spdx_tools.spdx.model.spdx_no_assertion.SpdxNoAssertion, spdx_tools.spdx.model.spdx_none.SpdxNone]]
copyright_text: Union[str, spdx_tools.spdx.model.spdx_no_assertion.SpdxNoAssertion, spdx_tools.spdx.model.spdx_none.SpdxNone, NoneType]