Skip to content

Commit

Permalink
fixup! Fix header of search result sections (RhBug:1301868)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrohel committed Apr 21, 2017
1 parent 1b1ceb1 commit dcc3921
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions dnf/cli/commands/search.py
Expand Up @@ -53,16 +53,23 @@ def set_argparser(parser):
def _search(self, args):
"""Search for simple text tags in a package object."""

def _translate_attr(attr):
TRANS_TBL = {'name': _('Name'),
'summary': _('Summary'),
'description': _('Description'),
'url': _('URL')
}
try:
return TRANS_TBL[attr]
except:
return attr

def _print_section_header(exact_match, attrs, keys):
section_text = ' or '.join(attrs) if exact_match else ' & '.join(attrs)
section_text = section_text.replace('name', _('Name'))
section_text = section_text.replace('summary', _('Summary'))
section_text = section_text.replace('description', _('Description'))
section_text = section_text.replace('url', _('URL'))
trans_attrs = map(_translate_attr, attrs)
if exact_match:
section_text = _('%s Exactly Matched: %%s') % section_text
section_text = _('%s Exactly Matched: %%s') % ' & '.join(trans_attrs)
else:
section_text = _('%s Matched: %%s') % section_text
section_text = _('%s Matched: %%s') % ' & '.join(trans_attrs)
formatted = self.base.output.fmtSection(section_text % ", ".join(keys))
print(ucd(formatted))

Expand Down

0 comments on commit dcc3921

Please sign in to comment.