-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.py
More file actions
48 lines (43 loc) · 1.04 KB
/
Config.py
File metadata and controls
48 lines (43 loc) · 1.04 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""File used to load in config info to be used in the program
"""
"""Variables to be saved and loaded
"""
config = {"email":"",
"other":"",
"somethingElse":""
}
"""Loads the config file and stores the data in config(dict)
@Params:
None
@Return:
config(dict)
"""
def loadConfig():
file = open("config",'r')
data = file.read()
data = data.split("\n")
for d in data:
d = d.split(": ")
try:
try:
config[d[0]] = int(d[1])#load as int
except ValueError:
if d[1]=="True" or d[1]=="False":
config[d[0]] = bool(d[1])#load as boolean
else:
config[d[0]] = d[1]#load as string
except IndexError:
pass
return config
"""Saves config(dict) to config file
@Params:
None
@Return:
None
"""
def saveConfig():
f = open('config','w')
for key, value in config.iteritems():
f.write(key+": "+str(value)+'\n')
print key+": "+str(value)
f.close()