Skip to content

Commit d80034e

Browse files
author
Martin Durant
committed
Add test and other fixes
1 parent f6c9f61 commit d80034e

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

fsspec/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ def get_fs_token_paths(
400400
if "w" in mode:
401401
paths = _expand_paths(path, name_function, num)
402402
elif "*" in path:
403-
paths = sorted(fs.glob(path))
403+
paths = [f for f in sorted(fs.glob(path))
404+
if not fs.isdir(f)]
404405
else:
405406
paths = [path]
406407

fsspec/implementations/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def ls(self, url, detail=True):
107107
return list(sorted(out))
108108

109109
def cat(self, url):
110-
r = requests.get(url, **self.kwargs)
110+
r = self.session.get(url, **self.kwargs)
111111
r.raise_for_status()
112112
return r.content
113113

fsspec/implementations/tests/test_cached.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def local_filecache():
2424
"filecache", target_protocol="file", cache_storage=cache_location
2525
)
2626

27-
return (data, original_file, cache_location, fs)
27+
return data, original_file, cache_location, fs
2828

2929

3030
def test_idempotent():
@@ -59,6 +59,22 @@ def test_workflow(ftp_writable):
5959
assert fs.cat("/out") == b"test" # old value
6060

6161

62+
def test_glob(ftp_writable):
63+
host, port, user, pw = ftp_writable
64+
fs = FTPFileSystem(host, port, user, pw)
65+
with fs.open("/out", "wb") as f:
66+
f.write(b"test")
67+
with fs.open("/out2", "wb") as f:
68+
f.write(b"test2")
69+
fs = fsspec.filesystem(
70+
"cached",
71+
target_protocol="ftp",
72+
target_options={"host": host, "port": port, "username": user, "password": pw},
73+
)
74+
assert fs.glob('/wrong*') == []
75+
assert fs.glob('/ou*') == ['/out', '/out2']
76+
77+
6278
def test_blocksize(ftp_writable):
6379
host, port, user, pw = ftp_writable
6480
fs = FTPFileSystem(host, port, user, pw)

fsspec/registry.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@
6969
"class": "fsspec.implementations.dask.DaskWorkerFileSystem",
7070
"err": "Install dask distributed to access worker file system",
7171
},
72+
"github": {
73+
"class": "fsspec.implementations.github.GithubFileSystem",
74+
"err": "Install the requests to use the github FS"
75+
}
7276
}
7377

7478
minversions = {"s3fs": LooseVersion("0.3.0"), "gcsfs": LooseVersion("0.3.0")}

fsspec/transaction.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
2727

2828
def start(self):
2929
"""Start a transaction on this FileSystem"""
30+
self.files = [] # clean up after previous failed completions
3031
self.fs._intrans = True
3132

3233
def complete(self, commit=True):

0 commit comments

Comments
 (0)