From 126cfecce5d9fd1e5c22df883b3b64864f25d344 Mon Sep 17 00:00:00 2001 From: Johannes Kung <johku144@student.liu.se> Date: Tue, 18 Jun 2024 08:01:16 +0000 Subject: [PATCH] Apply 4 suggestion(s) to 4 file(s) --- src/simudator/core/module.py | 16 ++++++++++++---- src/simudator/processor/mia/modules/alu.py | 3 ++- src/simudator/processor/mia/modules/bus.py | 3 ++- src/simudator/processor/mia/modules/ir.py | 3 --- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/simudator/core/module.py b/src/simudator/core/module.py index dc65434..82beff3 100644 --- a/src/simudator/core/module.py +++ b/src/simudator/core/module.py @@ -117,10 +117,18 @@ class Module: print(self.name) def _helper_save_state_to_file(self, file_path: str, content: str) -> bool: - """ - Tries to save the content to a given file. - - Returns true on success and false otherwise. + """Save the given content to a given file. + + Parameters + ---------- + file_path : str + Path to file to save to. + content : str + Content to save to file. + + Returns + ------- + ``True`` on success, ``False`` otherwise. """ try: with open(file_path, "a") as file: diff --git a/src/simudator/processor/mia/modules/alu.py b/src/simudator/processor/mia/modules/alu.py index edb4eb6..3f9cbdb 100644 --- a/src/simudator/processor/mia/modules/alu.py +++ b/src/simudator/processor/mia/modules/alu.py @@ -67,7 +67,8 @@ class ALU(Module): pass def save_state_to_file(self, file_path: str) -> bool: - """ + """Do nothing. + The alu is state-less. """ return True diff --git a/src/simudator/processor/mia/modules/bus.py b/src/simudator/processor/mia/modules/bus.py index 71125ff..9e1112a 100644 --- a/src/simudator/processor/mia/modules/bus.py +++ b/src/simudator/processor/mia/modules/bus.py @@ -70,7 +70,8 @@ class Bus(Module): pass def save_state_to_file(self, file_path: str) -> bool: - """ + """Do nothing. + The bus is state-less. """ return True diff --git a/src/simudator/processor/mia/modules/ir.py b/src/simudator/processor/mia/modules/ir.py index 57cd353..776df1e 100644 --- a/src/simudator/processor/mia/modules/ir.py +++ b/src/simudator/processor/mia/modules/ir.py @@ -129,9 +129,6 @@ class IR(Module, MiaBusConnector): ) 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 += "Instruction: " + hex(self.instruction)[2:] + "\n\n" return super()._helper_save_state_to_file(file_path, content) -- GitLab