forked from spdx/tools-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage_verification_code_converter.py
More file actions
28 lines (23 loc) · 1.24 KB
/
package_verification_code_converter.py
File metadata and controls
28 lines (23 loc) · 1.24 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
# SPDX-FileCopyrightText: 2022 spdx contributors
#
# SPDX-License-Identifier: Apache-2.0
from beartype.typing import Any, Type
from spdx_tools.spdx.jsonschema.converter import TypedConverter
from spdx_tools.spdx.jsonschema.json_property import JsonProperty
from spdx_tools.spdx.jsonschema.package_verification_code_properties import PackageVerificationCodeProperty
from spdx_tools.spdx.model import Document, PackageVerificationCode
class PackageVerificationCodeConverter(TypedConverter[PackageVerificationCode]):
def _get_property_value(
self,
verification_code: PackageVerificationCode,
verification_code_property: PackageVerificationCodeProperty,
document: Document | None = None,
) -> Any:
if verification_code_property == PackageVerificationCodeProperty.PACKAGE_VERIFICATION_CODE_EXCLUDED_FILES:
return verification_code.excluded_files or None
elif verification_code_property == PackageVerificationCodeProperty.PACKAGE_VERIFICATION_CODE_VALUE:
return verification_code.value
def get_json_type(self) -> Type[JsonProperty]:
return PackageVerificationCodeProperty
def get_data_model_type(self) -> Type[PackageVerificationCode]:
return PackageVerificationCode