Skip to content
Snippets Groups Projects
Commit 2d3768fc authored by Wissam Benadjaoud's avatar Wissam Benadjaoud
Browse files

add specific file

parent 246fbf26
Branches
Tags
No related merge requests found
......@@ -23,19 +23,26 @@ class Savable:
"""
return self.amas
def save(self) -> None:
def save(self, file= None) -> None:
"""
Save the current state of the system
"""
with open('filename.pickle', 'wb') as handle:
pickle.dump(self.amas, handle, protocol=pickle.HIGHEST_PROTOCOL)
if file == None:
with open('filename.pickle', 'wb') as handle:
pickle.dump(self.amas, handle, protocol=pickle.HIGHEST_PROTOCOL)
else:
with open('file.pickle', 'wb') as handle:
pickle.dump(self.amas, handle, protocol=pickle.HIGHEST_PROTOCOL)
@classmethod
def load(cls) -> 'Savable':
def load(cls, file= None) -> 'Savable':
"""
Load the last save of the system
"""
with open('filename.pickle', 'rb') as handle:
amas_object = pickle.load(handle)
return cls(amas_object)
\ No newline at end of file
if file == None:
with open('filename.pickle', 'rb') as handle:
amas_object = pickle.load(handle)
else:
with open('file.pickle', 'rb') as handle:
amas_object = pickle.load(handle)
return cls(amas_object)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment