-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathztConfig.py
More file actions
43 lines (38 loc) · 723 Bytes
/
ztConfig.py
File metadata and controls
43 lines (38 loc) · 723 Bytes
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
import json
from pathlib import Path
class ztConfig(object):
"""
Configuration
"""
def __init__(self):
"""
Set up config
"""
self.data = {
'token': '',
'networkId': ''
}
self.file = 'config.json'
self.load()
def load(self):
"""
"""
if Path(self.file).is_file():
with open(self.file) as configfile:
newdata:dict = json.load(configfile)
self.data.update(newdata)
if newdata != self.data:
self.store()
else:
self.store()
def store(self):
"""
"""
with open(self.file, 'w') as configfile:
json.dump(self.data, configfile, indent='\t')
@property
def token(self):
return self.data['token']
@property
def networkId(self):
return self.data['networkId']