diff --git a/h5grove/content.py b/h5grove/content.py index 0d76612..459d1d6 100644 --- a/h5grove/content.py +++ b/h5grove/content.py @@ -320,8 +320,8 @@ def get_list_of_paths( names = [] - def get_path(name: str): - full_path = hdf_path_join(base_path, name) + def get_path(name: bytes): + full_path = hdf_path_join(base_path, name.decode()) content = create_content(f, full_path, resolve_links) names.append(content.path) @@ -329,7 +329,7 @@ def get_path(name: str): base_content = create_content(f, base_path, resolve_links) assert isinstance(base_content, GroupContent) names.append(base_content.path) - base_content._h5py_entity.visit(get_path) + base_content._h5py_entity.id.links.visit(get_path) yield names except NotFoundError as e: raise create_error(404, str(e)) diff --git a/test/base_test.py b/test/base_test.py index 168b41d..f8a30a5 100644 --- a/test/base_test.py +++ b/test/base_test.py @@ -412,8 +412,11 @@ def test_paths(self, server): with h5py.File(server.served_directory / filename, "w") as h5file: h5file["tree/branch/fruit"] = "apple" + h5file["tree/branch/fruit_2"] = h5py.SoftLink("fruit") h5file["tree/other_branch"] = 5 - h5file["tree_2"] = "birch" + h5file["tree_2/branch"] = h5py.SoftLink("/tree/branch") + h5file["tree_2/trunk"] = "birch" + h5file["tree_3"] = h5py.ExternalLink("test2.h5", "/another_tree") response = server.get(f"/paths/?file={filename}") retrieved_paths = decode_response(response) @@ -423,8 +426,12 @@ def test_paths(self, server): "/tree", "/tree/branch", "/tree/branch/fruit", + "/tree/branch/fruit_2", "/tree/other_branch", "/tree_2", + "/tree_2/branch", + "/tree_2/trunk", + "/tree_3", ] response = server.get(f"/paths/?file={filename}&path=/tree/branch") @@ -433,6 +440,7 @@ def test_paths(self, server): assert retrieved_paths == [ "/tree/branch", "/tree/branch/fruit", + "/tree/branch/fruit_2", ] def test_404_on_non_existing_path(self, server):