Skip to content

Commit

Permalink
update extra requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Mar 17, 2024
1 parent 05a949e commit 12c5b16
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 28 deletions.
40 changes: 27 additions & 13 deletions src/requirements_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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():
Expand All @@ -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')


Expand Down
39 changes: 24 additions & 15 deletions src/requirements_extra.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 12c5b16

Please sign in to comment.