1
0

switch_to_dict_literal.py 337 B

123456789
  1. import re
  2. case_pattern = re.compile(r"case\s(?P<name>[^:]*):\s*.*?new GUIContent\((?P<val>\"[^\"]*\")\);")
  3. with open("input.txt", "r", encoding="utf-8") as f:
  4. with open("result.txt", "w", encoding="utf-8") as fo:
  5. for m in case_pattern.finditer(f.read()):
  6. fo.write(f"[{m.group('name')}] = {m.group('val')},\n")