8000 [issue-503] fix: delete helper method as we don't need to distinguish… · HarshvMahawar/tools-python@8d2f497 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d2f497

Browse files
committed
[issue-503] fix: delete helper method as we don't need to distinguish cases for LicenseInfoFromFiles, LicenseInfoInFile and LicenseInfoInSnippet
Signed-off-by: Meret Behrens <meret.behrens@tngtech.com>
1 parent 44250c1 commit 8d2f497

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

src/spdx/writer/tagvalue/file_writer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from spdx.model.file import File
1414
from spdx.writer.tagvalue.checksum_writer import write_checksum_to_tag_value
15-
from spdx.writer.tagvalue.tagvalue_writer_helper_functions import write_value, write_text_value, write_license_info_list
15+
from spdx.writer.tagvalue.tagvalue_writer_helper_functions import write_value, write_text_value
1616

1717

1818
def write_file(file: File, text_output: TextIO):
@@ -28,7 +28,8 @@ def write_file(file: File, text_output: TextIO):
2828
write_value("FileChecksum", write_checksum_to_tag_value(file_checksum), text_output)
2929

3030
write_value("LicenseConcluded", file.license_concluded, text_output)
31-
write_license_info_list("LicenseInfoInFile", file.license_info_in_file, text_output)
31+
for license_info in file.license_info_in_file:
32+
write_value("LicenseInfoInFile", license_info, text_output)
3233
write_text_value("LicenseComments", file.license_comment, text_output)
3334
write_text_value("FileCopyrightText", file.copyright_text, text_output)
3435

src/spdx/writer/tagvalue/package_writer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from spdx.model.package import Package, PackageVerificationCode
1515
from spdx.writer.tagvalue.checksum_writer import write_checksum_to_tag_value
1616
f 8000 rom spdx.writer.tagvalue.tagvalue_writer_helper_functions import write_value, write_text_value, \
17-
transform_enum_name_to_tv, write_actor, write_license_info_list
17+
transform_enum_name_to_tv, write_actor
1818

1919

2020
def write_package(package: Package, text_output: TextIO):
@@ -40,7 +40,8 @@ def write_package(package: Package, text_output: TextIO):
4040
write_text_value("PackageSourceInfo", package.source_info, text_output)
4141

4242
write_value("PackageLicenseConcluded", package.license_concluded, text_output)
43-
write_license_info_list("PackageLicenseInfoFromFiles", package.license_info_from_files, text_output)
43+
for license_info in package.license_info_from_files:
44+
write_value("PackageLicenseInfoFromFiles", license_info, text_output)
4445
write_value("PackageLicenseDeclared", package.license_declared, text_output)
4546
write_text_value("PackageLicenseComments", package.license_comment, text_output)
4647
write_text_value("PackageCopyrightText", package.copyright_text, text_output)

src/spdx/writer/tagvalue/snippet_writer.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
from typing import TextIO
1212

1313
from spdx.model.snippet import Snippet
14-
from spdx.writer.tagvalue.tagvalue_writer_helper_functions import write_value, write_text_value, write_range, \
15-
write_license_info_list
16-
14+
from spdx.writer.tagvalue.tagvalue_writer_helper_functions import write_value, write_text_value, write_range
1715

1816
def write_snippet(snippet: Snippet, text_output: TextIO):
1917
text_output.write("## Snippet Information\n")
@@ -24,7 +22,8 @@ def write_snippet(snippet: Snippet, text_output: TextIO):
2422
write_range("SnippetLineRange", snippet.line_range, text_output)
2523

2624
write_value("SnippetLicenseConcluded", snippet.license_concluded, text_output)
27-
write_license_info_list("LicenseInfoInSnippet", snippet.license_info_in_snippet, text_output)
25+
for license_info in snippet.license_info_in_snippet:
26+
write_value("LicenseInfoInSnippet", license_info, text_output)
2827
write_text_value("SnippetLicenseComments", snippet.license_comment, text_output)
2928
write_text_value("SnippetCopyrightText", snippet.copyright_text, text_output)
3029

src/spdx/writer/tagvalue/tagvalue_writer_helper_functions.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ def write_list_of_elements(list_of_elements: List[Any], write_method: Callable[[
5858
write_separator(text_output)
5959

6060

61-
def write_license_info_list(tag: str, license_infos: Union[SpdxNone, SpdxNoAssertion, List[LicenseExpression]], text_output: TextIO):
62-
if isinstance(license_infos, (SpdxNone, SpdxNoAssertion)):
63-
write_value(tag, license_infos, text_output)
64-
return
65-
66-
for license_info in license_infos:
67-
write_value(tag, license_info, text_output)
68-
69-
7061
def write_actor(tag: str, element_to_write: Optional[Union[Actor, SpdxNoAssertion]], text_output: TextIO):
7162
if isinstance(element_to_write, Actor):
7263
write_value(tag, element_to_write.to_serialized_string(), text_output)

0 commit comments

Comments
 (0)
0