diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f10b236 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +venv/ +.tox/ +minecraft_libs/__pycache__/ +version.json diff --git a/.pylintrc b/.pylintrc new file mode 100644 index 0000000..0c96ad3 --- /dev/null +++ b/.pylintrc @@ -0,0 +1,2 @@ +[BASIC] +good-names = f diff --git a/DESC.md b/DESC.md new file mode 100644 index 0000000..0fb5bc8 --- /dev/null +++ b/DESC.md @@ -0,0 +1 @@ +Parse version.json file and return libs diff --git a/README.md b/README.md index 164cabe..123b3de 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -* `make_libs_list.py` - parse `version.json` file and return libs -Moved to [iiiypuk/minecraft-libs-parser](https://github.com/iiiypuk/minecraft-libs-parser). +## minecraft_libs +Parse `version.json` file and return libs diff --git a/dev_requiments.txt b/dev_requiments.txt new file mode 100644 index 0000000..d13ff40 --- /dev/null +++ b/dev_requiments.txt @@ -0,0 +1,4 @@ +black==21.7b0 +click==8.0.1 +flit==3.2.0 +pylint==2.9.5 diff --git a/minecraft_libs/__init__.py b/minecraft_libs/__init__.py new file mode 100644 index 0000000..48d7f29 --- /dev/null +++ b/minecraft_libs/__init__.py @@ -0,0 +1,3 @@ +"""Parse version.json file and return libs""" + +__version__ = "1.0.3" diff --git a/make_libs_list.py b/minecraft_libs/__main__.py similarity index 69% rename from make_libs_list.py rename to minecraft_libs/__main__.py index 9d1909c..8dd7ae7 100644 --- a/make_libs_list.py +++ b/minecraft_libs/__main__.py @@ -1,19 +1,15 @@ -#!/usr/bin/env python3 +"""Parse version.json file and return libs""" 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 """ + """Return libraries list""" libraries = parse_libs() @@ -38,7 +34,7 @@ def make_output(platform, output): if platform == "win32": print("\nWindows generate libraries list complete!") - elif platform == "linux" or platform == "darwin": + elif ("linux", "darwin") in platform: print("\nUnix generate libraries list complete!") elif output == "txt": with open("./libs.txt", "w", encoding="utf-8") as f: @@ -46,23 +42,27 @@ def make_output(platform, output): if platform == "win32": print("\nWindows generate libraries list complete!\n" "See libs.txt file.") - elif platform == "linux" or platform == "darwin": + elif ("linux", "darwin") in platform: print("\nUnix generate libraries list complete!\n" "See libs.txt file.") def parse_libs(): - """ Make libraries list from version.json file """ + """Make libraries list from version.json file""" _ = [] - with open("./version.json", "r", encoding="utf-8") as f: - file_data = json.loads(f.read()) + try: + 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"]) + for lib in file_data["libraries"]: + _.append(lib["downloads"]["artifact"]["path"]) + except FileNotFoundError: + print("ERROR: File version.json not found.") + sys.exit(-1) return _ if __name__ == "__main__": - make_output() + make_output(platform=sys.platform, output="tty") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..098a115 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,25 @@ +[build-system] +requires = ["flit_core >=2,<4"] +build-backend = "flit_core.buildapi" + +[tool.flit.metadata] +module = "minecraft_libs" +author = "Alexander Popov" +author-email = "iiiypuk@iiiypuk.me" +requires = [ "click==7.1.2" ] +description-file = "DESC.md" +classifiers = [ + 'License :: Public Domain', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', +] +requires-python = ">=3" +keywords = "iOS,splashscreen,splash-screen" + +[tool.flit.metadata.requires-extra] +dev = ["pylint == 2.7.1", "black == 20.8b1"] + +[tool.black] +line-length = 99 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..c453187 --- /dev/null +++ b/tox.ini @@ -0,0 +1,12 @@ +[tox] +isolated_build = True +envlist = py37,py38,py39 + +[testenv] +deps = + black + pylint + pytest +commands = + black minecraft_libs + pylint minecraft_libs