diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/run-pytest.yml b/.github/workflows/run-pytest.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml old mode 100644 new mode 100755 index a004f6b..5191ffd --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,13 @@ fail_fast: true repos: + - repo: local + hooks: + - id: check-filenames + name: Check Python Filenames + entry: python ./.pre-commit/check_filename.py + language: python + files: \.py$ + - repo: https://github.com/psf/black rev: 24.4.2 hooks: diff --git a/.pre-commit/check_filename.py b/.pre-commit/check_filename.py new file mode 100644 index 0000000..d7f2e10 --- /dev/null +++ b/.pre-commit/check_filename.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 + +import os +import re +import sys + + +def is_valid_filename(filename: str) -> bool: + """文件名完整相对路径 + + Args: + filename (str): _description_ + + Returns: + bool: _description_ + """ + # 检查文件名是否仅包含小写字母,数字,下划线 + if not re.match(r"^[a-z0-9_]+\.py$", filename): + return False + else: + return True + + +def main(): + invalid_files = [] + for root, _, files in os.walk("nonebot_plugin_marshoai"): + for file in files: + if file.endswith(".py"): + if not is_valid_filename(file): + invalid_files.append(os.path.join(root, file)) + + if invalid_files: + print("以下文件名不符合命名规则:") + for file in invalid_files: + print(file) + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/LICENSE-MIT b/LICENSE-MIT old mode 100644 new mode 100755 diff --git a/LICENSE-MULAN b/LICENSE-MULAN old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/README_DEV.md b/README_DEV.md old mode 100644 new mode 100755 diff --git a/README_EN.md b/README_EN.md old mode 100644 new mode 100755 diff --git a/README_TOOLS.md b/README_TOOLS.md old mode 100644 new mode 100755 diff --git a/README_TOOLS_EN.md b/README_TOOLS_EN.md old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/__init__.py b/nonebot_plugin_marshoai/__init__.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/azure.py b/nonebot_plugin_marshoai/azure.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/azure_onebot.py b/nonebot_plugin_marshoai/azure_onebot.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/config.py b/nonebot_plugin_marshoai/config.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/config_example.yaml b/nonebot_plugin_marshoai/config_example.yaml old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/constants.py b/nonebot_plugin_marshoai/constants.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/deal_latex.py b/nonebot_plugin_marshoai/deal_latex.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/hunyuan.py b/nonebot_plugin_marshoai/hunyuan.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/metadata.py b/nonebot_plugin_marshoai/metadata.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/models.py b/nonebot_plugin_marshoai/models.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_bangumi/__init__.py b/nonebot_plugin_marshoai/tools/marshoai_bangumi/__init__.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_bangumi/tools.json b/nonebot_plugin_marshoai/tools/marshoai_bangumi/tools.json old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_basic/__init__.py b/nonebot_plugin_marshoai/tools/marshoai_basic/__init__.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_basic/tools.json b/nonebot_plugin_marshoai/tools/marshoai_basic/tools.json old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_basic/tools_test.json b/nonebot_plugin_marshoai/tools/marshoai_basic/tools_test.json old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_megakits/__init__.py b/nonebot_plugin_marshoai/tools/marshoai_megakits/__init__.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_megakits/mk_common.py b/nonebot_plugin_marshoai/tools/marshoai_megakits/mk_common.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_megakits/mk_info.py b/nonebot_plugin_marshoai/tools/marshoai_megakits/mk_info.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_megakits/mk_morse_code.py b/nonebot_plugin_marshoai/tools/marshoai_megakits/mk_morse_code.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_megakits/mk_nya_code.py b/nonebot_plugin_marshoai/tools/marshoai_megakits/mk_nya_code.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_megakits/tools.json b/nonebot_plugin_marshoai/tools/marshoai_megakits/tools.json old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_meogirl/__init__.py b/nonebot_plugin_marshoai/tools/marshoai_meogirl/__init__.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_meogirl/mg_info.py b/nonebot_plugin_marshoai/tools/marshoai_meogirl/mg_info.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_meogirl/mg_introduce.py b/nonebot_plugin_marshoai/tools/marshoai_meogirl/mg_introduce.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_meogirl/mg_search.py b/nonebot_plugin_marshoai/tools/marshoai_meogirl/mg_search.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools/marshoai_meogirl/tools.json b/nonebot_plugin_marshoai/tools/marshoai_meogirl/tools.json old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools_wip/marshoai_memory/__init__.py b/nonebot_plugin_marshoai/tools_wip/marshoai_memory/__init__.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/tools_wip/marshoai_memory/tools.json b/nonebot_plugin_marshoai/tools_wip/marshoai_memory/tools.json old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/util.py b/nonebot_plugin_marshoai/util.py old mode 100644 new mode 100755 diff --git a/nonebot_plugin_marshoai/util_hunyuan.py b/nonebot_plugin_marshoai/util_hunyuan.py old mode 100644 new mode 100755 diff --git a/pyproject.toml b/pyproject.toml old mode 100644 new mode 100755 diff --git a/resources/README.md b/resources/README.md old mode 100644 new mode 100755 diff --git a/resources/bg.png b/resources/bg.png old mode 100644 new mode 100755 diff --git a/resources/catface.svg b/resources/catface.svg old mode 100644 new mode 100755 diff --git a/resources/marsho-640x360.png b/resources/marsho-640x360.png old mode 100644 new mode 100755 diff --git a/resources/marsho-bg-1x1.png b/resources/marsho-bg-1x1.png old mode 100644 new mode 100755 diff --git a/resources/marsho-bg.png b/resources/marsho-bg.png old mode 100644 new mode 100755 diff --git a/resources/marsho-icon.png b/resources/marsho-icon.png old mode 100644 new mode 100755 diff --git a/resources/marsho-icon.svg b/resources/marsho-icon.svg old mode 100644 new mode 100755 diff --git a/resources/marsho-new.svg b/resources/marsho-new.svg old mode 100644 new mode 100755 diff --git a/resources/marsho-no-paw.png b/resources/marsho-no-paw.png old mode 100644 new mode 100755 diff --git a/resources/marsho-paw.png b/resources/marsho-paw.png old mode 100644 new mode 100755 diff --git a/resources/marsho.png b/resources/marsho.png old mode 100644 new mode 100755 diff --git a/resources/marsho.svg b/resources/marsho.svg old mode 100644 new mode 100755 diff --git a/tests/test_none.py b/tests/test_none.py old mode 100644 new mode 100755