def get_file(self, key, file):
        if isinstance(file, str):
            try:
                f = open(file, 'wb')
            except __HOLE__ as e:
                raise IOError('Error opening %s for writing: %r' % (
                    file, e
                ))

            # file is open, now we call ourself again with a proper file
            try:
                self.get_file(key, f)
            finally:
                f.close()
        else:
            # need to use open, no way around it it seems
            # this will check the HMAC as well
            source = self.open(key)

            bufsize = 1024 * 1024

            # copy
            while True:
                buf = source.read(bufsize)
                file.write(buf)

                if len(buf) != bufsize:
                    break
dataset/ETHPy150Open mbr/simplekv/simplekv/crypt.py/HMACDecorator.get_file