Merge pull request #4185 from ThomasWaldmann/more-placeholders-1.1

list repo: add placeholders for hostname and username, fixes #4130
This commit is contained in:
TW 2018-11-28 01:17:25 +01:00 committed by GitHub
commit 0db87c116a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -1689,10 +1689,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
@ -1735,8 +1738,10 @@ class ArchiveFormatter(BaseFormatter):
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
@ -1774,8 +1779,9 @@ class ArchiveFormatter(BaseFormatter):
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)