pyfilesystem 可以组合模式吗?

Can pyfilesystem combine schemas?

我想结合使用 pyfilesystem 模式。例如,我想在 FTP 服务器上打开一个 tar 文件,我会做 ftp+tar://user:password@host:port/path/file.tar.gz.

不是这样,但是 TarFS 构造函数接受打开的文件。所以按照这些思路应该可以工作:

with open_fs("ftp://user:password@host:port/") as ftp_fs:
    with ftp_fs.open("path/file.tar.gz") as tar_file:
        my_tar = TarFS(tar_file)
        my_tar.tree()

我最终得到了这样的结果:

@contextmanager
def open_url(url: str,
             mode: str = "r",
             create: bool = False,
             buffering: int = -1,
             encoding: Optional[str] = None,
             errors: Optional[str] = None,
             newline: str = "",
             **options: Any,
    ) -> typing.IO:
    writeable = True if "w" in mode else False
    dir_url, file_name = os.path.split(url)
    with open_fs(dir_url, writeable, create) as fs_:
        with fs_.open(file_name, mode, buffering, encoding, errors, newline,
                      **options) as file_:
            yield file_