- 包含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>
137 lines
4.1 KiB
Python
137 lines
4.1 KiB
Python
#!/usr/bin/env python3
|
||
# -*- coding: utf-8 -*-
|
||
|
||
import re
|
||
from datetime import datetime
|
||
|
||
def create_backup(file_path):
|
||
"""创建备份文件"""
|
||
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||
backup_path = f"{file_path}.backup_{timestamp}"
|
||
with open(file_path, 'r', encoding='utf-8') as f:
|
||
content = f.read()
|
||
with open(backup_path, 'w', encoding='utf-8') as f:
|
||
f.write(content)
|
||
print(f"已创建备份: {backup_path}")
|
||
return backup_path
|
||
|
||
def remove_unmodified_positions():
|
||
"""删除没有真实修改版的岗位的modified字段"""
|
||
|
||
# 有真实修改版的岗位列表(这些要保留modified)
|
||
real_modified_positions = {
|
||
"会展策划师",
|
||
"会展执行助理",
|
||
"会展讲解员",
|
||
"活动策划师",
|
||
"活动执行",
|
||
"漫展策划师",
|
||
"旅游规划师",
|
||
"旅游计调专员",
|
||
"景区运营专员",
|
||
"文旅运营总监助理"
|
||
}
|
||
|
||
file_path = 'src/mocks/resumeInterviewMock.js'
|
||
|
||
# 创建备份
|
||
create_backup(file_path)
|
||
|
||
# 读取文件内容
|
||
with open(file_path, 'r', encoding='utf-8') as f:
|
||
content = f.read()
|
||
|
||
# 查找所有包含position和content的代码块
|
||
# 匹配从position到整个content对象的模式
|
||
pattern = r'(position:\s*"([^"]+)"[^{]*?content:\s*\{[^}]*?)(,?\s*modified:\s*`[^`]*?`)([^}]*?\})'
|
||
|
||
modified_count = 0
|
||
kept_count = 0
|
||
|
||
def process_match(match):
|
||
nonlocal modified_count, kept_count
|
||
before_modified = match.group(1)
|
||
position_name = match.group(2)
|
||
modified_part = match.group(3)
|
||
after_modified = match.group(4)
|
||
|
||
# 如果是有真实修改版的岗位,保持不变
|
||
if position_name in real_modified_positions:
|
||
kept_count += 1
|
||
print(f"✓ 保留 {position_name} 的modified字段")
|
||
return match.group(0)
|
||
|
||
# 否则,删除modified字段
|
||
modified_count += 1
|
||
print(f"✗ 删除 {position_name} 的modified字段")
|
||
# 返回没有modified部分的内容
|
||
return before_modified + after_modified
|
||
|
||
# 执行替换
|
||
new_content = re.sub(pattern, process_match, content, flags=re.DOTALL)
|
||
|
||
# 保存文件
|
||
with open(file_path, 'w', encoding='utf-8') as f:
|
||
f.write(new_content)
|
||
|
||
print(f"\n处理完成!")
|
||
print(f"- 删除了 {modified_count} 个岗位的modified字段")
|
||
print(f"- 保留了 {kept_count} 个岗位的modified字段")
|
||
|
||
def verify_results():
|
||
"""验证处理结果"""
|
||
file_path = 'src/mocks/resumeInterviewMock.js'
|
||
|
||
with open(file_path, 'r', encoding='utf-8') as f:
|
||
content = f.read()
|
||
|
||
# 统计所有有modified字段的岗位
|
||
pattern = r'position:\s*"([^"]+)"[^}]*?modified:\s*`'
|
||
matches = re.findall(pattern, content, re.DOTALL)
|
||
|
||
print("\n验证结果:")
|
||
print("=" * 50)
|
||
print(f"还有modified字段的岗位(共{len(set(matches))}个):")
|
||
|
||
unique_positions = set(matches)
|
||
for position in sorted(unique_positions):
|
||
print(f" - {position}")
|
||
|
||
# 期望的岗位列表
|
||
expected = {
|
||
"会展策划师",
|
||
"会展执行助理",
|
||
"会展讲解员",
|
||
"活动策划师",
|
||
"活动执行",
|
||
"漫展策划师",
|
||
"旅游规划师",
|
||
"旅游计调专员",
|
||
"景区运营专员",
|
||
"文旅运营总监助理"
|
||
}
|
||
|
||
# 检查是否匹配
|
||
if unique_positions == expected:
|
||
print("\n✓ 完美!所有岗位的modified字段都处理正确")
|
||
else:
|
||
missing = expected - unique_positions
|
||
extra = unique_positions - expected
|
||
|
||
if missing:
|
||
print(f"\n⚠️ 缺少modified的岗位:{missing}")
|
||
if extra:
|
||
print(f"\n⚠️ 不应该有modified的岗位:{extra}")
|
||
|
||
def main():
|
||
print("开始处理没有真实修改版的岗位...")
|
||
print("=" * 50)
|
||
|
||
# 删除没有真实修改版的岗位的modified字段
|
||
remove_unmodified_positions()
|
||
|
||
# 验证结果
|
||
verify_results()
|
||
|
||
if __name__ == "__main__":
|
||
main() |