2019-05-05 21:20:45 +08:00
|
|
|
# Primitive config
|
2018-10-28 10:42:24 +08:00
|
|
|
import configparser
|
2018-10-29 03:49:19 +08:00
|
|
|
import os
|
2018-10-28 10:42:24 +08:00
|
|
|
|
2019-05-05 21:20:45 +08:00
|
|
|
|
|
|
|
def createConfig(path="Settings.ini"):
|
2018-10-28 10:42:24 +08:00
|
|
|
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")
|
2019-05-05 21:20:45 +08:00
|
|
|
config.set("Defaults", "theme", "anaglyph")
|
2018-10-28 10:42:24 +08:00
|
|
|
with open(path, 'w') as configFile:
|
|
|
|
config.write(configFile)
|
|
|
|
|
2019-05-05 21:20:45 +08:00
|
|
|
|
|
|
|
def readConfig(path="Settings.ini"):
|
2018-10-28 10:42:24 +08:00
|
|
|
config = configparser.ConfigParser()
|
|
|
|
config.read(path)
|
|
|
|
return config
|
2018-10-29 03:49:19 +08:00
|
|
|
|
2019-05-05 21:20:45 +08:00
|
|
|
|
2018-10-29 03:49:19 +08:00
|
|
|
def ifSettingsNotExists():
|
|
|
|
if not os.path.exists("Settings.ini"):
|
|
|
|
createConfig()
|