-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileRW.py
More file actions
39 lines (36 loc) · 1.07 KB
/
FileRW.py
File metadata and controls
39 lines (36 loc) · 1.07 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
import json
from configparser import ConfigParser
def readConfig(fileName):
cfg = ConfigParser()
cfg.read('DiscordBotConfig.ini')
return cfg['DiscordBotConfig']
def readEmoji():
cfg = ConfigParser()
cfg.read('emoji.ini')
emoji=dict([])
for e in cfg['Emoji']:
emoji[e] = eval(cfg['Emoji'][e]).decode('utf8')
return emoji
def readCategory(fileName):
data = []
with open(fileName, mode = 'r') as f:
data = f.read()
return json.loads(data)
def ReadPollData(fileName):
with open(fileName,mode='r') as f:
d = json.load(f.read())
return d
def SavePollData(fileName,data):
with open(fileName,mode='w') as f:
f.write(json.dump(data))
def SaveNewPoll(fileName,data):
with open(fileName,mode='r+') as f:
f_data = f.read()
f_data=json.load(f_data)
f_data.append(data)
f.seek(0,0)
f.write(json.dump(f_data))
def SaveHisPollData(fileName,data):
with open(fileName,mode='a') as f:
d = f.write(json.load(data))
return d