filesystem_spec icon indicating copy to clipboard operation
filesystem_spec copied to clipboard

How to assemble urlpath from given fs or protocol?

Open CyberCoder-X opened this issue 3 years ago • 2 comments

Does fsspec provide any API to assemble urlpath or local path from given fs or protocol? e.g

def get_path(protocol, file_path):
    # decide which pattern to use
    # return "/xxx/xxx" or "protocol://xxx/xxx"

path1 = get_path('file', "xxx/xxx")
# path1:    /xxx/xxx
path2 = get_path('s3', "xxx/xxx")
# path2:    s3://xxx/xxx

CyberCoder-X avatar Jan 29 '22 03:01 CyberCoder-X

I think this is still an open point, see #114 and drivendataorg/cloudpathlib#96

e-roux avatar Feb 04 '22 13:02 e-roux

The function you want is fsspec.utils._unsrip_protocol, which is used internally but not documented. In #828 (which has stalled), this will be made a method on a filesystem.

martindurant avatar Feb 04 '22 13:02 martindurant