From e44e4d132c2d8fd4f973fc4d4dfd9d231bdfe3d8 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Thu, 14 Dec 2023 10:13:51 +0800 Subject: [PATCH] Commented out unused code in label.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 我的问题( Update label.yml to install dependencies using pip Update git clone URL for python-packs repository Fix git clone URL in label.yml workflow Add ls commands to debug dependency installation Update directory paths in label.yml Update label generation script Add ls commands to label.yml workflow Add ls command to display file details Remove unnecessary code in label.yml Update label.yml and add requirement.txt 不管了! build? mkdir added --- .gitea/workflows/label.yml | 52 +++++++++++++++----------- .gitignore | 4 ++ modules/10/10.litematic | 3 -- modules/10/10.schem | 3 -- modules/10/10_bottom.nbt | 3 -- modules/10/10_top.nbt | 3 -- modules/11/11.litematic | 3 -- modules/11/11.schem | 3 -- modules/11/11_bottom.nbt | 3 -- modules/11/11_top.nbt | 3 -- modules/12/12.litematic | 3 -- modules/12/12.nbt | 3 -- modules/12/12.schem | 3 -- modules/13/13.litematic | 3 -- modules/13/13.schem | 3 -- modules/13/13_bottom.nbt | 3 -- modules/13/13_top.nbt | 3 -- modules/15/15.litematic | 3 -- modules/15/15.nbt | 3 -- modules/15/15.schem | 3 -- modules/8/8.litematic | 3 -- modules/8/8.schem | 3 -- modules/8/8_bottom.nbt | 3 -- modules/8/8_top.nbt | 3 -- scripts/parse-label.py | 76 +++++++++++++++++++++++++++++--------- scripts/requirement.txt | 3 ++ 26 files changed, 96 insertions(+), 105 deletions(-) create mode 100644 .gitignore delete mode 100644 modules/10/10.litematic delete mode 100644 modules/10/10.schem delete mode 100644 modules/10/10_bottom.nbt delete mode 100644 modules/10/10_top.nbt delete mode 100644 modules/11/11.litematic delete mode 100644 modules/11/11.schem delete mode 100644 modules/11/11_bottom.nbt delete mode 100644 modules/11/11_top.nbt delete mode 100644 modules/12/12.litematic delete mode 100644 modules/12/12.nbt delete mode 100644 modules/12/12.schem delete mode 100644 modules/13/13.litematic delete mode 100644 modules/13/13.schem delete mode 100644 modules/13/13_bottom.nbt delete mode 100644 modules/13/13_top.nbt delete mode 100644 modules/15/15.litematic delete mode 100644 modules/15/15.nbt delete mode 100644 modules/15/15.schem delete mode 100644 modules/8/8.litematic delete mode 100644 modules/8/8.schem delete mode 100644 modules/8/8_bottom.nbt delete mode 100644 modules/8/8_top.nbt create mode 100644 scripts/requirement.txt diff --git a/.gitea/workflows/label.yml b/.gitea/workflows/label.yml index 8d43bb9..2afeb46 100644 --- a/.gitea/workflows/label.yml +++ b/.gitea/workflows/label.yml @@ -2,10 +2,9 @@ name: 自动生成 label # main 分支推送 on: - [push] - # push: - # branches: - # - main + push: + branches: + - main jobs: Generate-label: @@ -13,31 +12,42 @@ jobs: steps: - name: 获取仓库 uses: http://shenjack.top:5100/gitea-server/checkout@v4 - with: - path: main - - # - name: ensure pip - # uses: http://shenjack.top:5100/gitea-server/python-packs@1cd32b1235ba23d51524b6870c0735f63efcffc2 - - name: ensurepip - uses: http://shenjack.top:5100/gitea-server/checkout@v4 - with: - repository: gitea-server/python-packs - with: - path: python-packs + - name: pip + run: | + cd .. + git clone http://shenjack.top:5100/gitea-server/python-packs.git + cd python-packs + python3 -m ensurepip + cd ../ARS-docs - name: 安装依赖 run: | - ls -la . - ls -la .. - ls -la ../.. - python3 -m ../python-packs/ensurepip python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple python3 -m pip install -U pip - python3 -m pip install mistune + python3 -m pip install -U -r scripts/requirement.txt + ls . -la + ls scripts - name: 生成 label run: | - python3 generate_label.py + python3 scripts/parse-label.py + + - name: 检查是否有改动 + run: | + git config user.name gitea-actions + git config user.email gitea-action@shenjack.top + if [ -n "$(git status --porcelain)" ]; then + git add . + git commit -m "gen by python script" + # 创建并切换到deploy分支 + git checkout -b deploy + # 将更改添加到deploy分支的最新提交 + git commit --amend --no-edit + # 推送到deploy分支 + git push origin HEAD --force + else + echo "工作区没有改动" + fi # https://gitea.com/actions/gitea-release-action diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..59088f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +venv +env +*__pycache__* +build \ No newline at end of file diff --git a/modules/10/10.litematic b/modules/10/10.litematic deleted file mode 100644 index 2a44368..0000000 --- a/modules/10/10.litematic +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f47c635221913891af353c5ffb1282fdab8040d0d19ece72a0271f5dacafc0f5 -size 10125 diff --git a/modules/10/10.schem b/modules/10/10.schem deleted file mode 100644 index 3a23535..0000000 --- a/modules/10/10.schem +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:41e7055e133c7b299ffcf2c1c9deea59258ddcf903df81aeee19eaee70652063 -size 10031 diff --git a/modules/10/10_bottom.nbt b/modules/10/10_bottom.nbt deleted file mode 100644 index 0142d2b..0000000 --- a/modules/10/10_bottom.nbt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:da0f69741e6a6ff7f9804a502ae771fbf6fc93f8025e6400835215599870d36a -size 23841 diff --git a/modules/10/10_top.nbt b/modules/10/10_top.nbt deleted file mode 100644 index 1ceba7d..0000000 --- a/modules/10/10_top.nbt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1097d8ac9662ffe9f8bdb8738072b69296ad028a7c89a167858fb076322a8979 -size 86 diff --git a/modules/11/11.litematic b/modules/11/11.litematic deleted file mode 100644 index 21b2e0c..0000000 --- a/modules/11/11.litematic +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:601cfbbf97ae6bb2d6d175f9fc0336b1eefdbd09952313fce4356a56d293fb50 -size 13276 diff --git a/modules/11/11.schem b/modules/11/11.schem deleted file mode 100644 index 64a3f2a..0000000 --- a/modules/11/11.schem +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5f360fe68055a475b72b955d3837cb0a4346dfff918f50250d0a014f4cfed103 -size 11832 diff --git a/modules/11/11_bottom.nbt b/modules/11/11_bottom.nbt deleted file mode 100644 index c4d970c..0000000 --- a/modules/11/11_bottom.nbt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bb602b483a4aeef696a01da8575f4d57ab849e5844519e5cda6ab2df38882546 -size 38638 diff --git a/modules/11/11_top.nbt b/modules/11/11_top.nbt deleted file mode 100644 index f00b68e..0000000 --- a/modules/11/11_top.nbt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:649557ccb7d795b9a7866e47c693d1f1437ed138a05916651cab818e7377251a -size 83640 diff --git a/modules/12/12.litematic b/modules/12/12.litematic deleted file mode 100644 index 207e7dd..0000000 --- a/modules/12/12.litematic +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6c7b521439dbae44dcc27829af089c26aa13ab88c76c7a7a0e525384d0657060 -size 6078 diff --git a/modules/12/12.nbt b/modules/12/12.nbt deleted file mode 100644 index 45462c3..0000000 --- a/modules/12/12.nbt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2435ed3f325fe210b713eca63a65411a21325c0a18aebd02868f09b6049f758b -size 26266 diff --git a/modules/12/12.schem b/modules/12/12.schem deleted file mode 100644 index 64ce5a2..0000000 --- a/modules/12/12.schem +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5855cdf6f1c38060495a57ca54fbd8b188d483c85b3abf764d39d2c93dc7890b -size 5859 diff --git a/modules/13/13.litematic b/modules/13/13.litematic deleted file mode 100644 index 3d74c38..0000000 --- a/modules/13/13.litematic +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d72759bf482de5e96cdeff5e4d7f80a9b475757c5779c4834879c929291e8e66 -size 7784 diff --git a/modules/13/13.schem b/modules/13/13.schem deleted file mode 100644 index 1c83b32..0000000 --- a/modules/13/13.schem +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:27a9c829b744420d1b6304ae4df0e18b7731be68a954a687ca5bed27c587271d -size 691 diff --git a/modules/13/13_bottom.nbt b/modules/13/13_bottom.nbt deleted file mode 100644 index 2e24185..0000000 --- a/modules/13/13_bottom.nbt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6af674c5531515ab68bff3b81ebae900642441578a7b4d2a13215b4c0f7c7786 -size 16281 diff --git a/modules/13/13_top.nbt b/modules/13/13_top.nbt deleted file mode 100644 index 1ceba7d..0000000 --- a/modules/13/13_top.nbt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1097d8ac9662ffe9f8bdb8738072b69296ad028a7c89a167858fb076322a8979 -size 86 diff --git a/modules/15/15.litematic b/modules/15/15.litematic deleted file mode 100644 index 0ab21dd..0000000 --- a/modules/15/15.litematic +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9a8b49117bae9d2f4294f9fec6e1c3ffe099631bd9ffc751920e7b2855fcc49a -size 1267 diff --git a/modules/15/15.nbt b/modules/15/15.nbt deleted file mode 100644 index f59f35c..0000000 --- a/modules/15/15.nbt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bbb378bbd2fb5a069977a3e20cc844fc4e0cecb3df4c67bd5a5ae4b7c5d032d5 -size 8963 diff --git a/modules/15/15.schem b/modules/15/15.schem deleted file mode 100644 index ea72961..0000000 --- a/modules/15/15.schem +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a343283cc6abff4725503930028d424afd57891052a51200f75d4377c4a0cf9e -size 1247 diff --git a/modules/8/8.litematic b/modules/8/8.litematic deleted file mode 100644 index 88aeae3..0000000 --- a/modules/8/8.litematic +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d17057a1884e34516613bc557ecb51ce054b1b295018346ea70bb7ed326a0b01 -size 10427 diff --git a/modules/8/8.schem b/modules/8/8.schem deleted file mode 100644 index cc8165c..0000000 --- a/modules/8/8.schem +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:64d0db9358b47d4a1d93bbd81c4249a280a880f3bd379e0a6decbecd8076606b -size 8272 diff --git a/modules/8/8_bottom.nbt b/modules/8/8_bottom.nbt deleted file mode 100644 index 976ee38..0000000 --- a/modules/8/8_bottom.nbt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:db3d921f5bd1905a963662b299e74eba315ded36330ba3479d717a9a53361905 -size 23586 diff --git a/modules/8/8_top.nbt b/modules/8/8_top.nbt deleted file mode 100644 index e33576c..0000000 --- a/modules/8/8_top.nbt +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ebd7467b076ebef1aaea8f7d116a5c2953f19de29d3751c90ce35434cdf42828 -size 50817 diff --git a/scripts/parse-label.py b/scripts/parse-label.py index 7c775d5..0e43877 100644 --- a/scripts/parse-label.py +++ b/scripts/parse-label.py @@ -1,28 +1,68 @@ - from pathlib import Path -from pprint import pprint import mistune +from qtoml.encoder import dumps +from qtoml.decoder import loads +from lib_not_dr import loggers +from lib_not_dr.types.options import Options + + ast_markdown = mistune.create_markdown(renderer='ast') -def read_files(module_path: Path): - with open(module_path, 'r', encoding='utf-8') as f: - file = f.read() + +class TagParser(Options): + module_root: Path + tags: dict[str, list[str]] = {} + logger: loggers.logger.Logger = None # noqa + + def load_module(self, **kwargs): + for readme in self.module_root.rglob('readme.md'): + self.logger.debug(readme.absolute(), tag="load file") + self.get_module_data(readme) - parsed = ast_markdown(file) - return parsed + tag_toml = dumps(self.tags) + tag_path = self.module_root / ".." / "build" / "tags.toml" + tag_path.mkdir(parents=True, exist_ok=True) + tag_path.touch(exist_ok=True) + with open(tag_path, 'w', encoding='utf-8') as file: + file.write(tag_toml) + + + def get_module_data(self, module_path: Path): + with open(module_path, 'r', encoding='utf-8') as f: + file = f.read() + + ast = ast_markdown(file) + if len(ast) == 0: + return + + if ast[0] != {'type': 'thematic_break'}: + # 排除开头不是注释块的 + return + + self.logger.info(f"开始解析 {ast[1]}") + config_code = ast[1].get("raw", "") + config_dict = loads(config_code) + self.logger.trace(config_dict) + + if not (tag_list := config_dict.get('tags')): + self.logger.warn("未找到 tags", tag=str(module_path)) + return + + for tag in tag_list: + if tag not in self.tags: + self.tags[tag] = [module_path.__str__()] + else: + self.tags[tag].append(module_path.__str__()) + + def init(self, **kwargs) -> bool: + self.logger = loggers.get_logger() + self.logger.global_level = 0 + return True if __name__ == '__main__': - module_path = Path('modules') - - # walk through the modules - # for every markdown file - # parse the label - - for md_file in module_path.rglob('*.md'): - print(md_file) - parsed = read_files(md_file) - pprint(parsed) - + parser = TagParser(module_root = Path("modules")) + parser.load_module() + parser.logger.info(parser.tags) diff --git a/scripts/requirement.txt b/scripts/requirement.txt new file mode 100644 index 0000000..058e70d --- /dev/null +++ b/scripts/requirement.txt @@ -0,0 +1,3 @@ +mistune +lib-not-dr +qtoml