Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Kowalleck <[email protected]>
  • Loading branch information
jkowalleck committed Jan 17, 2025
1 parent 83aa0c2 commit 712918e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cyclonedx/model/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,7 @@ def get_pypi_url(self) -> str:
@staticmethod
def __comparable_tuple(o: 'Component') -> _ComparableTuple:
return _ComparableTuple((
o._bom_ref, # see https://github.com/CycloneDX/cyclonedx-python-lib/issues/753
o.bom_ref, # see https://github.com/CycloneDX/cyclonedx-python-lib/issues/753
o.type, o.group, o.name, o.version,
o.mime_type, o.supplier, o.author, o.publisher,
o.description, o.scope, _ComparableTuple(o.hashes),
Expand Down
21 changes: 11 additions & 10 deletions cyclonedx/model/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,25 +163,26 @@ def street_address(self) -> Optional[str]:
def street_address(self, street_address: Optional[str]) -> None:
self._street_address = street_address

@staticmethod
def __comparable_tuple(o: 'PostalAddress') -> _ComparableTuple:
return _ComparableTuple((
o.bom_ref,
o.country, o.region, o.locality, o.post_office_box_number, o.postal_code,
o.street_address
))

def __eq__(self, other: object) -> bool:
if isinstance(other, PostalAddress):
return hash(other) == hash(self)
return self.__comparable_tuple(self) == self.__comparable_tuple(other)
return False

def __lt__(self, other: Any) -> bool:
if isinstance(other, PostalAddress):
return _ComparableTuple((
self.bom_ref, self.country, self.region, self.locality, self.post_office_box_number, self.postal_code,
self.street_address
)) < _ComparableTuple((
other.bom_ref, other.country, other.region, other.locality, other.post_office_box_number,
other.postal_code, other.street_address
))
return self.__comparable_tuple(self) < self.__comparable_tuple(other)
return NotImplemented

def __hash__(self) -> int:
return hash((self.bom_ref, self.country, self.region, self.locality, self.post_office_box_number,
self.postal_code, self.street_address))
return hash(self.__comparable_tuple(self))

def __repr__(self) -> str:
return f'<PostalAddress bom-ref={self.bom_ref}, street_address={self.street_address}, country={self.country}>'
Expand Down

0 comments on commit 712918e

Please sign in to comment.