(text: js_data, search: str)
| 96 | |
| 97 | |
| 98 | def search_js_reg(text: js_data, search: str) -> list[js_search_data]: |
| 99 | output = [] |
| 100 | for data in text.children: |
| 101 | if type(data) is js_data: |
| 102 | output.extend(search_js_reg(data, search)) |
| 103 | for key in range(len(text.children)): |
| 104 | data = text.children[key] |
| 105 | if type(data) is str: |
| 106 | find = re.findall(search, data) |
| 107 | for _ in range(len(find)): |
| 108 | output.append(js_search_data()) |
| 109 | output[-1].children = text.children[key] |
| 110 | output[-1].parent = text |
| 111 | if len(text.children) > key + 1: |
| 112 | output[-1].after = text.children[key + 1] |
| 113 | if len(text.children) > 0: |
| 114 | output[-1].before = text.children[key - 1] |
| 115 | output[-1].data = find |
| 116 | break |
| 117 | return output |
| 118 | |
| 119 | |
| 120 | def json_parser(text: js_data): |
no test coverage detected