| 918 | |
| 919 | |
| 920 | def parse_string(input_string, value_format_fn=None): |
| 921 | matches = {} |
| 922 | pattern = r"(\w+):\s*((?:(?!\n\w+:).)*)" |
| 923 | regex = re.compile(pattern) |
| 924 | for match in regex.finditer(input_string): |
| 925 | key, value = match.group(1).strip(), match.group(2).strip() |
| 926 | try: |
| 927 | value = value_format_fn(value) if value_format_fn else value |
| 928 | json_value = json.loads(value) |
| 929 | matches[key] = json_value |
| 930 | except: |
| 931 | matches[key] = value |
| 932 | return matches |
| 933 | |
| 934 | |
| 935 | def parse_body(body, content_type, value_format_fn=None): |