From 68afee5d5a661edc4bb06ee71d7d4a30a85c163a Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 27 Oct 2022 13:56:41 +0200 Subject: [PATCH] Fixing method line() in lib/pp_admintools/app/__init__.py --- lib/pp_admintools/app/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/pp_admintools/app/__init__.py b/lib/pp_admintools/app/__init__.py index cc9e1b3..aebc717 100644 --- a/lib/pp_admintools/app/__init__.py +++ b/lib/pp_admintools/app/__init__.py @@ -9,6 +9,7 @@ from __future__ import absolute_import # Standard modules import logging +import shutil # Third party modules from fb_tools.cfg_app import FbConfigApplication @@ -18,6 +19,7 @@ from fb_tools.multi_config import BaseMultiConfig # Own modules from .. import __version__ as GLOBAL_VERSION from .. import DEFAULT_CONFIG_DIR +from .. import DEFAULT_TERMINAL_WIDTH, DEFAULT_TERMINAL_HEIGHT from ..xlate import XLATOR @@ -26,7 +28,7 @@ LOG = logging.getLogger(__name__) _ = XLATOR.gettext ngettext = XLATOR.ngettext -__version__ = '0.6.1' +__version__ = '0.6.3' # ============================================================================= @@ -67,7 +69,7 @@ class BaseDPXApplication(FbConfigApplication): ) # ------------------------------------------------------------------------- - def line(self, width=80, linechar='-', color=None): + def line(self, width=None, linechar='-', color=None): """Print out an line on stdout, if not in quiet mode.""" if self.quiet: return @@ -76,9 +78,13 @@ class BaseDPXApplication(FbConfigApplication): if not lchar: lchar = '-' + if not width: + term_size = shutil.get_terminal_size((DEFAULT_TERMINAL_WIDTH, DEFAULT_TERMINAL_HEIGHT)) + width = term_size.columns + lin = (lchar * width)[0:width] if color: - lin=self.colored(lin, color) + lin = self.colored(lin, color) print(lin) # ------------------------------------------------------------------------- -- 2.39.5