UriHolder: remove bool return values for setters/adders/removers

master
Felix Stupp 11 months ago
parent 738a362b16
commit 7d47b95aa2
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -71,30 +71,32 @@ class UriHolder:
"""Returns True if the given uri is equal to the current primary uri.""" """Returns True if the given uri is equal to the current primary uri."""
return self.primary_uri == compare_uri return self.primary_uri == compare_uri
def set_primary_uri(self, uri: str) -> bool: def set_primary_uri(self, uri: str) -> None:
"""Sets the current primary of this object. """Sets the current primary of this object.
It will also add the uri to the uri set. It will also add the uri to the uri set.
Returns True if the uri was not in the uri set before.
You may also just write the primary_uri property if you do not need the return value. You may also just write the primary_uri property.
""" """
ret = self._add_uri_to_set(uri) # might fail, so try first self._add_uri_to_set(uri) # might fail, so try first
self._set_primary_uri(uri) self._set_primary_uri(uri)
return ret
def set_as_only_uri(self, uri: str) -> None: def set_as_only_uri(self, uri: str) -> None:
self._clear_uri_set() self._clear_uri_set()
self.set_primary_uri(uri) self.set_primary_uri(uri)
def add_single_uri(self, uri: str) -> bool: def add_single_uri(self, uri: str) -> None:
return self._add_uri_to_set(uri) self._add_uri_to_set(uri)
def add_uris(self, uri_list: Iterable[Optional[str]]) -> bool: def add_uris(self, uri_list: Iterable[Optional[str]]) -> None:
return any([self.add_single_uri(uri) for uri in set(uri_list) if uri]) for uri in set(uri_list):
if uri is not None:
self.add_single_uri(uri)
def remove_single_uri(self, uri: str) -> bool: def remove_single_uri(self, uri: str) -> None:
return self._remove_uri_from_set(uri) self._remove_uri_from_set(uri)
def remove_uris(self, uri_list: Iterable[Optional[str]]) -> bool: def remove_uris(self, uri_list: Iterable[Optional[str]]) -> None:
return any([self.remove_single_uri(uri) for uri in set(uri_list) if uri]) for uri in set(uri_list):
if uri is not None:
self.remove_single_uri(uri)

Loading…
Cancel
Save