123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- import os
- def read(setting):
-
- data = open("settings/settings.data")
- data = data.read()
- data = data.split("\n")
-
- for line in data:
- if line.startswith(setting):
- return convert(line.replace(setting+" = ", ""))
-
- return False
- def write(setting, value):
-
-
- value = str(value)
-
-
- data = open("settings/settings.data")
- data = data.read()
- data = data.split("\n")
-
-
- ndata = open("settings/settings.data", "w")
-
-
-
- found = False
- for line in data:
- if line.startswith(setting):
- line = setting+" = "+str(value)
- found = True
- if line != "":
- ndata.write(line+"\n")
-
- if not found:
- ndata.write(setting+" = "+str(value)+"\n")
-
-
- ndata.close()
-
-
- def list_languages():
-
-
- all_langs = os.listdir("settings/languages/")
-
-
- r = []
- for lang in all_langs:
- if lang.endswith(".data"):
- r.append(lang.replace(".data", ""))
- all_langs = sorted(r)
-
- return all_langs
- def load_all():
-
-
-
-
-
-
- ret = {}
-
-
- data = open("settings/settings.data")
- data = data.read()
- data = data.split("\n")
-
-
- for d in data:
- if d:
- ret[d[:d.find(" = ")]] = convert(d[d.find(" = ")+3:])
-
-
- return ret
- def convert(string):
-
-
-
-
-
-
- try:
- string = float(string)
- except:
-
-
- if string == "True":
- string = True
- elif string == "False":
- string = False
- elif string == "None":
- string = None
-
- return string
-
|