读取python中Fuse的实现,未按预期返回,cat:<;mountpoint>;:地址不正确

读取python中Fuse的实现,未按预期返回,cat:<;mountpoint>;:地址不正确,python,git,filesystems,fuse,Python,Git,Filesystems,Fuse,我试图从某个存储库获取数据,并试图在存储库目录中显示任何文件的文件内容,例如,cat def read(self, path, size, offset, fh=None): file_content = '' path_ele = path.split('/') print('***[read]') print(path) if path.endswith('/') or path[1] == '.': print('ok')

我试图从某个存储库获取数据,并试图在存储库目录中显示任何文件的文件内容,例如,
cat

def read(self, path, size, offset, fh=None):
    file_content = ''
    path_ele = path.split('/')
    print('***[read]')
    print(path)
    if path.endswith('/') or path[1] == '.':
        print('ok')
        return file_content
    else:
        path = path.split('/')
        repo_name = path[-2]
        file_name = path[-1]
        print(repo_name, file_name)
        for item in self.user.get_user().get_repos():
            if item.name == repo_name:
                files = item.get_dir_contents('/')
                for file_ in files:
                    if file_name == file_.name:
                        file_content = item.get_file_contents(file_name).decoded_content
                        print(len(file_content.decode('utf-8')))
                        print(type(file_content.decode('utf-8')))
                        return file_content
当我对存储库目录中的文件执行
cat
操作时,它会给出由以下行引起的错误

assert retsize <= size, 'actual amount read %d greater than expected %d' % (retsize, size)

assert retsize您不尊重
read
的所有参数,即
size
offset
。某些程序或命令一次只能读取文件块。这意味着他们希望能够从位置y字节(
偏移量
)开始读取x字节(
大小
)。因此,您在代码截取中的主要错误是每次读取操作都返回整个文件

修复可以从一些琐碎的事情开始,比如返回
文件内容[offset:(offset+size)]
。当我说“开始”时,您必须记住,如果传递到
读取
函数的
偏移量
大小
(对于给定的
偏移量
)超出范围,您还必须提出适当的错误