MCPcopy Create free account
hub / github.com/Qinbf/groundmap / flatten_sections

Function flatten_sections

scripts/section_parser.py:332–341  ·  view source on GitHub ↗

深度优先扁平化所有 sections。

(sections: list[Section])

Source from the content-addressed store, hash-verified

330
331
332def flatten_sections(sections: list[Section]) -> list[Section]:
333 """深度优先扁平化所有 sections。"""
334 out: list[Section] = []
335 def walk(s: Section):
336 out.append(s)
337 for c in s.children:
338 walk(c)
339 for s in sections:
340 walk(s)
341 return out
342
343
344def find_section_by_anchor(sections: list[Section], anchor: str) -> Optional[Section]:

Callers 2

find_section_by_anchorFunction · 0.85
find_section_by_titleFunction · 0.85

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected