(parsed_list: js_data)
| 6 | |
| 7 | |
| 8 | def get_graphql(parsed_list: js_data) -> list: |
| 9 | |
| 10 | reg_graphql = "e\.graphQL\({func}\(\),$".format(func="([a-zA-Z_\$]{1,2})") |
| 11 | graphql_list = search_js_reg(parsed_list, reg_graphql) |
| 12 | graphql_output = [] |
| 13 | |
| 14 | for graphql in tqdm(graphql_list): |
| 15 | reg_func = "{func}=t.n\({arg}\)".format( |
| 16 | func=re.escape(graphql.data[0]), |
| 17 | arg="([a-zA-Z_\$]{1,2})", |
| 18 | ) |
| 19 | |
| 20 | graphql_parent = graphql.parent |
| 21 | match_func = search_js_reg(graphql_parent, reg_func) |
| 22 | while match_func == []: |
| 23 | graphql_parent = graphql_parent.parent |
| 24 | if graphql_parent == None: |
| 25 | break |
| 26 | match_func = search_js_reg(graphql_parent, reg_func) |
| 27 | |
| 28 | if match_func == []: |
| 29 | continue |
| 30 | reg_func_init = "{func}=t\({arg}\)".format( |
| 31 | func=re.escape(match_func[0].data[0]), |
| 32 | arg="([0-9]{1,5})", |
| 33 | ) |
| 34 | match_func_init = search_js_reg(graphql_parent, reg_func_init) |
| 35 | if match_func_init == []: |
| 36 | continue |
| 37 | n = match_func_init[0].data[0] |
| 38 | query = json_parser(graphql.after) |
| 39 | try: |
| 40 | query = json.loads(query) |
| 41 | except: |
| 42 | pass |
| 43 | graphql_output.append( |
| 44 | { |
| 45 | "n": n, |
| 46 | "func_name": graphql.data[0], |
| 47 | "func_name_init": match_func[0].data[0], |
| 48 | "query": query, |
| 49 | } |
| 50 | ) |
| 51 | return graphql_output |
| 52 | |
| 53 | |
| 54 | def marge_exports(parsed_list: list, graphql_output: list) -> list: |
no test coverage detected