-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuvasettings.py
40 lines (32 loc) · 1.03 KB
/
uvasettings.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
29
30
31
32
33
34
35
36
37
38
39
40
from os.path import expanduser
import json
import utils
import constants
SETTINGS_PATH = expanduser("~") + "/.uvashell"
class uvasettings():
def __init__(self):
try:
f = open(SETTINGS_PATH, "r")
self.d = json.loads(f.read())
except Exception as e:
self.d = self.prompt_info()
self.write_out()
def prompt_info(self):
print "No config file found, creating at: " + SETTINGS_PATH
print "Enter your desired UVA Username:"
username = raw_input()
print "Now, enter your default submission language (you have the ability to change this later):"
print constants.language
language = raw_input()
ret = {
'username': username,
'language': language
}
return ret;
def write_out(self):
utils.write_file(SETTINGS_PATH, json.dumps(self.d))
def __getitem__(self, i):
return self.d[i]
def __setitem__(self, key, value):
self.d[key] = value
self.write_out()