diff --git a/pyAmakCore/classes/scheduler_tool/savable.py b/pyAmakCore/classes/scheduler_tool/savable.py index d7f19139cc80bac8ff9d8502f33c6911baefb3c0..ade770292815e2253734aebac4196b6add66d073 100644 --- a/pyAmakCore/classes/scheduler_tool/savable.py +++ b/pyAmakCore/classes/scheduler_tool/savable.py @@ -23,26 +23,19 @@ class Savable: """ return self.amas - def save(self, file= None) -> None: + def save(self, file="filename.pickle") -> None: """ Save the current state of the system """ - 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: + with open(file, 'wb') as handle: pickle.dump(self.amas, handle, protocol=pickle.HIGHEST_PROTOCOL) @classmethod - def load(cls, file= None) -> 'Savable': + def load(cls, file="filename.pickle") -> 'Savable': """ Load the last save of the system """ - 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) + with open(file, 'rb') as handle: + amas_object = pickle.load(handle) + return cls(amas_object)