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

Function print_html_object

webarena/browser_env/html_tools/utils.py:51–91  ·  view source on GitHub ↗
(obj: str='')

Source from the content-addressed store, hash-verified

49 return temp_id, i2xpath, used_labels
50
51def print_html_object(obj: str='') -> str:
52 tab_cnt = 0
53 result, content, sep = '', '', ''
54 last_is_left, last_is_right = False, False
55 for ch in obj:
56 if ch == '<':
57 result += '\n'
58 if len(content.strip()) > 0:
59 result += sep + content.strip() + '\n'
60 result += sep + '<'
61
62 tab_cnt += 1
63 sep = ' ' * tab_cnt
64
65 content = ''
66 last_is_right = False
67 last_is_left = True
68 elif ch == '>':
69 if last_is_left:
70 result += content
71 else:
72 if last_is_right:
73 result += '\n'
74 if len(content.strip()) > 0:
75 result += sep + content.strip() + '\n'
76
77 tab_cnt -= 1
78 sep = ' ' * tab_cnt
79
80 if not last_is_left:
81 result += sep
82
83 result += '>'
84 content = ''
85
86 last_is_right = True
87 last_is_left = False
88 else:
89 content += ch
90
91 return result
92
93def rect2tuple(rect: str) -> tuple[int, int, int, int]:
94 if rect is None or type(rect) != type('str'):

Callers 1

parse_my_htmlMethod · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected