MCPcopy Create free account
hub / github.com/X-PLUG/MobileAgent / is_good_string

Function is_good_string

PC-Agent/run.py:505–518  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

503import re
504
505def is_good_string(s):
506 # Regex to match the dictionary-like part {'key1': 'value1', ...}
507 dict_pattern = r"\{('[^']+' *: *'[^']+' *(, *'[^']+' *: *'[^']+')*)?\}"
508 # Regex to match the item list part {item1, item2,...} with no single quotes in items
509 item_pattern = r"\{([a-zA-Z0-9_]+( *, *[a-zA-Z0-9_]+)*)?\}"
510
511 # Find all parts of the string contained within braces
512 parts = re.findall(r'\{.*?\}', s)
513
514 for part in parts:
515 # Check if the part matches either the dictionary pattern or item pattern
516 if not re.fullmatch(dict_pattern, part) and not re.fullmatch(item_pattern, part):
517 return False
518 return True
519
520def check_subtask_dict(subtask_dict):
521 num_subtask = len(list(subtask_dict.keys()))

Callers 1

check_subtask_dictFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected