-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathUtlis.py
30 lines (22 loc) · 785 Bytes
/
Utlis.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
import json
class Utils:
def __init__(self, configpath = 'config.json'):
self.config=configpath
def WriteToFile(self, data,filename):
with open('./Data/'+filename+'.txt','a') as fo:
fo.write(str(data))
fo.close()
def WriteConfig(self, config):
with open('config.json', 'w') as f:
json.dump(config, f)
def ReadConfig(self):
with open('./Config/'+self.config, 'r') as f:
config = json.load(f)
return config
def WriteLog(self, log):
with open('./Log/'+'log.txt', 'a') as f:
f.write(str(log)+'\n')
f.close()
def WriteToJSONFile(self,data,filename):
with open('./Data/JSON/'+filename+'.json','a') as fo:
json.dump(data,fo)