filesystem_spec
filesystem_spec copied to clipboard
How to assemble urlpath from given fs or protocol?
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
I think this is still an open point, see #114 and drivendataorg/cloudpathlib#96
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.