From 2558274afb44238d7a37972c8fbb5fd56556b50e Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 9 Dec 2023 02:03:41 +0800 Subject: [PATCH] work it on yml? MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit push 看起来还是得要node是吧 用这个 还得ensurepip是吧 用一下 setup python reee 行 v4 ? 还得是local 使用新 mirror 的 ? 不用了,行吧 ? v1 ? 行吗? --- .gitea/workflows/label.yaml | 18 ------------------ .gitea/workflows/label.yml | 34 ++++++++++++++++++++++++++++++++++ scripts/parse-label.py | 26 +++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 19 deletions(-) delete mode 100644 .gitea/workflows/label.yaml create mode 100644 .gitea/workflows/label.yml diff --git a/.gitea/workflows/label.yaml b/.gitea/workflows/label.yaml deleted file mode 100644 index 0c584b2..0000000 --- a/.gitea/workflows/label.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: 自动生成 label - -# main 分支推送 -on: - push: - branches: - - main - -jobs: - Generate-label: - runs-on: python311 - steps: - - name: 获取仓库 - uses: http://shenjack.top:5100/mirror/checkout@v4 - - # - name: 生成 label - # run: | - # python3 generate_label.py diff --git a/.gitea/workflows/label.yml b/.gitea/workflows/label.yml new file mode 100644 index 0000000..de56e1b --- /dev/null +++ b/.gitea/workflows/label.yml @@ -0,0 +1,34 @@ +name: 自动生成 label + +# main 分支推送 +on: + [push] + # push: + # branches: + # - main + +jobs: + Generate-label: + runs-on: node-21 + steps: + - name: 获取仓库 + uses: http://shenjack.top:5100/gitea-server/checkout@v4 + + # - name: 安装 Python + # uses: actions/setup-python + + - name: ensure pip + uses: http://shenjack.top:5100/gitea-server/python-packs@17b23b7e6b488cbc2244e47f640351bac0595c15 + + - name: 安装依赖 + run: | + python3 -m 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 + + - name: 生成 label + run: | + python3 generate_label.py + +# https://gitea.com/actions/gitea-release-action diff --git a/scripts/parse-label.py b/scripts/parse-label.py index 5f2354e..7c775d5 100644 --- a/scripts/parse-label.py +++ b/scripts/parse-label.py @@ -1,4 +1,28 @@ + from pathlib import Path +from pprint import pprint + +import mistune + +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() + + parsed = ast_markdown(file) + return parsed + + +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) +