clone from @iiiypuk/minecraft-launcher

This commit is contained in:
Alexander Popov 2021-07-21 04:34:01 +03:00
parent b2b7145706
commit 43580bc790
Signed by: iiiypuk
GPG Key ID: 398FC73478D97286
3 changed files with 71 additions and 2 deletions

View File

@ -1,2 +1,2 @@
# minecraft-libs-parser * `make_libs_list.py` - parse `version.json` file and return libs
parse `version.json` file and return libs Moved to [iiiypuk/minecraft-libs-parser](https://github.com/iiiypuk/minecraft-libs-parser).

68
make_libs_list.py Normal file
View File

@ -0,0 +1,68 @@
#!/usr/bin/env python3
import sys
import json
import click
__author__ = "Alexander Popov"
__version__ = "1.0.2"
__license__ = "Unlicense"
@click.command()
@click.option("--platform", default=sys.platform, help="Output platform (win32, linux, darwin).")
@click.option("--output", default="tty", help="Output option (tty, txt).")
def make_output(platform, output):
""" Return libraries list """
libraries = parse_libs()
# OS libs separate
_ = {"win32": ";", "linux": ":", "darwin": ":"}
out_lib = str()
# Generate libraries list
for lib in libraries:
out_lib = out_lib + "$MC_DIR/libraries/{0}".format(lib) + _[platform]
out_lib = out_lib + "$MC_DIR/versions/$GAME_VERSION/$GAME_VERSION.jar"
# Replace for OS shell variable symbol
if platform == "win32":
out_lib = out_lib.replace("$MC_DIR", "%MC_DIR%")
out_lib = out_lib.replace("$GAME_VERSION", "%GAME_VERSION%")
if output == "tty":
click.echo(out_lib)
if platform == "win32":
print("\nWindows generate libraries list complete!")
elif platform == "linux" or platform == "darwin":
print("\nUnix generate libraries list complete!")
elif output == "txt":
with open("./libs.txt", "w", encoding="utf-8") as f:
f.write(out_lib)
if platform == "win32":
print("\nWindows generate libraries list complete!\n" "See libs.txt file.")
elif platform == "linux" or platform == "darwin":
print("\nUnix generate libraries list complete!\n" "See libs.txt file.")
def parse_libs():
""" Make libraries list from version.json file """
_ = []
with open("./version.json", "r", encoding="utf-8") as f:
file_data = json.loads(f.read())
for lib in file_data["libraries"]:
_.append(lib["downloads"]["artifact"]["path"])
return _
if __name__ == "__main__":
make_output()

1
requirements.txt Normal file
View File

@ -0,0 +1 @@
click==7.1.2