From d53a4216c3219dc94cd45789142a2f28b5e0e1f7 Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 02:29:14 +0100 Subject: Format tweaks to Python files [#30] --- bin/handler.py | 5 +++++ bin/printer.py | 11 +++++++++-- bin/salis.py | 13 +++++++++++-- bin/world.py | 8 +++++++- 4 files changed, 32 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/handler.py b/bin/handler.py index 7bde479..da95789 100644 --- a/bin/handler.py +++ b/bin/handler.py @@ -151,6 +151,11 @@ class Handler: # Store command on console history. self.console_history.append(command_raw.strip()) + + ############################### + # Private methods + ############################### + def __raise(self, message): """ Generic exception thrower. Throws a 'RuntimeError' initialized with the given message. diff --git a/bin/printer.py b/bin/printer.py index 14aea6f..bed93d2 100644 --- a/bin/printer.py +++ b/bin/printer.py @@ -13,6 +13,7 @@ import curses import curses.textpad import os import time + from collections import OrderedDict from ctypes import c_uint8, c_uint32, cast, POINTER from handler import Handler @@ -393,6 +394,11 @@ class Printer: elif self.current_page == "PROCESS": self.__print_proc_list() + + ############################### + # Private methods + ############################### + def __set_colors(self): """ Define the color pairs for the data printer. """ @@ -489,8 +495,9 @@ class Printer: represents a PAGE. We initialize all pages inside an ordered dictionary object. """ - # The following widgets help up print special sets of data elements. - # The use of nested lambdas is needed to receive updated values. + # The following comprehensions build up widgets to help up print sets + # of data elements. The use of nested lambdas is needed to receive + # updated values. # Instruction counter widget: inst_widget = [("e", inst[0], (lambda j: ( lambda: self.__sim.lib.sal_mem_get_inst_count(j) diff --git a/bin/salis.py b/bin/salis.py index dc86d1d..31a6ac1 100755 --- a/bin/salis.py +++ b/bin/salis.py @@ -21,6 +21,7 @@ import re import sys import time import traceback + from argparse import ArgumentParser, HelpFormatter from ctypes import CDLL, c_bool, c_uint8, c_uint32, c_char_p, POINTER from handler import Handler @@ -151,6 +152,11 @@ class Salis: """ self.__exit = True + + ############################### + # Private methods + ############################### + def __get_path(self): """ Retrieve the absolute path of this script. We need to do this in order to detect the './lib', './sims' and './genomes' subdirectories. @@ -334,7 +340,10 @@ class Salis: return lib + +############################### +# Entry point +############################### + if __name__ == "__main__": - """ Entry point... - """ Salis().run() diff --git a/bin/world.py b/bin/world.py index 15cdd21..31674f2 100644 --- a/bin/world.py +++ b/bin/world.py @@ -6,11 +6,12 @@ Email: paul.t.oliver.design@gmail.com This module should be considered an extension of the 'printer' module. It takes care of getting a pre-redered image from Salis and post-processing it in order -to print it into the curses screen. It also keeps track of user cntrollable +to print it into the curses screen. It also keeps track of user controllable rendering parameters (position and zoom). """ import curses + from ctypes import c_uint8, cast, POINTER @@ -147,6 +148,11 @@ class World: if self.__is_world_editable(): self.__show_ip = not self.__show_ip + + ############################### + # Private methods + ############################### + def __set_world_colors(self): """ Define color pairs for rendering the world. Each color has a special meaning, referring to the selected process IP, SP and memory -- cgit v1.2.1