From dd74ed1fd8e9ddec016c186920e400a81daba1e7 Mon Sep 17 00:00:00 2001 From: feilong Date: Thu, 24 Mar 2022 18:20:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E4=BA=91=E5=8E=9F=E7=94=9F?= =?UTF-8?q?=E6=8A=80=E8=83=BD=E6=A0=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +-- src/main/main.py => data/.gitkeep | 0 data/package/.gitkeep | 0 data/package/career/java_backend.json | 20 +++++++++++ data/package/career/python_crawler.json | 19 +++++++++++ data/package/career/python_data_analyzer.json | 18 ++++++++++ data/package/career/python_ops.json | 18 ++++++++++ main.py | 5 +++ requirements.txt | 1 + src/main/package.py | 23 +++++++++++++ src/main/utils.py | 33 +++++++++++++++++++ 11 files changed, 140 insertions(+), 2 deletions(-) rename src/main/main.py => data/.gitkeep (100%) create mode 100644 data/package/.gitkeep create mode 100644 data/package/career/java_backend.json create mode 100644 data/package/career/python_crawler.json create mode 100644 data/package/career/python_data_analyzer.json create mode 100644 data/package/career/python_ops.json create mode 100644 main.py create mode 100644 src/main/package.py create mode 100644 src/main/utils.py diff --git a/README.md b/README.md index e501af4..e8a1112 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,9 @@ |[OpenCV技能树编辑仓库](https://gitcode.net/csdn/skill_tree_opencv)|[OpenCV技能树社区](https://bbs.csdn.net/skill/opencv)|✓| |[每日一题技能树编辑仓库](https://gitcode.net/csdn/skill_tree_dailycode)|[每日一练](https://dailycode.csdn.net)|✓| |[Neo4j技能树编辑仓库](https://gitcode.net/csdn/skill_tree_neo4j)|[Neo4j技能树社区](https://bbs.csdn.net/skill/neo4j)|✓| -|[云原生技能树](https://gitcode.net/csdn/skill_tree_cloud_native)| | .. | +|[云原生技能树](https://gitcode.net/csdn/skill_tree_cloud_native)|[云原生入门技能树](https://bbs.csdn.net/skill/cloud_native)|✓| |[网络技能树](https://gitcode.net/csdn/skill_tree_network)|[网络技能树社区](https://bbs.csdn.net/skill/network) | ✓初阶已上线 | +|[Vue技能树](https://gitcode.net/csdn/skill_tree_vue)| |.| |[.NET技能树](https://gitcode.net/csdn/skill_tree_dotnet)| | . | |[Rust技能树](https://gitcode.net/csdn/skill_tree_rust)| | . | |[Web技能树](https://gitcode.net/csdn/skill_tree_web)| | | @@ -39,7 +40,7 @@ |[DevOps运维技能树](https://gitcode.net/csdn/skill_tree_devops)| | | |[面向对象程序设计技能树](https://gitcode.net/csdn/skill_tree_oo)| | | |[游戏开发入门技能树](https://gitcode.net/csdn/skill_tree_game)| | | -|[Vue技能树](https://gitcode.net/csdn/skill_tree_vue)| | | + ## 技能树服务构建项目 diff --git a/src/main/main.py b/data/.gitkeep similarity index 100% rename from src/main/main.py rename to data/.gitkeep diff --git a/data/package/.gitkeep b/data/package/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/data/package/career/java_backend.json b/data/package/career/java_backend.json new file mode 100644 index 0000000..b8d3e3c --- /dev/null +++ b/data/package/career/java_backend.json @@ -0,0 +1,20 @@ +{ + "type": "career", + "name": "Java后端工程师", + "skill_trees": { + "level_0": [ + "gml", + "algorithm", + "java", + "springboot", + "mysql" + ], + "level_1": [ + "algorithm02", + "pg", + "cloud_native", + "se" + ] + }, + "package_id": "4ee897f9c6ef49f78d906cd46b813208" +} \ No newline at end of file diff --git a/data/package/career/python_crawler.json b/data/package/career/python_crawler.json new file mode 100644 index 0000000..172e51b --- /dev/null +++ b/data/package/career/python_crawler.json @@ -0,0 +1,19 @@ +{ + "type": "career", + "name": "Python爬虫工程师", + "skill_trees": { + "level_0": [ + "gml", + "python", + "algorithm", + "mysql" + ], + "level_1": [ + "python02", + "algorithm02", + "web", + "pg" + ] + }, + "package_id": "968cf8e80217499fa68d119140033e5a" +} \ No newline at end of file diff --git a/data/package/career/python_data_analyzer.json b/data/package/career/python_data_analyzer.json new file mode 100644 index 0000000..945ab7b --- /dev/null +++ b/data/package/career/python_data_analyzer.json @@ -0,0 +1,18 @@ +{ + "type": "career", + "name": "Python数据分析工程师", + "skill_trees": { + "level_0": [ + "gml", + "python", + "algorithm", + "mysql" + ], + "level_1": [ + "python02", + "algorithm02", + "pg" + ] + }, + "package_id": "900fef3acfbd450a8b342a6bbfb5145d" +} \ No newline at end of file diff --git a/data/package/career/python_ops.json b/data/package/career/python_ops.json new file mode 100644 index 0000000..58b9be1 --- /dev/null +++ b/data/package/career/python_ops.json @@ -0,0 +1,18 @@ +{ + "type": "career", + "name": "Python运维工程师", + "skill_trees": { + "level_0": [ + "gml", + "python", + "algorithm", + "mysql" + ], + "level_1": [ + "devops", + "cloud_native", + "pg" + ] + }, + "package_id": "2afef99901814988afc7624c4c59a122" +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..85878cb --- /dev/null +++ b/main.py @@ -0,0 +1,5 @@ +from src.main.package import Package + +if __name__ == '__main__': + p = Package('data/') + p.walk() diff --git a/requirements.txt b/requirements.txt index e69de29..bcc6f36 100644 --- a/requirements.txt +++ b/requirements.txt @@ -0,0 +1 @@ +uuid \ No newline at end of file diff --git a/src/main/package.py b/src/main/package.py new file mode 100644 index 0000000..2392fd6 --- /dev/null +++ b/src/main/package.py @@ -0,0 +1,23 @@ +import os +import uuid + +from src.main.utils import load_json, dump_json + + +class Package: + def __init__(self, root) -> None: + self.root = root + + def walk(self): + for base, dirs, files in os.walk(self.root): + for file_name in files: + file_full_name = os.path.join(base, file_name) + _, ext = os.path.splitext(file_name) + if ext == '.json': + pkg = load_json(file_full_name) + if pkg.get('type') == 'career': + self.visit_package(file_full_name, pkg) + + def visit_package(self, file_full_name, pkg): + pkg['package_id'] = uuid.uuid4().hex + dump_json(file_full_name, pkg, exist_ok=True, override=True) diff --git a/src/main/utils.py b/src/main/utils.py new file mode 100644 index 0000000..b554ee8 --- /dev/null +++ b/src/main/utils.py @@ -0,0 +1,33 @@ +import json +import os +import logging +import sys + +logger = logging.getLogger(__name__) +logger.setLevel(logging.INFO) +handler = logging.StreamHandler(sys.stdout) +formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') +handler.setFormatter(formatter) +logger.addHandler(handler) + + +def load_json(p): + with open(p, 'r', encoding="utf-8") as f: + try: + return json.loads(f.read()) + except UnicodeDecodeError: + logger.info( + "json 文件 [{p}] 编码错误,请确保其内容保存为 utf-8 或 base64 后的 ascii 格式。") + + +def dump_json(p, j, exist_ok=False, override=False): + if os.path.exists(p): + if exist_ok: + if not override: + return + else: + logger.error(f"{p} already exist") + sys.exit(0) + + with open(p, 'w+', encoding="utf8") as f: + f.write(json.dumps(j, indent=2, ensure_ascii=False)) -- GitLab