Consolidate and slightly simplify some warning message emittances
Marco Ricci

Marco Ricci commited on 2025-01-07 11:09:38
Zeige 1 geänderte Dateien mit 3 Einfügungen und 9 Löschungen.

... ...
@@ -3296,7 +3296,6 @@ def derivepassphrase_vault(  # noqa: C901,PLR0912,PLR0913,PLR0914,PLR0915
3296 3296
                 view['key'] = key
3297 3297
             elif use_phrase:
3298 3298
                 view['phrase'] = phrase
3299
-                settings_type = 'service' if service else 'global'
3300 3299
                 try:
3301 3300
                     _check_for_misleading_passphrase(
3302 3301
                         ('services', service) if service else ('global',),
... ...
@@ -3314,20 +3313,15 @@ def derivepassphrase_vault(  # noqa: C901,PLR0912,PLR0913,PLR0914,PLR0915
3314 3313
                     )
3315 3314
                 if 'key' in settings:
3316 3315
                     if service:
3317
-                        logger.warning(
3318
-                            _msg.TranslatedString(
3316
+                        w_msg = _msg.TranslatedString(
3319 3317
                             _msg.WarnMsgTemplate.SERVICE_PASSPHRASE_INEFFECTIVE,
3320 3318
                             service=json.dumps(service),
3321
-                            ),
3322
-                            extra={'color': ctx.color},
3323 3319
                         )
3324 3320
                     else:
3325
-                        logger.warning(
3326
-                            _msg.TranslatedString(
3321
+                        w_msg = _msg.TranslatedString(
3327 3322
                             _msg.WarnMsgTemplate.GLOBAL_PASSPHRASE_INEFFECTIVE
3328
-                            ),
3329
-                            extra={'color': ctx.color},
3330 3323
                         )
3324
+                    logger.warning(w_msg, extra={'color': ctx.color})
3331 3325
             if not view.maps[0] and not unset_settings:
3332 3326
                 settings_type = 'service' if service else 'global'
3333 3327
                 err_msg = _msg.TranslatedString(
3334 3328