From 12c5b16ef8801ecbebb08ecdf245aff7f35c6d52 Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Mon, 18 Mar 2024 00:10:59 +0800 Subject: [PATCH] update extra requirements --- src/requirements_collector.py | 40 +++++++++++++++++++++++------------ src/requirements_extra.txt | 39 +++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 28 deletions(-) diff --git a/src/requirements_collector.py b/src/requirements_collector.py index 21d18e7..6d33430 100644 --- a/src/requirements_collector.py +++ b/src/requirements_collector.py @@ -6,7 +6,7 @@ import sys import urllib.request from io import BytesIO -from typing import Dict, List, Iterable +from typing import Dict, List, Iterable, NamedTuple def download_json_gz(url: str): @@ -20,23 +20,30 @@ def sorted_string(collection: Iterable[str]) -> Iterable[str]: return sorted(collection, key=lambda r: (r.lower(), r)) +class ReqData(NamedTuple): + plugin_id: str + requirement: str + + def main(): data = download_json_gz('https://raw.githubusercontent.com/MCDReforged/PluginCatalogue/meta/everything.json.gz') - requirements: Dict[str, List[str]] = collections.defaultdict(list) + requirements: Dict[str, List[ReqData]] = collections.defaultdict(list) def add(pid: str, req_: str): - req_ = req_.strip().lower().replace('-', '_') - if req_ != 'mcdreforged': - requirements[req_].append(pid) + # https://peps.python.org/pep-0426/#name + matched = re.match(r'^([A-Z0-9][A-Z0-9._-]*[A-Z0-9]|[A-Z0-9])(.*)', req_, re.IGNORECASE) + if matched is not None: + package, rest = matched.group(1), matched.group(2) + if package in ['mcdreforged', 'python']: + return + key = package.strip().lower().replace('-', '_') + requirements[key].append(ReqData(pid, req_)) + else: + print('Unknown requirement line {!r} for plugin {!r}'.format(req, plugin_id), file=sys.stderr) for plugin_id, plugin in data['plugins'].items(): for req in plugin['meta']['requirements']: - matched = re.match(r'^([A-Z0-9][A-Z0-9._-]*[A-Z0-9]|[A-Z0-9])', req, re.IGNORECASE) - if matched is not None: - # https://peps.python.org/pep-0426/#name - add(plugin_id, matched.group(1)) - else: - print('Unknown requirement line {!r} for plugin {!r}'.format(req, plugin_id), file=sys.stderr) + add(plugin_id, req) with open('requirements_additional.json', 'r', encoding='utf8') as f: for plugin_id, reqs in json.load(f).items(): @@ -45,8 +52,15 @@ def add(pid: str, req_: str): with open('requirements_extra.txt', 'w', encoding='utf8') as f: for req in sorted_string(requirements.keys()): - plugins = ', '.join(sorted_string(requirements[req])) - f.write(f'# {plugins}\n') + items = [] + for rd in requirements[req]: + if rd.requirement == req: + items.append(rd.plugin_id) + else: + items.append('{} ({})'.format(rd.plugin_id, rd.requirement)) + comment = ', '.join(sorted_string(items)) + + f.write(f'# {comment}\n') f.write(f'{req}\n\n') diff --git a/src/requirements_extra.txt b/src/requirements_extra.txt index 3ead561..b331c55 100644 --- a/src/requirements_extra.txt +++ b/src/requirements_extra.txt @@ -1,22 +1,28 @@ # qq_api, qq_chat aiocqhttp -# cpu_temp, prime_backup +# matrix_sync +aiofiles + +# cpu_temp (APScheduler), prime_backup (APScheduler>=3.8,<4) apscheduler +# matrix_sync +asyncio + # prime_backup blake3 # chatbridge, pcrc colorlog -# mcdr_pycraft_bot, pcrc +# mcdr_pycraft_bot (cryptography>=1.5), pcrc cryptography # fastapi_mcdr fastapi -# simple_translator +# simple_translator (googletrans == 4.0.0rc1) googletrans # minecraft_data_api, player_manager @@ -31,19 +37,22 @@ jproperties # prime_backup lz4 +# matrix_sync (matrix-nio) +matrix_nio + # player_manager nbt -# joinmotd_reforged +# joinmotd_reforged (nbtlib >= 2.0.0) nbtlib -# mcd_seen, mcd_task, minecraft_data_api, minecraft_version_api, online, player_manager +# mcd_seen, mcd_task, minecraft_data_api, minecraft_version_api, online (parse>=1.19.0), player_manager parse -# cpu_temp, info, ipanel_mcdreforged, prime_backup +# cpu_temp, info, ipanel_mcdreforged (psutil>=5.8.0), prime_backup psutil -# info +# info (py-cpuinfo) py_cpuinfo # chatbridge @@ -52,25 +61,25 @@ pycryptodome # chatbridgereforged_mc pycryptodomex -# better_backup +# better_backup (pydal~=20230521.1) pydal -# mcdr_pycraft_bot, pcrc +# mcdr_pycraft_bot (PyNBT), pcrc pynbt # prime_backup pytz -# better_backup +# better_backup (pyzstd~=0.15.9) pyzstd # pcrc redbaron -# lite_file_manager, mc_uuid, mcdr_pycraft_bot, mcdreforged_plugin_manager, pcrc, uuid_api, wiki_request +# lite_file_manager, mc_uuid (requests>=2.25.1), mcdr_pycraft_bot, mcdreforged_plugin_manager, pcrc, uuid_api, wiki_request (requests>=2.26.0) requests -# eulagree, pcrc +# eulagree (ruamel.yaml~=0.17), pcrc ruamel.yaml # simple_calculator @@ -79,16 +88,16 @@ simpleeval # faster_transfer speedcopy -# database_api, player_manager, prime_backup +# database_api, player_manager, prime_backup (SQLAlchemy>=2) sqlalchemy # fastapi_mcdr, qq_api uvicorn -# ipanel_mcdreforged, onebot_api +# ipanel_mcdreforged (websocket-client>=1.6.1), onebot_api (websocket-client>=1.2.0) websocket_client -# better_backup, prime_backup +# better_backup (xxhash~=3.4.1), prime_backup (xxhash>=3) xxhash # prime_backup