From: Frank Brehm Date: Thu, 15 Jun 2023 14:18:05 +0000 (+0200) Subject: Including xlate informations in as_dict() X-Git-Tag: 0.10.0^2~8 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=e366cf0d49655fc0de2d0cbd723bb616e44e6d7e;p=pixelpark%2Fpp-admin-tools.git Including xlate informations in as_dict() --- diff --git a/lib/pp_admintools/app/__init__.py b/lib/pp_admintools/app/__init__.py index 49c5579..e3abc1f 100644 --- a/lib/pp_admintools/app/__init__.py +++ b/lib/pp_admintools/app/__init__.py @@ -21,14 +21,18 @@ from fb_tools.multi_config import BaseMultiConfig from .. import DEFAULT_CONFIG_DIR from .. import DEFAULT_TERMINAL_HEIGHT, DEFAULT_TERMINAL_WIDTH from .. import __version__ as GLOBAL_VERSION -from ..xlate import XLATOR +from ..xlate import DOMAIN, LOCALE_DIR, XLATOR +from ..xlate import __base_dir__ as __xlate_base_dir__ +from ..xlate import __lib_dir__ as __xlate_lib_dir__ +from ..xlate import __mo_file__ as __xlate_mo_file__ +from ..xlate import __module_dir__ as __xlate_module_dir__ LOG = logging.getLogger(__name__) _ = XLATOR.gettext ngettext = XLATOR.ngettext -__version__ = '0.6.5' +__version__ = '0.7.0' # ============================================================================= @@ -68,6 +72,32 @@ class BaseDPXApplication(FbConfigApplication): env_prefix=env_prefix, config_dir=config_dir ) + # ------------------------------------------------------------------------- + def as_dict(self, short=True): + """ + Transform the elements of the object into a dict. + + @param short: don't include local properties in resulting dict. + @type short: bool + + @return: structure as dict + @rtype: dict + """ + res = super(BaseDPXApplication, self).as_dict(short=short) + + if 'xlate' not in res: + res['xlate'] = {} + res['xlate'][DOMAIN] = { + '__module_dir__': __xlate_module_dir__, + '__lib_dir__': __xlate_lib_dir__, + '__base_dir__': __xlate_base_dir__, + 'LOCALE_DIR': LOCALE_DIR, + 'DOMAIN': DOMAIN, + '__mo_file__': __xlate_mo_file__, + } + + return res + # ------------------------------------------------------------------------- def line(self, width=None, linechar='-', color=None): """Print out an line on stdout, if not in quiet mode."""