mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
improve result output of a pelican run
* display count of hidden pages * pluralize only if necessary * add maybe_pluralize to utils * add tests for maybe_pluralize
This commit is contained in:
parent
940eb76b7f
commit
39fd4936b5
3 changed files with 50 additions and 7 deletions
|
|
@ -767,3 +767,19 @@ def path_to_file_url(path):
|
|||
'''Convert file-system path to file:// URL'''
|
||||
return six.moves.urllib_parse.urljoin(
|
||||
"file://", six.moves.urllib.request.pathname2url(path))
|
||||
|
||||
|
||||
def maybe_pluralize(count, singular, plural):
|
||||
'''
|
||||
Returns a formatted string containing count and plural if count is not 1
|
||||
Returns count and singular if count is 1
|
||||
|
||||
maybe_pluralize(0, 'Article', 'Articles') -> '0 Articles'
|
||||
maybe_pluralize(1, 'Article', 'Articles') -> '1 Article'
|
||||
maybe_pluralize(2, 'Article', 'Articles') -> '2 Articles'
|
||||
|
||||
'''
|
||||
selection = plural
|
||||
if count == 1:
|
||||
selection = singular
|
||||
return '{} {}'.format(count, selection)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue