mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-01 01:06:59 +00:00
print_warning*: support warning msgids, fixes #7080
This commit is contained in:
parent
5168a97782
commit
4adc782100
1 changed files with 4 additions and 2 deletions
|
@ -133,19 +133,21 @@ def print_warning(self, msg, *args, **kw):
|
||||||
warning_code = kw.get("wc", EXIT_WARNING) # note: wc=None can be used to not influence exit code
|
warning_code = kw.get("wc", EXIT_WARNING) # note: wc=None can be used to not influence exit code
|
||||||
warning_type = kw.get("wt", "percent")
|
warning_type = kw.get("wt", "percent")
|
||||||
assert warning_type in ("percent", "curly")
|
assert warning_type in ("percent", "curly")
|
||||||
|
warning_msgid = kw.get("msgid")
|
||||||
if warning_code is not None:
|
if warning_code is not None:
|
||||||
add_warning(msg, *args, wc=warning_code, wt=warning_type)
|
add_warning(msg, *args, wc=warning_code, wt=warning_type)
|
||||||
if warning_type == "percent":
|
if warning_type == "percent":
|
||||||
output = args and msg % args or msg
|
output = args and msg % args or msg
|
||||||
else: # == "curly"
|
else: # == "curly"
|
||||||
output = args and msg.format(*args) or msg
|
output = args and msg.format(*args) or msg
|
||||||
logger.warning(output)
|
logger.warning(output, msgid=warning_msgid) if warning_msgid else logger.warning(output)
|
||||||
|
|
||||||
def print_warning_instance(self, warning):
|
def print_warning_instance(self, warning):
|
||||||
assert isinstance(warning, BorgWarning)
|
assert isinstance(warning, BorgWarning)
|
||||||
msg = type(warning).__doc__
|
msg = type(warning).__doc__
|
||||||
|
msgid = type(warning).__qualname__
|
||||||
args = warning.args
|
args = warning.args
|
||||||
self.print_warning(msg, *args, wc=warning.exit_code, wt="curly")
|
self.print_warning(msg, *args, wc=warning.exit_code, wt="curly", msgid=msgid)
|
||||||
|
|
||||||
def print_file_status(self, status, path):
|
def print_file_status(self, status, path):
|
||||||
# if we get called with status == None, the final file status was already printed
|
# if we get called with status == None, the final file status was already printed
|
||||||
|
|
Loading…
Reference in a new issue