Source code for g3d.defs.world.display

"""G3DDisplay static class"""
import os
from typing import Any
from .info import G3DInfo
from g3d.defs import CodeType


[docs] class G3DDisplay: """G3D display placeholder""" __verbose = False __print_splash = True __silent = False __print_iterations = False __scrw = 80 __plot_edges = False __progress_bar = False @property def verbose(self) -> bool: """verbose = True => more printed output (default value = False)""" return type(self).__verbose @verbose.setter def verbose(self, b: bool) -> None: type(self).__verbose = b if type(self).__verbose: type(self).__silent = False @property def print_iterations(self) -> bool: """print_iterations = True => residuals will be printed every iteration (default value = False)""" return type(self).__print_iterations @print_iterations.setter def print_iterations(self, b: bool) -> None: type(self).__print_iterations = b @property def progress_bar(self) -> bool: """progress_bar = True => progress bar will be printed to std out (default value = False)""" return type(self).__progress_bar @progress_bar.setter def progress_bar(self, b: bool) -> None: type(self).__progress_bar = b @property def print_splash(self) -> bool: """print_splash = True => code splash (logo) will be printed on solver start (default value = True)""" return type(self).__print_splash @print_splash.setter def print_splash(self, b: bool) -> None: type(self).__print_splash = b @property def silent(self) -> bool: """silent = True => limited solver output (default value = False)""" return type(self).__silent @silent.setter def silent(self, b: bool) -> None: type(self).__silent = b if type(self).__silent: type(self).__verbose = False type(self).__print_splash = False else: type(self).__print_splash = True @property def scrw(self) -> int: """screen width (default value = 80)""" return type(self).__scrw @scrw.setter def scrw(self, w: int) -> None: type(self).__scrw = w @property def plot_edges(self) -> bool: """plot_edges = True => mesh block edges will be printed on mesh plot (default value = False)""" return type(self).__plot_edges @plot_edges.setter def plot_edges(self, b: bool) -> None: type(self).__plot_edges = b
[docs] def hline(self, *args: Any, **kwargs: Any) -> None: """ prints horizontal line on screen input: args, kwargs args: dash (default = '-'), scrw (default = 80 or earlier specified scrw value) kwargs: 'dashes', 'scrw' example: hline(args, kwargs) """ dashes = '-' scrw = None if len(args) > 0: dashes = args[0] if len(args) > 1: scrw = args[1] for key, value in kwargs.items(): if key == 'dashes': dashes = value if key == 'scrw': scrw = value if scrw is None: scrw = type(self).__scrw print(dashes * scrw)
# def header(self, info='test header'):
[docs] def header(self, *args: Any, **kwargs: Any) -> None: """ prints header to std out input: args, kwargs args: info (header text (string)), dashes (default = '='), scrw (default = 80 or earlier specified scrw value) kwargs: 'info', 'dashes', 'scrw' example: header(args, kwargs) """ info = 'test header' dashes = '=' scrw = None n_space = 1 if len(args) > 0: info = args[0] if len(args) > 1: dashes = args[1] if len(args) > 2: scrw = args[2] for key, value in kwargs.items(): if key == 'info': info = value if key == 'dashes': dashes = value if key == 'scrw': scrw = value if key == 'n_space': n_space = value for i in range(n_space): print() self.hline(dashes=dashes, scrw=scrw) if isinstance(info, (list, tuple)): for line in info: print(' ' + line) else: print(' ' + info) self.hline(dashes=dashes, scrw=scrw) for i in range(n_space): print()
[docs] @staticmethod def author(): """ prints author/developer information to std out input: no input example: author() """ g3d_info = G3DInfo() print('') for line in g3d_info.author: print(' ' + line) print('')
[docs] def splash(self) -> None: """ prints code splash to std out logo (code specific), code version & author information input: no input example: splash() """ if type(self).__print_splash: self.hline('=') self.logo() self.author() self.hline('=') type(self).__print_splash = False