From 9894b8e30c61f64d4e21d0404b724dbba764ccc1 Mon Sep 17 00:00:00 2001 From: Thomas Guillod Date: Fri, 30 Jun 2023 10:54:54 -0400 Subject: [PATCH] better alg for splash screen --- pypeec/main.py | 51 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/pypeec/main.py b/pypeec/main.py index eca08076..0fd95fe8 100644 --- a/pypeec/main.py +++ b/pypeec/main.py @@ -16,14 +16,29 @@ # create the logger LOGGER = log.get_logger("MAIN") -# get logo display status +# get the logo display status DISPLAY_LOGO = config.DISPLAY_LOGO -# display the logo -if DISPLAY_LOGO: - with importlib.resources.open_text("pypeec", "pypeec.txt") as file_logo: - data = file_logo.read() - print(data, flush=True) +# init the logo display status +STATUS_LOGO = False + + +def _display_logo(): + """ + Display the logo as a splash screen. + """ + + # variable with the logo status + global STATUS_LOGO + + # display the logo + if DISPLAY_LOGO and not STATUS_LOGO: + with importlib.resources.open_text("pypeec", "pypeec.txt") as file_logo: + data = file_logo.read() + print(data, flush=True) + + # logo has been displayed + STATUS_LOGO = True def run_mesher_data(data_geometry, **kwargs): @@ -48,6 +63,9 @@ def run_mesher_data(data_geometry, **kwargs): data_voxel: dict (output data) """ + # display logo + _display_logo() + # load the tool LOGGER.info("load the mesher") from pypeec.run import mesher @@ -83,6 +101,9 @@ def run_mesher_file(file_geometry, file_voxel, **kwargs): None if the termination is successful. """ + # display logo + _display_logo() + # run the tool try: # load data @@ -133,6 +154,9 @@ def run_viewer_data(data_voxel, data_point, data_viewer, **kwargs): None if the termination is successful. """ + # display logo + _display_logo() + # load the tool LOGGER.info("load the viewer") from pypeec.run import viewer @@ -176,6 +200,9 @@ def run_viewer_file(file_voxel, file_point, file_viewer, **kwargs): None if the termination is successful. """ + # display logo + _display_logo() + # run the tool try: # load data @@ -217,6 +244,9 @@ def run_solver_data(data_voxel, data_problem, data_tolerance, **kwargs): data_solution: dict (output data) """ + # display logo + _display_logo() + # load the tool LOGGER.info("load the solver") from pypeec.run import solver @@ -254,6 +284,9 @@ def run_solver_file(file_voxel, file_problem, file_tolerance, file_solution, **k None if the termination is successful. """ + # display logo + _display_logo() + # run the tool try: # load data @@ -309,6 +342,9 @@ def run_plotter_data(data_solution, data_point, data_plotter, **kwargs): None if the termination is successful. """ + # display logo + _display_logo() + # load the tool LOGGER.info("load the plotter") from pypeec.run import plotter @@ -355,6 +391,9 @@ def run_plotter_file(file_solution, file_point, file_plotter, **kwargs): None if the termination is successful. """ + # display logo + _display_logo() + # run the tool try: # load data