-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatastorage.py
More file actions
31 lines (26 loc) · 941 Bytes
/
datastorage.py
File metadata and controls
31 lines (26 loc) · 941 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
import pickle
class system():
"""
A class for saving the current system using pickle.
The class has the following:
name: string of the name of the system
lettermap: numpy array object with alphabet of the L-system, along with replacement rules turtleCommands and turtleActions
start: the start condition of the system
scaling: what the lengths should be scaled by after each iteration
"""
def __init__(self, name, lettermap, start, scaling):
self.name = name
self.lettermap = lettermap
self.start = start
self.scaling = scaling
def loadall(filename):
"""
A function for loading all systems saved in the systems.dat.
It is a generator, going through all dumps in the file systems.dat
"""
with open(filename, "rb") as f:
while True:
try:
yield pickle.load(f)
except EOFError:
break