From 73177ca355f5738dc8bdf408a11f4d05df40d9c2 Mon Sep 17 00:00:00 2001 From: Alexander Hayden Date: Sun, 20 Dec 2020 16:30:59 -0500 Subject: add blacklist functionality --- modpackman.py | 6 ++++-- packs/jeffrey-3/local-config.ini | 2 ++ util.py | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/modpackman.py b/modpackman.py index 18cdecc..69ebe41 100755 --- a/modpackman.py +++ b/modpackman.py @@ -19,6 +19,7 @@ from util import config def install(): mods_location = os.path.join(config["pack"]["location"], "mods") whitelist = config["pack"]["whitelist"] + blacklist = config["pack"]["blacklist"] # Actual download links are stored in pack-lock.ini, so we need to read it in here pack_lock = RawConfigParser() @@ -39,8 +40,9 @@ def install(): checksum, url = entry[1].split(',') mod_path = os.path.join(mods_location, name) i += 1 - if os.path.exists(mod_path) and os.path.isfile(mod_path) and \ - hashlib.sha1(open(mod_path, 'rb').read()).hexdigest() == checksum: + if (os.path.exists(mod_path) and os.path.isfile(mod_path) and \ + hashlib.sha1(open(mod_path, 'rb').read()).hexdigest() == checksum) or \ + name in blacklist: print(f"Skipping {name}, already up to date") else: print(f'Installing {name} from {url}...') diff --git a/packs/jeffrey-3/local-config.ini b/packs/jeffrey-3/local-config.ini index f1d3058..5781ccf 100644 --- a/packs/jeffrey-3/local-config.ini +++ b/packs/jeffrey-3/local-config.ini @@ -5,3 +5,5 @@ #location = /home/example/.minecraft/instances/jeffrey # A comma-separated list of mods that won't be deleted during the install process. whitelist = example_mod.jar,example_extra_mod.jar +# A comma-separated list of mods that won't be installed during the install process +blacklist = server_only_mod.jar,client_only_mod.jar diff --git a/util.py b/util.py index 9bf6300..e376649 100644 --- a/util.py +++ b/util.py @@ -31,6 +31,11 @@ def load_config(): config["pack"]["whitelist"] = [] else: config["pack"]["whitelist"] = config["pack"]["whitelist"].split(",") + + if "blacklist" not in config["pack"]: + config["pack"]["blacklist"] = [] + else: + config["pack"]["blacklist"] = config["pack"]["blacklist"].split(",") config["pack"]["game_version"] = game_version_from_string(config["pack"]["game_version"]) -- cgit v1.2.3