version parser
This commit is contained in:
parent
9b2fdfda39
commit
219cae9a82
1
TODO.md
1
TODO.md
@ -1,4 +1,5 @@
|
||||
# TODO
|
||||
|
||||
- [x] assets downloader
|
||||
- [x] library parser
|
||||
- [ ] library downloader
|
||||
|
1
utils/version-parser/.gitignore
vendored
Normal file
1
utils/version-parser/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.json
|
30
utils/version-parser/parser.py
Executable file
30
utils/version-parser/parser.py
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import json
|
||||
|
||||
TYPE = 'linux'
|
||||
# TYPE='windows'
|
||||
# TYPE='macos'
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 2:
|
||||
print('add file')
|
||||
exit(-1)
|
||||
else:
|
||||
version_file = sys.argv[1]
|
||||
|
||||
with open(version_file, 'r') as f:
|
||||
a = json.loads(f.read())
|
||||
|
||||
print('Game ID: {0}'.format(a['id']))
|
||||
print('Main class: {0}'.format(a['mainClass']))
|
||||
print('Assets index: {0}'.format(a['assetIndex']['id']))
|
||||
|
||||
for library in a['libraries']:
|
||||
if 'rules' in library:
|
||||
if 'os' in library['rules'][0]:
|
||||
if TYPE == library['rules'][0]['os']['name']:
|
||||
print(library['downloads']['artifact']['path'])
|
||||
else:
|
||||
print(library['downloads']['artifact']['path'])
|
3
utils/version-parser/pyproject.toml
Normal file
3
utils/version-parser/pyproject.toml
Normal file
@ -0,0 +1,3 @@
|
||||
[tool.black]
|
||||
skip-string-normalization = true
|
||||
line-length = 100
|
Loading…
Reference in New Issue
Block a user