2018-10-28 10:42:24 +08:00
|
|
|
#Primitive config works
|
|
|
|
import configparser
|
2018-10-29 03:49:19 +08:00
|
|
|
import os
|
2018-10-28 10:42:24 +08:00
|
|
|
|
|
|
|
def createConfig(path = "Settings.ini"):
|
|
|
|
config = configparser.ConfigParser()
|
|
|
|
config.add_section("Settings")
|
2018-10-29 03:49:19 +08:00
|
|
|
config.add_section("Defaults")
|
2018-10-28 10:42:24 +08:00
|
|
|
config.set("Settings", "Language", "en")
|
2018-10-29 03:49:19 +08:00
|
|
|
config.set("Settings", "DidBackground", "True")
|
|
|
|
config.set("Defaults", "webPage", "Facebook")
|
|
|
|
config.set("Defaults", "additionalOption", "1")
|
2018-10-28 10:42:24 +08:00
|
|
|
with open(path, 'w') as configFile:
|
|
|
|
config.write(configFile)
|
|
|
|
|
|
|
|
def readConfig(path = "Settings.ini"):
|
|
|
|
config = configparser.ConfigParser()
|
|
|
|
config.read(path)
|
|
|
|
return config
|
2018-10-29 03:49:19 +08:00
|
|
|
|
|
|
|
def ifSettingsNotExists():
|
|
|
|
if not os.path.exists("Settings.ini"):
|
|
|
|
createConfig()
|