PySimLogger: move cmd2 import to where it is needed

The PySimLogger has a dependency to cmd2, however this dependency is
only required in one specific corner case. We can move the import
to the related code section and remove the dependency for all other
cases.

Change-Id: Idfdfcd27eef8d87bea75230600c7be1e7a8ba749
Related: SYS#6959
This commit is contained in:
Philipp Maier
2026-06-09 11:22:44 +02:00
parent 0f4ab37003
commit e92a4ee382
+1 -1
View File
@@ -24,7 +24,6 @@
#
import logging
from cmd2 import style
class _PySimLogHandler(logging.Handler):
def __init__(self, log_callback):
@@ -121,6 +120,7 @@ class PySimLogger:
if isinstance(color, str):
PySimLogger.print_callback(color + formatted_message + "\033[0m")
else:
from cmd2 import style
PySimLogger.print_callback(style(formatted_message, fg = color))
else:
PySimLogger.print_callback(formatted_message)