From 55c7ef774db75e7ba37a3a121f749ab60f8d4117 Mon Sep 17 00:00:00 2001 From: Dylan Jones Date: Fri, 27 Nov 2020 00:13:57 -0500 Subject: start conversion to ini --- update.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'update.py') diff --git a/update.py b/update.py index 28ee252..bca3cbc 100755 --- a/update.py +++ b/update.py @@ -8,6 +8,7 @@ import re import collections import urllib.parse import multiprocessing +from configparser import ConfigParser import requests @@ -48,6 +49,25 @@ parser.add_argument("--game-version", ## loaded from version.txt VERSION = 0 +def load_config(): + config = ConfigParser() + config.read("pack.ini") + config["pack"]["sanitized_name"] = sanitize_text(config["pack"]["name"]) + # return the whole config file, pack configuration and modlist + return config + +# take a string and only keep filename-friendly parts +def sanitize_text(text): + sanitized = "" + replacement_map = {" ": "-"} + for char in text: + if char.isalnum(): + sanitized += char.lower() + elif char in replacement_map: + sanitized += replacement_map[char] + return sanitized + + def read_file(fil): """ Given a filename, read its contents in as a list of tuples. -- cgit v1.2.3