diff --git a/fsspec/caching.py b/fsspec/caching.py index 5a9f75be8..e38782780 100644 --- a/fsspec/caching.py +++ b/fsspec/caching.py @@ -370,6 +370,16 @@ def __len__(self): return len(self.cache) +class AllBytes(object): + """Cache entire contents of the file""" + + def __init__(self, data): + self.data = data + + def _fetch(self, start, end): + return self.data[start:end] + + caches = { "none": BaseCache, "mmap": MMapCache, diff --git a/fsspec/implementations/http.py b/fsspec/implementations/http.py index d3ef0a638..75fbff0b6 100644 --- a/fsspec/implementations/http.py +++ b/fsspec/implementations/http.py @@ -6,6 +6,7 @@ from fsspec import AbstractFileSystem from fsspec.spec import AbstractBufferedFile from fsspec.utils import tokenize, DEFAULT_BLOCK_SIZE +from ..caching import AllBytes # https://stackoverflow.com/a/15926317/3821154 ex = re.compile(r"""]*?\s+)?href=(["'])(.*?)\1""") @@ -359,13 +360,3 @@ def file_size(url, session=None, size_policy="head", **kwargs): return int(r.headers["Content-Length"]) elif "Content-Range" in r.headers: return int(r.headers["Content-Range"].split("/")[1]) - - -class AllBytes(object): - """Cache entire contents of a remote URL""" - - def __init__(self, data): - self.data = data - - def _fetch(self, start, end): - return self.data[start:end] diff --git a/fsspec/registry.py b/fsspec/registry.py index 1536668e1..3f401061c 100644 --- a/fsspec/registry.py +++ b/fsspec/registry.py @@ -12,6 +12,13 @@ known_implementations = { "file": {"class": "fsspec.implementations.local.LocalFileSystem"}, "memory": {"class": "fsspec.implementations.memory.MemoryFileSystem"}, + "dropbox": { + "class": "dropboxdrivefs.DropboxDriveFileSystem", + "err": ( + 'DropboxFileSystem requires "dropboxdrivefs",' + '"requests" and "dropbox" to be installed' + ), + }, "http": { "class": "fsspec.implementations.http.HTTPFileSystem", "err": 'HTTPFileSystem requires "requests" to be installed',