| #!/usr/bin/env python3 | |
| """移除 stokes_wave 所有 case controlDict 中的 line 函数""" | |
| import os, re | |
| raw = '/mnt/f/agent-workspace/paper2/Exp/data/raw/stokes_wave' | |
| fixed = 0 | |
| for d in sorted(os.listdir(raw)): | |
| if not d.startswith('t'): | |
| continue | |
| cd = os.path.join(raw, d, 'system', 'controlDict') | |
| if not os.path.isfile(cd): | |
| continue | |
| c = open(cd).read() | |
| m = re.search(r'functions\s*\{.*?\}\s*\n', c, re.DOTALL) | |
| if m: | |
| new_c = c[:m.start()] + 'functions {};\n' + c[m.end():] | |
| with open(cd, 'w') as f: | |
| f.write(new_c) | |
| fixed += 1 | |
| print(f'Fixed {fixed} controlDicts') | |