Skip to content
Snippets Groups Projects
Commit 126cfecc authored by Johannes Kung's avatar Johannes Kung Committed by Martin Högstedt
Browse files

Apply 4 suggestion(s) to 4 file(s)

parent 0c112b7b
No related branches found
No related tags found
1 merge request!24Fixed save_state_to_file
Pipeline #132136 failed
...@@ -117,10 +117,18 @@ class Module: ...@@ -117,10 +117,18 @@ class Module:
print(self.name) print(self.name)
def _helper_save_state_to_file(self, file_path: str, content: str) -> bool: def _helper_save_state_to_file(self, file_path: str, content: str) -> bool:
""" """Save the given content to a given file.
Tries to save the content to a given file.
Parameters
Returns true on success and false otherwise. ----------
file_path : str
Path to file to save to.
content : str
Content to save to file.
Returns
-------
``True`` on success, ``False`` otherwise.
""" """
try: try:
with open(file_path, "a") as file: with open(file_path, "a") as file:
......
...@@ -67,7 +67,8 @@ class ALU(Module): ...@@ -67,7 +67,8 @@ class ALU(Module):
pass pass
def save_state_to_file(self, file_path: str) -> bool: def save_state_to_file(self, file_path: str) -> bool:
""" """Do nothing.
The alu is state-less. The alu is state-less.
""" """
return True return True
......
...@@ -70,7 +70,8 @@ class Bus(Module): ...@@ -70,7 +70,8 @@ class Bus(Module):
pass pass
def save_state_to_file(self, file_path: str) -> bool: def save_state_to_file(self, file_path: str) -> bool:
""" """Do nothing.
The bus is state-less. The bus is state-less.
""" """
return True return True
...@@ -129,9 +129,6 @@ class IR(Module, MiaBusConnector): ...@@ -129,9 +129,6 @@ class IR(Module, MiaBusConnector):
) )
def save_state_to_file(self, file_path: str) -> bool: def save_state_to_file(self, file_path: str) -> bool:
"""
Tries to save the modules state to a given file.
"""
content = self.name + ":\n" content = self.name + ":\n"
content += "Instruction: " + hex(self.instruction)[2:] + "\n\n" content += "Instruction: " + hex(self.instruction)[2:] + "\n\n"
return super()._helper_save_state_to_file(file_path, content) return super()._helper_save_state_to_file(file_path, content)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment