Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/sundry.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import os
import sys
from colorama import init
from catfood.functions.print import 消息头

def main() -> int:
init(autoreset=True)

try:
tool = sys.argv[1].lower()
args = sys.argv[2:]
Expand All @@ -19,7 +22,6 @@ def main() -> int:
"忽略", "检查忽略", "ignore", # 不确定如何读取 Token
"verify", "test", "验证", "测试", # 仅 Windows
]):
from colorama import Fore
print(f"{消息头.错误} 该操作仅可在 Windows 上运行")
return 1

Expand Down
3 changes: 1 addition & 2 deletions src/tools/autoremove.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
import requests
import subprocess
from typing import Any
from colorama import Fore
import tools.remove as remove
from colorama import Fore, init
from function.constant import Response
from catfood.functions.print import 消息头
from catfood.exceptions.request import RequestException
from function.files.manifest import 获取现有包版本, 获取清单目录

def main(args: list[str]) -> int:
try:
init(autoreset=True)
if not args:
print(f"{消息头.错误} 请传递参数")
raise KeyboardInterrupt
Expand Down
6 changes: 2 additions & 4 deletions src/tools/cat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from colorama import init, Fore
from colorama import Fore
from catfood.functions.print import 消息头
from pygments import highlight # type: ignore
from pygments.lexers import YamlLexer # type: ignore
Expand Down Expand Up @@ -33,9 +33,7 @@ def 读取和输出(清单文件: str):
print(f"{消息头.错误} 读取清单文件失败: {Fore.RED}文件不存在{Fore.RESET}")
return 1

def main(args: list[str]):
init(autoreset=True)

def main(args: list[str]) -> int:
winget_pkgs目录 = 读取配置("paths.winget-pkgs")
if not isinstance(winget_pkgs目录, str):
return 1
Expand Down
6 changes: 2 additions & 4 deletions src/tools/ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import time
import requests
import subprocess
from colorama import init, Fore
from colorama import Fore
from catfood.functions.print import 消息头
from function.maintain.config import 读取配置
from catfood.functions.files import open_file
Expand Down Expand Up @@ -153,9 +153,7 @@ def 创建拉取请求(分支名: str, owner: str, 忽略字段: str | None = No
print(f"{消息头.错误} 拉取请求创建失败: {response.status_code} - {response.text}")
return 0

def main(args: list[str]):
init(autoreset=True)

def main(args: list[str]) -> int:
winget_tools目录 = 读取配置("paths.winget-tools")
if not isinstance(winget_tools目录, str):
return 1
Expand Down
4 changes: 1 addition & 3 deletions src/tools/logsAnalyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tempfile
import requests
from typing import Any
from colorama import Fore, init
from colorama import Fore
import tools.maintain.cleanup as cleanup
from catfood.functions.print import 消息头
from urllib.parse import urlparse, parse_qs
Expand All @@ -21,8 +21,6 @@
def main(args: list[str]) -> int:
"""`sundry logs-analyse <Url> [是否保留日志文件] [是否显示一般错误/异常]`"""

init(autoreset=True)

# 获取 Azure Pipeline 运行链接
if len(args) < 1:
print(f"{消息头.错误} 请提供 GitHub PR 或 Azure Pipeline Run 的链接")
Expand Down
4 changes: 1 addition & 3 deletions src/tools/maintain/cleanup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import shutil
import tempfile
from colorama import Fore, init
from colorama import Fore
from catfood.functions.print import 消息头

def main(哪个工具: str) -> int:
Expand All @@ -10,8 +10,6 @@ def main(哪个工具: str) -> int:
参数 1: 指定哪个工具
"""

init(autoreset=True)

if not 哪个工具:
print(f"{消息头.警告} 未指定清理哪个工具产生的文件,默认清理除缓存外所有 Sundry 产生的文件 (aec)")
哪个工具 = "aec"
Expand Down
4 changes: 1 addition & 3 deletions src/tools/maintain/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
import jsonschema
from typing import Any
from colorama import init, Fore
from colorama import Fore
from catfood.functions.print import 消息头
from pygments import highlight # type: ignore
from catfood.functions.files import open_file
Expand Down Expand Up @@ -274,8 +274,6 @@ def 递归获取配置值(配置字典: dict[str, Any], 当前路径: str="") ->
return 1

def main(args: list[str]) -> int:
init(autoreset=True)

# 配置文件路径
配置文件 = 配置信息.所在位置

Expand Down
4 changes: 1 addition & 3 deletions src/tools/maintain/fun.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import os
import random
from colorama import init, Fore
from colorama import Fore
from catfood.functions.print import 消息头
from catfood.functions.files import open_file

def main(args: list[str]) -> int:
init(autoreset=True)

fun位置 = os.path.normpath(os.path.join(args[0], "fun.txt"))

if (1 <= len(args) <= 3): # 这里就这样,不然在 else 里要加一堆参数错误
Expand Down
6 changes: 2 additions & 4 deletions src/tools/maintain/revert.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import os
import subprocess
from colorama import Fore, init
from colorama import Fore
from catfood.functions.print import 消息头
from function.maintain.config import 读取配置

def main(args: list[str]):
init(autoreset=True)

def main(args: list[str]) -> int:
winget_pkgs目录 = 读取配置("paths.winget-pkgs")
winget_tools目录 = 读取配置("paths.winget-tools")
if not (isinstance(winget_pkgs目录, str) and isinstance(winget_tools目录, str)):
Expand Down
4 changes: 1 addition & 3 deletions src/tools/modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import random
import requests
import subprocess
from colorama import Fore
from datetime import datetime
from colorama import init, Fore
from catfood.functions.print import 消息头
from function.files.manifest import 清单信息
from function.maintain.config import 读取配置
Expand All @@ -19,8 +19,6 @@ def main(args: list[str]):
global 解决, 清单目录, 首个_PR, 格式化审查者, 程序所在目录
global owner

init(autoreset=True)

# 目录路径
# 尝试从参数中获取软件包标识符和版本
if (2 <= len(args) <= 3):
Expand Down
6 changes: 2 additions & 4 deletions src/tools/prune.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import os
import subprocess
from colorama import init, Fore
from colorama import Fore
from catfood.functions.print import 消息头
from function.maintain.config import 读取配置
from catfood.exceptions.operation import OperationFailed

def main():
init(autoreset=True)

def main() -> int:
try:
for 仓库 in ["winget-pkgs", "winget-tools"]:
仓库路径 = 读取配置(f"paths.{仓库}")
Expand Down
6 changes: 2 additions & 4 deletions src/tools/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import webbrowser
import tools.cat as cat
import tools.sync as sync
from colorama import init, Fore
from colorama import Fore
from catfood.functions.print import 消息头
from function.maintain.config import 读取配置
from function.files.manifest import 获取清单目录
Expand Down Expand Up @@ -62,11 +62,9 @@ def 创建拉取请求(软件包标识符: str, 分支名: str, 版本文件夹:
except KeyboardInterrupt:
return 1

def main(args: list[str]):
def main(args: list[str]) -> int:
global 手动验证结果, owner

init(autoreset=True)

winget_pkgs目录 = 读取配置("paths.winget-pkgs")
if not isinstance(winget_pkgs目录, str):
return 1
Expand Down
5 changes: 2 additions & 3 deletions src/tools/repr.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import os
from colorama import Fore, init
from colorama import Fore
from catfood.functions.print import 消息头

def main(args: list[str]):
init(autoreset=True)
def main(args: list[str]) -> int:

if (len(args) == 1):
if os.path.exists(args[0]):
Expand Down
6 changes: 2 additions & 4 deletions src/tools/sync.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import os
import subprocess
from colorama import init, Fore
from colorama import Fore
from catfood.functions.print import 消息头
from function.maintain.config import 读取配置

def main():
init(autoreset=True)

def main() -> int:
try:
winget_pkgs目录 = 读取配置("paths.winget-pkgs")
if not isinstance(winget_pkgs目录, str):
Expand Down
4 changes: 1 addition & 3 deletions src/tools/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import requests
import subprocess
from typing import Any
from colorama import Fore, init
from colorama import Fore
from catfood.functions.print import 消息头
from function.maintain.config import 读取配置
from pygments import highlight # pyright: ignore[reportUnknownVariableType]
Expand All @@ -22,8 +22,6 @@
from catfood.exceptions.request import RequestException

def main(args: list[str]) -> int:
init(autoreset=True)

# 初始化
软件包标识符: str = ""
软件包版本: str = ""
Expand Down