Initial commit: 教务系统在线平台
- 包含4个产业方向的前端项目:智能开发、智能制造、大健康、财经商贸 - 已清理node_modules、.yoyo等大文件,项目大小从2.6GB优化至631MB - 配置完善的.gitignore文件 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
61
frontend_大健康/clean_mixed_structures.py
Normal file
61
frontend_大健康/clean_mixed_structures.py
Normal file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
清理混合的数据结构,移除所有嵌套的subQuestions结构
|
||||
只保留扁平的questions结构
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
def clean_mixed_structures():
|
||||
"""清理混合结构"""
|
||||
try:
|
||||
# 读取文件
|
||||
with open('src/mocks/resumeInterviewMock.js', 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
print("开始清理混合结构...")
|
||||
|
||||
# 1. 移除所有包含subQuestions的问题组
|
||||
# 匹配从 { "id": "group_q..." 开始到对应的 } 结束的完整问题组
|
||||
content = re.sub(
|
||||
r',?\s*\{\s*"id":\s*"group_q\d+"[\s\S]*?"subQuestions":\s*\[[\s\S]*?\]\s*\}',
|
||||
'',
|
||||
content,
|
||||
flags=re.DOTALL
|
||||
)
|
||||
|
||||
# 2. 清理残留的多余逗号和空白
|
||||
content = re.sub(r',\s*,', ',', content)
|
||||
content = re.sub(r'\[\s*,', '[', content)
|
||||
content = re.sub(r',\s*\]', ']', content)
|
||||
|
||||
# 3. 修复空的questions数组
|
||||
content = re.sub(r'"questions":\s*\[\s*\]', '"questions": []', content)
|
||||
|
||||
# 4. 清理孤立的逗号和括号
|
||||
content = re.sub(r'\s*\]\s*\}\s*\]\s*\},', '\n }', content)
|
||||
|
||||
# 5. 修复岗位间的连接
|
||||
content = re.sub(r'(\s+\}\s*)\n\s+\{\s*("id":\s*"health_)', r'\1,\n {\n \2', content)
|
||||
|
||||
print("清理完成,写入文件...")
|
||||
|
||||
# 写回文件
|
||||
with open('src/mocks/resumeInterviewMock.js', 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
|
||||
print("混合结构清理完成!")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"清理失败: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
def main():
|
||||
clean_mixed_structures()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user