Mercurial > kallithea
view .coveragerc @ 7645:e0626084e9c5 stable
files: remove need for webhelpers.html.literal
The following code is unnecessarily complex:
h.literal(_('There are no files yet. %s') % add_new)
First of all, the '%s' part in the translatable string is a whole new
sentence, independent of the first. There is no reason it needs to be part
of the same translatable string.
Secondly, the only reason for h.literal is to preserve the link in
'add_new' (which contains the result of 'h.link_to'). But, h.link_to
actually already is a 'literal' object. The problem is that the special
'literal' property is lost due to the coercion into a plain string via the
'%' operator.
The following code would be a possible solution for the second issue:
h.HTML(_('There are no files yet. %s')) % add_new
i.e. make sure that the format string is not a plain string but itself a
literal object (after its contents being escaped), before applying the '%'
operator.
To handle the first issue, this would become:
h.HTML(_('There are no files yet.')) + ' ' + h.HTML(add_new)
but, here h.HTML is unnecessary on the first string because there is nothing
special about it, and equally unnecessary on the 'add_new' variable because
h.link_to already returns a literal object.
So, the final code becomes:
_('There are no files yet.') + ' ' + add_new
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Thu, 18 Apr 2019 21:33:23 +0200 |
parents | 4b241f198cf2 |
children | d332fca29474 |
line wrap: on
line source
[run] omit = # the bin scripts are not part of the Kallithea web app kallithea/bin/* # we ship with no active extensions kallithea/config/rcextensions/* # dbmigrate is not a part of the Kallithea web app kallithea/lib/dbmigrate/* # the tests themselves should not be part of the coverage report kallithea/tests/* # the scm hooks are not run in the kallithea process kallithea/config/post_receive_tmpl.py kallithea/config/pre_receive_tmpl.py # same omit lines should be present in sections 'run' and 'report' [report] omit = # the bin scripts are not part of the Kallithea web app kallithea/bin/* # we ship with no active extensions kallithea/config/rcextensions/* # dbmigrate is not a part of the Kallithea web app kallithea/lib/dbmigrate/* # the tests themselves should not be part of the coverage report kallithea/tests/* # the scm hooks are not run in the kallithea process kallithea/config/post_receive_tmpl.py kallithea/config/pre_receive_tmpl.py [paths] source = kallithea/ **/workspace/*/kallithea