8000 [issue-578] remove hasFiles output from json writer · spdx/tools-python@e86e574 · GitHub
[go: up one dir, main page]

Skip to content

Commit e86e574

Browse files
[issue-578] remove hasFiles output from json writer
Signed-off-by: Armin Tänzer <armin.taenzer@tngtech.com>
1 parent 1ea3a8f commit e86e574

File tree

4 files changed

+1
-56
lines changed

4 files changed

+1
-56
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ instead of `bin`.
102102
* Note: in-place manipulations like `list.append(item)` will circumvent the type checking (a `TypeError` will still be raised when reading `list` again). We recommend using `list = list + [item]` instead.
103103
* The main entry point of an SPDX document is the `Document` class, which links to all other classes.
104104
* For license handling, the [license_expression](https://github.com/nexB/license-expression) library is used.
105-
* Note on `documentDescribes` and `hasFiles`: These fields will be converted to relationships in the internal data model. During serialization, they will be written again where appropriate.
105+
* Note on `documentDescribes` and `hasFiles`: These fields will be converted to relationships in the internal data model. As they are deprecated, these fields will not be written in the output.
106106
2. **PARSING**
107107
* Use `parse_file(file_name)` from the `parse_anything.py` module to parse an arbitrary file with one of the supported file endings.
108108
* Successful parsing will return a `Document` instance. Unsuccessful parsing will raise `SPDXParsingError` with a list of all encountered problems.

src/spdx/jsonschema/package_converter.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,6 @@ def _get_property_value(
7171
] or None
7272
elif package_property == PackageProperty.FILES_ANALYZED:
7373
return package.files_analyzed
74-
elif package_property == PackageProperty.HAS_FILES:
75-
package_contains_file_ids = [
76-
relationship.related_spdx_element_id
77-
for relationship in find_package_contains_file_relationships(document, package)
78-
]
79-
file_contained_in_package_ids = [
80-
relationship.spdx_element_id
81-
for relationship in find_file_contained_by_package_relationships(document, package)
82-
]
83-
return package_contains_file_ids + file_contained_in_package_ids or None
8474
elif package_property == PackageProperty.HOMEPAGE:
8575
return apply_if_present(str, package.homepage)
8676
elif package_property == PackageProperty.LICENSE_COMMENTS:

src/spdx/jsonschema/package_properties.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class PackageProperty(JsonProperty):
1818
DOWNLOAD_LOCATION = auto()
1919
EXTERNAL_REFS = auto()
2020
FILES_ANALYZED = auto()
21-
HAS_FILES = auto()
2221
HOMEPAGE = auto()
2322
LICENSE_COMMENTS = auto()
2423
LICENSE_CONCLUDED = auto()

tests/spdx/jsonschema/test_package_converter.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def converter(
6666
(PackageProperty.DOWNLOAD_LOCATION, "downloadLocation"),
6767
(PackageProperty.EXTERNAL_REFS, "externalRefs"),
6868
(PackageProperty.FILES_ANALYZED, "filesAnalyzed"),
69-
(PackageProperty.HAS_FILES, "hasFiles"),
7069
(PackageProperty.HOMEPAGE, "homepage"),
7170
(PackageProperty.LICENSE_COMMENTS, "licenseComments"),
7271
(PackageProperty.LICENSE_CONCLUDED, "licenseConcluded"),
@@ -230,7 +229,6 @@ def test_null_values(converter: PackageConverter):
230229
assert converter.json_property_name(PackageProperty.ATTRIBUTION_TEXTS) not in converted_dict
231230
assert converter.json_property_name(PackageProperty.CHECKSUMS) not in converted_dict
232231
assert converter.json_property_name(PackageProperty.EXTERNAL_REFS) not in converted_dict
233-
assert converter.json_property_name(PackageProperty.HAS_FILES) not in converted_dict
234232
assert converter.json_property_name(PackageProperty.LICENSE_INFO_FROM_FILES) not in converted_dict
235233

236234

@@ -314,45 +312,3 @@ def test_package_annotations(converter: PackageConverter):
314312
)
315313
converted_file_annotations = converted_dict.get(converter.json_property_name(PackageProperty.ANNOTATIONS))
316314
assert converted_file_annotations == ["mock_converted_annotation", "mock_converted_annotation"]
317-
318-
319-
def test_has_files(converter: PackageConverter):
320-
package = package_fixture()
321-
first_contained_file = file_fixture(spdx_id="firstFileId")
322-
second_contained_file = file_fixture(spdx_id="secondFileId")
323-
non_contained_file = file_fixture(spdx_id="otherFileId")
324-
snippet = snippet_fixture()
325-
document = document_fixture(
326-
packages=[package], files=[first_contained_file, second_contained_file, non_contained_file], snippets=[snippet]
327-
)
328-
package_contains_file_relationship = relationship_fixture(
329-
spdx_element_id=package.spdx_id,
330-
relationship_type=RelationshipType.CONTAINS,
331-
related_spdx_element_id=first_contained_file.spdx_id,
332-
)
333-
file_contained_in_package_relationship = relationship_fixture(
334-
spdx_element_id=second_contained_file.spdx_id,
335-
relationship_type=RelationshipType.CONTAINED_BY,
336-
related_spdx_element_id=package.spdx_id,
337-
)
338-
package_contains_snippet_relationship = relationship_fixture(
339-
spdx_element_id=package.spdx_id,
340-
relationship_type=RelationshipType.CONTAINS,
341-
related_spdx_element_id=snippet.spdx_id,
342-
)
343-
package_describes_file_relationship = relationship_fixture(
344-
spdx_element_id=package.spdx_id,
345-
relationship_type=RelationshipType.DESCRIBES,
346-
related_spdx_element_id=non_contained_file.spdx_id,
347-
)
348-
document.relationships = [
349-
package_contains_file_relationship,
350-
file_contained_in_package_relationship,
351-
package_contains_snippet_relationship,
352-
package_describes_file_relationship,
353-
]
354-
355-
converted_dict = converter.convert(package, document)
356-
357-
has_files = converted_dict.get(converter.json_property_name(PackageProperty.HAS_FILES))
358-
assert has_files == [first_contained_file.spdx_id, second_contained_file.spdx_id]

0 commit comments

Comments
 (0)
0