Skip to content

Commit

Permalink
Review comments for ws-patches PR
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolaus Weidner <[email protected]>
  • Loading branch information
nicoweidner committed Nov 7, 2022
1 parent 57a4672 commit 146bb65
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 4 additions & 1 deletion spdx/relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
14 changes: 4 additions & 10 deletions spdx/writers/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 0 additions & 5 deletions spdx/writers/jsonyamlxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -545,4 +541,3 @@ def create_document(self):
self.document_object["relationships"] = self.create_relationship_info()

return self.document_object

2 changes: 1 addition & 1 deletion spdx/writers/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 146bb65

Please sign in to comment.