forked from nss-day-cohort-13/birdyboard-castle-c
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial.py
50 lines (34 loc) · 982 Bytes
/
serial.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
41
42
43
44
45
46
47
48
49
50
import pickle
def serializeUsers(self):
with open('userData.txt', 'wb+') as u:
pickle.dump(self.users, u)
def deserializeUsers(self):
try:
with open('userData.txt', 'rb+') as u: #rb in read binary
self.users = pickle.load(u)
except EOFError:
self.users = []
except FileNotFoundError:
self.users = []
def serializeChirps(self):
with open('chirps.txt', 'wb+') as u:
pickle.dump(self.chirps, u)
def deserializeChirps(self):
try:
with open('chirps.txt', 'rb+') as u: #rb in read binary
self.chirps = pickle.load(u)
except EOFError:
self.chirps = []
except FileNotFoundError:
self.chirps = []
def serializeConvos(self):
with open('convos.txt', 'wb+') as u:
pickle.dump(self.convos, u)
def deserializeConvos(self):
try:
with open('convos.txt', 'rb+') as u: #rb in read binary
self.convos = pickle.load(u)
except EOFError:
self.convos = []
except FileNotFoundError:
self.convos = []