-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
As far as I understand it, this package cannot be used with universal pathlib right away, but all the building block are already there. All that's missing is registering the AbstractFileSystem subclasses with fsspec and creating fsspec/universal_pathlib subclasses and registering them with their registry.
This seems simple enough and seems to work in my testing:
from fsspec import AbstractFileSystem
from upath import UPath
from upath.registry import register_implementation
from morefs.memory import MemFS
# local instance for inspectability during testing
mem_fs = MemFS()
class MorefsMemPath(UPath):
@classmethod
def _fs_factory(
cls, urlpath: str, protocol: str, storage_options: dict
) -> AbstractFileSystem:
return mem_fs # this should be MemFS(...)
fsname = "customfs"
register_implementation(fsname, MorefsMemPath)
def test_upath():
testtext = "Hello from MemFS!"
testfile = "/example.txt"
p = UPath(f"{fsname}:///{testfile}")
p.write_text(testtext)
assert testtext == p.read_text()
assert mem_fs.ls("/") == [testfile]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels