mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-25 01:06:50 +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"',
|
||||
'end': 'time (end) of creation 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 = (
|
||||
('archive', 'name', 'barchive', 'comment', 'bcomment', 'id'),
|
||||
('start', 'time', 'end'),
|
||||
('hostname', 'username'),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
@ -563,8 +566,10 @@ def __init__(self, format, repository, manifest, key, *, json=False):
|
|||
self.format = partial_format(format, static_keys)
|
||||
self.format_keys = {f[1] for f in Formatter().parse(format)}
|
||||
self.call_keys = {
|
||||
'comment': partial(self.get_comment, rs=True),
|
||||
'bcomment': partial(self.get_comment, rs=False),
|
||||
'hostname': partial(self.get_meta, 'hostname', rs=True),
|
||||
'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,
|
||||
}
|
||||
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)
|
||||
return self._archive
|
||||
|
||||
def get_comment(self, rs):
|
||||
return remove_surrogates(self.archive.comment) if rs else self.archive.comment
|
||||
def get_meta(self, key, rs):
|
||||
value = self.archive.metadata.get(key, '')
|
||||
return remove_surrogates(value) if rs else value
|
||||
|
||||
def get_ts_end(self):
|
||||
return self.format_time(self.archive.ts_end)
|
||||
|
|
Loading…
Reference in a new issue