-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_data.py
38 lines (26 loc) · 903 Bytes
/
save_data.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
import os
import pickle
class SaveFile:
def __init__(self):
self.round_data = {}
self.encounter_name = ""
self.highest_round = 1
self.notes = []
class RoundData:
def __init__(self, round_number=1, characters={}):
self.round = round_number
self.characters = characters
def save_file(file_name, data_file):
save_path = f"{os.getcwd()}\\saved_files\\"
if not os.path.exists(save_path):
os.makedirs(save_path)
with open(f"{save_path}\\{file_name}.pkl", "wb") as f:
pickle.dump(data_file, f)
def does_file_exists(file_name):
file_path = f"{os.getcwd()}\\saved_files\\{file_name}.pkl"
return os.path.exists(file_path)
def load_file(file_name):
file_path = f"{os.getcwd()}\\saved_files\\{file_name}.pkl"
with open(f"{file_path}", "rb") as f:
data_file = pickle.load(f)
return data_file