MCPcopy Create free account
hub / github.com/FSoft-AI4Code/HyperAgent / make_tree

Method make_tree

src/hyperagent/get_repo_struct.py:31–52  ·  view source on GitHub ↗
(cls, root, parent=None, is_last=False, criteria=None)

Source from the content-addressed store, hash-verified

29
30 @classmethod
31 def make_tree(cls, root, parent=None, is_last=False, criteria=None):
32 root = Path(str(root))
33 criteria = criteria or cls._default_criteria
34
35 displayable_root = cls(root, parent, is_last)
36 yield displayable_root
37
38 children = sorted(list(path
39 for path in root.iterdir()
40 if criteria(path)),
41 key=lambda s: str(s).lower())
42 count = 1
43 for path in children:
44 is_last = count == len(children)
45 if path.is_dir():
46 yield from cls.make_tree(path,
47 parent=displayable_root,
48 is_last=is_last,
49 criteria=criteria)
50 else:
51 yield cls(path, displayable_root, is_last)
52 count += 1
53
54 @classmethod
55 def _default_criteria(cls, path):

Callers

nothing calls this directly

Calls 1

listFunction · 0.85

Tested by

no test coverage detected