-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
28 lines (21 loc) · 935 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import re, os
#Some important constants
FOLDER = os.path.dirname(os.path.realpath(__file__)) + "/"
SETTINGSFILE = FOLDER + "settings.dat"
def LoadSettings():
global settings
#Define some default settings
settings = {"field" : "Story Arc", "GroupKeywordColon" : "True", "StripLeadingThe" : "False"}
#The settings file should be formated with each line as SettingName:Value. eg Prefix:Scanner:
try:
with open(SETTINGSFILE, 'r') as settingsfile:
for line in settingsfile:
match = re.match("(?P<setting>.*?):(?P<value>.*)", line)
settings[match.group("setting")] = match.group("value").strip()
except Exception as ex:
print("Something has gone wrong loading the settings file. The error was: " + str(ex))
return settings
def SaveSettings(settings):
with open(SETTINGSFILE, 'w') as settingsfile:
for setting in settings:
settingsfile.write(setting + ":" + settings[setting] + "\n")