mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-02-07 02:46:10 +08:00
4f5cb89365
🌟优化部分内容
42 lines
934 B
Python
Executable File
42 lines
934 B
Python
Executable File
#!/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()
|