def _make_tree(root: str) -> Node: path = root[:-1] doc = DOCS.get(path) return Node( path=path, title=doc.title if doc else root, children=sorted( (_make_tree(child) for child in { root + doc.name[len(root):].split('/', 1)[0] + '/' for doc in DOCS.values() if doc.name.startswith(root) and not exclude.match(doc.name) }), key=attrgetter('title'), ), )
def _make_tree(root): path = root[:-1] doc = DOCS.get(path) return Node( path=path, title=doc.title if doc else root, children=sorted( [ _make_tree(child) for child in { root + doc.name[len(root):].split('/', 1)[0] + '/' for doc in DOCS.values() if doc.name.startswith(root) and not exclude.match(doc.name) } ], key=attrgetter('path'), ), )