diff options
author | Benji Dial <benji@benjidial.net> | 2023-12-18 13:21:22 -0500 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2023-12-18 13:21:22 -0500 |
commit | fb6a7ab56db602027e99e0bd9077366a28e36034 (patch) | |
tree | a079f9f2383e29d91654568ce7f6518a613cb647 /mc-resources.py | |
parent | cab012d443e35b17d55ee55b7bd233d1fc36181f (diff) | |
download | mc-resources-fb6a7ab56db602027e99e0bd9077366a28e36034.tar.gz |
guess .minecraft folder before asking
Diffstat (limited to 'mc-resources.py')
-rw-r--r-- | mc-resources.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/mc-resources.py b/mc-resources.py index cf5dc10..746705e 100644 --- a/mc-resources.py +++ b/mc-resources.py @@ -3,6 +3,7 @@ import itertools import graphlib import zipfile import json +import sys import os def ask_from_list(prompt, mapping): @@ -28,9 +29,19 @@ def join_with_and(list): return list[0] + ' and ' + list[1] return ', '.join(list[:-1]) + ', and ' + list[-1] +def guess_minecraft_directory(): + if sys.platform.startswith('linux'): + return os.path.join(os.path.expanduser('~'), '.minecraft') + if sys.platform in ['win32', 'cygwin']: + return os.path.join(os.getenv('APPDATA'), '.minecraft') + return '.' + if not os.path.exists('from-jar'): - print('please enter the path to the .minecraft folder:') - versions_dir = os.path.join(input('> '), 'versions') + versions_dir = os.path.join(guess_minecraft_directory(), 'versions') + + while not os.path.exists(versions_dir): + print('please enter the path to the .minecraft directory:') + versions_dir = os.path.join(input('> '), 'versions') versions = {} |