Skip to content

Commit c325a40

Browse files
authored
Merge pull request #207 from MarineChap/dropbox_implementation
Dropbox implementation + add existing implementation in the registry
2 parents 526286f + 5577251 commit c325a40

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

fsspec/caching.py

+10
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,16 @@ def __len__(self):
370370
return len(self.cache)
371371

372372

373+
class AllBytes(object):
374+
"""Cache entire contents of the file"""
375+
376+
def __init__(self, data):
377+
self.data = data
378+
379+
def _fetch(self, start, end):
380+
return self.data[start:end]
381+
382+
373383
caches = {
374384
"none": BaseCache,
375385
"mmap": MMapCache,

fsspec/implementations/http.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from fsspec import AbstractFileSystem
77
from fsspec.spec import AbstractBufferedFile
88
from fsspec.utils import tokenize, DEFAULT_BLOCK_SIZE
9+
from ..caching import AllBytes
910

1011
# https://stackoverflow.com/a/15926317/3821154
1112
ex = re.compile(r"""<a\s+(?:[^>]*?\s+)?href=(["'])(.*?)\1""")
@@ -359,13 +360,3 @@ def file_size(url, session=None, size_policy="head", **kwargs):
359360
return int(r.headers["Content-Length"])
360361
elif "Content-Range" in r.headers:
361362
return int(r.headers["Content-Range"].split("/")[1])
362-
363-
364-
class AllBytes(object):
365-
"""Cache entire contents of a remote URL"""
366-
367-
def __init__(self, data):
368-
self.data = data
369-
370-
def _fetch(self, start, end):
371-
return self.data[start:end]

fsspec/registry.py

+7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
known_implementations = {
1313
"file": {"class": "fsspec.implementations.local.LocalFileSystem"},
1414
"memory": {"class": "fsspec.implementations.memory.MemoryFileSystem"},
15+
"dropbox": {
16+
"class": "dropboxdrivefs.DropboxDriveFileSystem",
17+
"err": (
18+
'DropboxFileSystem requires "dropboxdrivefs",'
19+
'"requests" and "dropbox" to be installed'
20+
),
21+
},
1522
"http": {
1623
"class": "fsspec.implementations.http.HTTPFileSystem",
1724
"err": 'HTTPFileSystem requires "requests" to be installed',

0 commit comments

Comments
 (0)