Skip to content

Only catch FileNotFound in mapping get #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions fsspec/implementations/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MemoryFileSystem(AbstractFileSystem):
protocol = "memory"
root_marker = ""

def ls(self, path, detail=False):
def ls(self, path, detail=False, **kwargs):
if path in self.store:
# there is a key with this exact name, but could also be directory
out = [
Expand Down Expand Up @@ -127,7 +127,10 @@ def copy(self, path1, path2, **kwargs):
self.store[path2] = MemoryFile(self, path2, self.store[path1].getbuffer())

def cat(self, path):
return self.store[path].getvalue()
try:
return self.store[path].getvalue()
except KeyError:
raise FileNotFoundError(path)

def _rm(self, path):
del self.store[path]
Expand Down
6 changes: 3 additions & 3 deletions fsspec/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ def _str_to_key(self, s):

def __getitem__(self, key, default=None):
"""Retrieve data"""
key = self._key_to_str(key)
k = self._key_to_str(key)
try:
result = self.fs.cat(key)
except: # noqa: E722
result = self.fs.cat(k)
except FileNotFoundError:
if default is not None:
return default
raise KeyError(key)
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ conda_deps=
pytest
pytest-cov
fusepy==3.0.1
msgpack-python<1.0.0
deps=
hadoop-test-cluster==0.1.0

Expand Down