From f0cfc22cff41885220bb53f4d4b6267ee5b0d0f4 Mon Sep 17 00:00:00 2001 From: Robert Izzard <r.izzard@surrey.ac.uk> Date: Mon, 29 Nov 2021 09:47:03 +0000 Subject: [PATCH] improve newline passing --- binarycpython/utils/functions.py | 3 ++- binarycpython/utils/grid_logging.py | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py index 875398fe9..304672866 100644 --- a/binarycpython/utils/functions.py +++ b/binarycpython/utils/functions.py @@ -373,7 +373,7 @@ def call_binary_c_config(argument): def verbose_print(message: str, verbosity: int, minimal_verbosity: int, - newline = "\n") -> None: + newline: str = "\n") -> None: """ Function that decides whether to print a message based on the current verbosity and its minimum verbosity @@ -384,6 +384,7 @@ def verbose_print(message: str, message: message to print verbosity: current verbosity level minimal_verbosity: threshold verbosity above which to print + newline: newline character (or set of characters), defaults to "\n" but "\x0d" (carriage return) might be useful. """ if verbosity >= minimal_verbosity: diff --git a/binarycpython/utils/grid_logging.py b/binarycpython/utils/grid_logging.py index e843e0744..f0cbbd85b 100644 --- a/binarycpython/utils/grid_logging.py +++ b/binarycpython/utils/grid_logging.py @@ -274,7 +274,7 @@ class grid_logging(): mem_use=total_mem_use, system_string_colour=self.ANSI_colours["yellow"], system_string=system_string, - closing_colour=self.ANSI_colours["reset"], + closing_colour=self.ANSI_colours["reset"] ), self.grid_options["verbosity"], 1, @@ -295,8 +295,7 @@ class grid_logging(): mem_use=total_mem_use, system_string_colour=self.ANSI_colours["yellow"], system_string=system_string, - closing_colour=self.ANSI_colours["reset"], - newline=self.grid_options["log_newline"] + closing_colour=self.ANSI_colours["reset"] ), self.grid_options["verbosity"], 1, @@ -313,6 +312,11 @@ class grid_logging(): ) def verbose_print(self,*args,**kwargs): + # wrapper for functions.verbose_print to use the correct newline + newline = kwargs.get("newline",self.grid_options["log_newline"]) + if newline is None: + newline = "\n" + kwargs["newline"] = newline binarycpython.utils.functions.verbose_print(*args,**kwargs) -- GitLab