blobsend/blobsend/client_base.py

47 lines
1.2 KiB
Python

class BaseChunkClient(object):
def __init__(self, chunk_size):
self.chunk_size = chunk_size
def get_hashes(self):
"""
yield a stream of hashes of file chunks. The returned format is tuples of (chunk_number, chunk_hash, )
"""
raise NotImplementedError()
def get_chunk(self, chunk_number):
"""
return a file handle from which CHUNK_SIZE bytes of data can be read
"""
raise NotImplementedError()
def put_chunk(self, chunk_number, contents):
"""
insert the data for chunk_number's position within the file, the content given by contents (which is a file-like object)
"""
raise NotImplementedError()
def get_length(self):
"""
get the file size
"""
raise NotImplementedError()
def set_length(self, length):
"""
truncate or extend the file
"""
raise NotImplementedError()
def close(self):
"""
truncate or extend the file
"""
raise NotImplementedError()
@staticmethod
def from_uri(uri, is_src):
"""
instantiate a client from the given uri
"""
raise NotImplementedError()