From 146bb65f21e73a430edc9985a5e4de5b24ec582c Mon Sep 17 00:00:00 2001 From: Nicolaus Weidner Date: Wed, 2 Nov 2022 22:03:33 +0100 Subject: [PATCH] Review comments for ws-patches PR Signed-off-by: Nicolaus Weidner --- setup.py | 4 ++-- spdx/relationship.py | 5 ++++- spdx/writers/json.py | 14 ++++---------- spdx/writers/jsonyamlxml.py | 5 ----- spdx/writers/rdf.py | 2 +- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/setup.py b/setup.py index 02f92ae90..9b9c7961d 100755 --- a/setup.py +++ b/setup.py @@ -13,8 +13,8 @@ def test_suite(): long_description = fh.read() setup( - name='ws-spdx-tools', - version='0.7.0a3.post7', + name='spdx-tools', + version='0.7.0a3', description='SPDX parser and tools.', long_description=long_description, long_description_content_type='text/markdown', diff --git a/spdx/relationship.py b/spdx/relationship.py index dc17b34d7..da302e07b 100644 --- a/spdx/relationship.py +++ b/spdx/relationship.py @@ -83,7 +83,10 @@ def __init__(self, relationship=None, relationship_comment=None): self.relationship_comment = relationship_comment def __eq__(self, other): - return True if self.relationship == other.relationship else False + return ( + isinstance(other, Relationship) + and self.relationship == other.relationship + ) @property def has_comment(self): diff --git a/spdx/writers/json.py b/spdx/writers/json.py index c9e257d04..a2b226fdf 100644 --- a/spdx/writers/json.py +++ b/spdx/writers/json.py @@ -14,20 +14,14 @@ from spdx.writers.tagvalue import InvalidDocumentError from spdx.writers.jsonyamlxml import Writer from spdx.parsers.loggers import ErrorMessages -import numpy as np import datetime -# this method has been added by the WhiteSouse PS Team. def json_converter(obj): - if isinstance(obj, np.integer): - return int(obj) - elif isinstance(obj, np.floating): - return float(obj) - elif isinstance(obj, np.ndarray): - return obj.tolist() - elif isinstance(obj, datetime.datetime): - return obj.__str__() + if isinstance(obj, datetime.datetime): + return str(obj) + else: + raise TypeError("No implementation available to serialize objects of type " + type(obj).__name__) def write_document(document, out, validate=True): diff --git a/spdx/writers/jsonyamlxml.py b/spdx/writers/jsonyamlxml.py index f28012216..e9516325a 100644 --- a/spdx/writers/jsonyamlxml.py +++ b/spdx/writers/jsonyamlxml.py @@ -379,10 +379,6 @@ def __init__(self, document): def create_extracted_license(self): extracted_license_objects = [] - # commented by the WS PS Team - # extracted_licenses = self.document.extracted_licenses - - # filter by unique identifier attribute in ExtractedLicense object, added by the WhiteSouse PS Team unique_extracted_licenses = {} for lic in self.document.extracted_licenses: if lic.identifier not in unique_extracted_licenses.keys(): @@ -545,4 +541,3 @@ def create_document(self): self.document_object["relationships"] = self.create_relationship_info() return self.document_object - diff --git a/spdx/writers/rdf.py b/spdx/writers/rdf.py index 5e1db3572..a7fc1a9c6 100644 --- a/spdx/writers/rdf.py +++ b/spdx/writers/rdf.py @@ -570,7 +570,7 @@ def relationships(self): """ Return a list of relationship nodes """ - return list(map(self.create_relationship_node, self.document.relationships)) + return map(self.create_relationship_node, self.document.relationships) class CreationInfoWriter(BaseWriter):