Skip to content

Commit db943b8

Browse files
committed
Clarify behavior of list/get on files/directories
1 parent 1b63db5 commit db943b8

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

contextshell/backends/FilesystemTree.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def contains_action(self, target: NodePath, path: NodePath) -> bool:
2929
def get_action(self, target: NodePath):
3030
full_path = self._to_os_path(target)
3131
if full_path.is_dir():
32-
raise NotSupportedError("Operation not defined for directories")
32+
return None
3333
return full_path.read_text()
3434

3535
def is_file_action(self, target: NodePath) -> bool:
@@ -43,7 +43,7 @@ def is_directory_action(self, target: NodePath) -> bool:
4343
def list_action(self, target: NodePath) -> List[NodePath]:
4444
dir_path = self._to_os_path(target)
4545
if not dir_path.is_dir():
46-
raise NotSupportedError("Operation not defined for files")
46+
return []
4747
return list(sorted([NodePath(f.name) for f in dir_path.iterdir()]))
4848

4949
def list_actions_action(self, target: NodePath) -> List[NodePath]:

tests/functional/FilesystemTests.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ def test_get_file_contents(self):
9393
def test_get_directory_contents(self):
9494
"""
9595
$ .dir: get
96-
NotSupportedError: Operation not defined for directories
9796
"""
9897

9998

@@ -147,7 +146,6 @@ def test_nested(self):
147146
def test_file(self):
148147
"""
149148
$ .file: list
150-
NotSupportedError: Operation not defined for files
151149
"""
152150

153151
@script_test

0 commit comments

Comments
 (0)