MCPcopy Create free account
hub / github.com/THUDM/AutoWebGLM / get_anscendants

Method get_anscendants

webarena/browser_env/html_tools/html_parser.py:300–310  ·  view source on GitHub ↗
(node: html.HtmlElement, max_depth: int, current_depth: int=0)

Source from the content-addressed store, hash-verified

298 def get_keep_elements(self, tree: html.HtmlElement, keep: list[str], max_depth: int, max_children: int,
299 max_sibling: int, dfs_count: int=1, keep_parent: bool=False) -> list[str]:
300 def get_anscendants(node: html.HtmlElement, max_depth: int, current_depth: int=0) -> list[str]:
301 if current_depth > max_depth:
302 return []
303
304 anscendants = []
305 parent = node.getparent()
306 if parent is not None:
307 anscendants.append(parent)
308 anscendants.extend(get_anscendants(parent, max_depth, current_depth + 1))
309
310 return anscendants
311
312 def get_descendants(node: html.HtmlElement, max_depth: int, current_depth: int=0) -> list[str]:
313 if current_depth > max_depth:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected