File size: 810 Bytes
63a63dd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | from abc import ABCMeta, abstractmethod
class BaseStorage:
"""Base class of backend storage"""
__metaclass__ = ABCMeta
@abstractmethod
def write(self, id, data):
"""Abstract interface of writing data
Args:
id (str): unique id of the data in the storage.
data (bytes or str): data to be stored.
"""
return
@abstractmethod
def exists(self, id):
"""Check the existence of some data
Args:
id (str): unique id of the data in the storage
Returns:
bool: whether the data exists
"""
return False
@abstractmethod
def max_file_idx(self):
"""Get the max existing file index
Returns:
int: the max index
"""
return 0
|