Changeset View
Changeset View
Standalone View
Standalone View
swh/objstorage/multiplexer/filter/filter.py
# Copyright (C) 2015-2016 The Software Heritage developers | # Copyright (C) 2015-2016 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
from typing import Iterator | |||||
from swh.objstorage.interface import CompositeObjId | |||||
from swh.objstorage.objstorage import ObjStorage | from swh.objstorage.objstorage import ObjStorage | ||||
class ObjStorageFilter(ObjStorage): | class ObjStorageFilter(ObjStorage): | ||||
"""Base implementation of a filter that allow inputs on ObjStorage or | """Base implementation of a filter that allow inputs on ObjStorage or | ||||
not. | not. | ||||
This class copy the API of ...objstorage in order to filter the | This class copy the API of ...objstorage in order to filter the | ||||
Show All 20 Lines | def check_config(self, *, check_write): | ||||
Returns: | Returns: | ||||
True if the storage is properly configured | True if the storage is properly configured | ||||
""" | """ | ||||
return self.storage.check_config(check_write=check_write) | return self.storage.check_config(check_write=check_write) | ||||
def __contains__(self, *args, **kwargs): | def __contains__(self, *args, **kwargs): | ||||
return self.storage.__contains__(*args, **kwargs) | return self.storage.__contains__(*args, **kwargs) | ||||
def __iter__(self): | def __iter__(self) -> Iterator[CompositeObjId]: | ||||
"""Iterates over the content of each storages | """Iterates over the content of each storages | ||||
Warning: The `__iter__` methods frequently have bad performance. You | Warning: The `__iter__` methods frequently have bad performance. You | ||||
almost certainly don't want to use this method in production as the | almost certainly don't want to use this method in production as the | ||||
wrapped storage may cause performance issues. | wrapped storage may cause performance issues. | ||||
""" | """ | ||||
return self.storage.__iter__() | return self.storage.__iter__() | ||||
Show All 24 Lines |