def download(self, path, to): conn, desc = self.session.data_objects.open(path, O_RDONLY) raw = iRODSDataObjectFileRaw(conn, desc) br = BufferedRandom(raw) try: with open(to, 'w') as wf: while(True): buf = _readLargeBlock(br) if not buf: break wf.write(buf) finally: conn.release(True) br.close() return to
def read(self, path, offset, size): buf = None br = None conn = None try: conn, desc = self.session.data_objects.open(path, O_RDONLY) raw = iRODSDataObjectFileRaw(conn, desc) br = BufferedRandom(raw) new_offset = br.seek(offset) if new_offset == offset: buf = br.read(size) finally: if br: br.close() if conn: conn.release(True) return buf
def open(self, path, mode='r', errors=None): stream = self.opened.get(path) if not stream: if mode[0] == 'r': raise FileNotFoundError(path) stream = self.opened[path] = BytesIO() stream.seek(0) stream = BufferedRandom(stream) if mode[-1] == 'b' else TextIOWrapper( stream) stream.close = stream.flush return stream
def FileClose(file_handle: io.BufferedRandom) -> None: file_handle.close()