mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 01:37:20 +00:00
list repo: add placeholders for hostname and username, fixes #4130
also: use a more generic get_meta() access method to avoid duplication.
This commit is contained in:
parent
29cbf5cd53
commit
e9ac9beef0
1 changed files with 10 additions and 4 deletions
|
@ -516,10 +516,13 @@ class ArchiveFormatter(BaseFormatter):
|
||||||
'time': 'alias of "start"',
|
'time': 'alias of "start"',
|
||||||
'end': 'time (end) of creation of the archive',
|
'end': 'time (end) of creation of the archive',
|
||||||
'id': 'internal ID of the archive',
|
'id': 'internal ID of the archive',
|
||||||
|
'hostname': 'hostname of host on which this archive was created',
|
||||||
|
'username': 'username of user who created this archive',
|
||||||
}
|
}
|
||||||
KEY_GROUPS = (
|
KEY_GROUPS = (
|
||||||
('archive', 'name', 'barchive', 'comment', 'bcomment', 'id'),
|
('archive', 'name', 'barchive', 'comment', 'bcomment', 'id'),
|
||||||
('start', 'time', 'end'),
|
('start', 'time', 'end'),
|
||||||
|
('hostname', 'username'),
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -563,8 +566,10 @@ def __init__(self, format, repository, manifest, key, *, json=False):
|
||||||
self.format = partial_format(format, static_keys)
|
self.format = partial_format(format, static_keys)
|
||||||
self.format_keys = {f[1] for f in Formatter().parse(format)}
|
self.format_keys = {f[1] for f in Formatter().parse(format)}
|
||||||
self.call_keys = {
|
self.call_keys = {
|
||||||
'comment': partial(self.get_comment, rs=True),
|
'hostname': partial(self.get_meta, 'hostname', rs=True),
|
||||||
'bcomment': partial(self.get_comment, rs=False),
|
'username': partial(self.get_meta, 'username', rs=True),
|
||||||
|
'comment': partial(self.get_meta, 'comment', rs=True),
|
||||||
|
'bcomment': partial(self.get_meta, 'comment', rs=False),
|
||||||
'end': self.get_ts_end,
|
'end': self.get_ts_end,
|
||||||
}
|
}
|
||||||
self.used_call_keys = set(self.call_keys) & self.format_keys
|
self.used_call_keys = set(self.call_keys) & self.format_keys
|
||||||
|
@ -602,8 +607,9 @@ def archive(self):
|
||||||
self._archive = Archive(self.repository, self.key, self.manifest, self.name)
|
self._archive = Archive(self.repository, self.key, self.manifest, self.name)
|
||||||
return self._archive
|
return self._archive
|
||||||
|
|
||||||
def get_comment(self, rs):
|
def get_meta(self, key, rs):
|
||||||
return remove_surrogates(self.archive.comment) if rs else self.archive.comment
|
value = self.archive.metadata.get(key, '')
|
||||||
|
return remove_surrogates(value) if rs else value
|
||||||
|
|
||||||
def get_ts_end(self):
|
def get_ts_end(self):
|
||||||
return self.format_time(self.archive.ts_end)
|
return self.format_time(self.archive.ts_end)
|
||||||
|
|
Loading…
Reference in a new issue