From fb6a7ab56db602027e99e0bd9077366a28e36034 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 18 Dec 2023 13:21:22 -0500 Subject: guess .minecraft folder before asking --- mc-resources.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'mc-resources.py') 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 = {} -- cgit v1.2.3