aboutsummaryrefslogtreecommitdiff
path: root/update.py
diff options
context:
space:
mode:
authorDylan Jones <dylanjones2011@gmail.com>2020-11-27 00:13:57 -0500
committerDylan Jones <dylanjones2011@gmail.com>2020-11-27 00:13:57 -0500
commit55c7ef774db75e7ba37a3a121f749ab60f8d4117 (patch)
tree6c32983df1d8468886f0f678a7dc3b0979da8784 /update.py
parent2c29fbad324c826e118be42e510a8388e4648ef5 (diff)
downloadmodpackman-55c7ef774db75e7ba37a3a121f749ab60f8d4117.tar.gz
modpackman-55c7ef774db75e7ba37a3a121f749ab60f8d4117.zip
start conversion to ini
Diffstat (limited to 'update.py')
-rwxr-xr-xupdate.py20
1 files changed, 20 insertions, 0 deletions
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.