MCPcopy
hub / github.com/volcengine/OpenViking / ls

Method ls

tests/test_task_tracker.py:86–103  ·  view source on GitHub ↗
(self, path: str = "/")

Source from the content-addressed store, hash-verified

84 return data[offset:]
85
86 def ls(self, path: str = "/"):
87 prefix = path.rstrip("/") or "/"
88 if prefix not in self.dirs:
89 return []
90 children = {}
91 for directory in self.dirs:
92 if directory in {prefix, "/"}:
93 continue
94 if directory.startswith(prefix + "/"):
95 name = directory[len(prefix) + 1 :].split("/", 1)[0]
96 if name:
97 children[name] = {"name": name, "path": f"{prefix}/{name}", "is_dir": True}
98 for file_path in self.files:
99 if file_path.startswith(prefix + "/"):
100 name = file_path[len(prefix) + 1 :].split("/", 1)[0]
101 if name and "/" not in file_path[len(prefix) + 1 :]:
102 children[name] = {"name": name, "path": f"{prefix}/{name}", "is_dir": False}
103 return list(children.values())
104
105
106class _FakeAgfsExistingDir(_FakeAgfs):

Callers

nothing calls this directly

Calls 1

splitMethod · 0.80

Tested by

no test coverage detected