diff options
author | Dylan Jones <dylanjones2011@gmail.com> | 2020-11-27 00:13:57 -0500 |
---|---|---|
committer | Dylan Jones <dylanjones2011@gmail.com> | 2020-11-27 00:13:57 -0500 |
commit | 55c7ef774db75e7ba37a3a121f749ab60f8d4117 (patch) | |
tree | 6c32983df1d8468886f0f678a7dc3b0979da8784 /update.py | |
parent | 2c29fbad324c826e118be42e510a8388e4648ef5 (diff) | |
download | modpackman-55c7ef774db75e7ba37a3a121f749ab60f8d4117.tar.gz modpackman-55c7ef774db75e7ba37a3a121f749ab60f8d4117.zip |
start conversion to ini
Diffstat (limited to 'update.py')
-rwxr-xr-x | update.py | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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. |