chore: sync local changes (2026-03-12)
This commit is contained in:
59
mengyaprofile-backend/sort_techstack.py
Normal file
59
mengyaprofile-backend/sort_techstack.py
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
技术栈排序和更新脚本
|
||||
- 按照技术栈名称的首字母排序
|
||||
- 添加新的技术栈项
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
def sort_and_update_techstack():
|
||||
# 文件路径
|
||||
file_path = os.path.join(os.path.dirname(__file__), 'data', 'techstack.json')
|
||||
|
||||
# 读取JSON文件
|
||||
with open(file_path, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
# 新添加的技术栈项
|
||||
new_items = [
|
||||
{
|
||||
"name": "Spring",
|
||||
"icon": "https://img.shields.io/badge/-Spring-6DB33F?style=flat&logo=spring&logoColor=white",
|
||||
"link": "https://spring.io/"
|
||||
},
|
||||
{
|
||||
"name": "Gin",
|
||||
"icon": "https://img.shields.io/badge/-Gin-00ADD8?style=flat&logo=go&logoColor=white",
|
||||
"link": "https://gin-gonic.com/"
|
||||
}
|
||||
]
|
||||
|
||||
# 获取现有项的名称集合,用于检查是否已存在
|
||||
existing_names = {item['name'] for item in data['items']}
|
||||
|
||||
# 添加新项(如果不存在)
|
||||
for new_item in new_items:
|
||||
if new_item['name'] not in existing_names:
|
||||
data['items'].append(new_item)
|
||||
print(f"已添加: {new_item['name']}")
|
||||
else:
|
||||
print(f"已存在,跳过: {new_item['name']}")
|
||||
|
||||
# 按照名称的首字母排序(不区分大小写)
|
||||
data['items'].sort(key=lambda x: x['name'].upper())
|
||||
|
||||
# 写回文件,保持格式美观
|
||||
with open(file_path, 'w', encoding='utf-8') as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=2)
|
||||
|
||||
print(f"\n排序完成!共 {len(data['items'])} 个技术栈项")
|
||||
print("技术栈列表(按首字母排序):")
|
||||
for i, item in enumerate(data['items'], 1):
|
||||
print(f" {i}. {item['name']}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
sort_and_update_techstack()
|
||||
|
||||
Reference in New Issue
Block a user