Repository: getpelican/pelican

Issue:
Hidden pages not counted when generating
If you set status to hidden on a page it won't be counted when generating. These pages are nonetheless generated. So there should be a counter for hidden as well. 



Discussion:

Resolving patch:
diff --git a/pelican/__init__.py b/pelican/__init__.py
--- a/pelican/__init__.py
+++ b/pelican/__init__.py
@@ -22,7 +22,8 @@
                                 TemplatePagesGenerator)
 from pelican.readers import Readers
 from pelican.settings import read_settings
-from pelican.utils import clean_output_dir, folder_watcher, file_watcher
+from pelican.utils import (clean_output_dir, folder_watcher,
+                           file_watcher, maybe_pluralize)
 from pelican.writers import Writer
 
 __version__ = "3.5.0"
@@ -183,12 +184,32 @@ def run(self):
         pages_generator = next(g for g in generators
                                if isinstance(g, PagesGenerator))
 
-        print('Done: Processed {} article(s), {} draft(s) and {} page(s) in ' \
-              '{:.2f} seconds.'.format(
-            len(articles_generator.articles) + len(articles_generator.translations),
-            len(articles_generator.drafts) + \
-            len(articles_generator.drafts_translations),
-            len(pages_generator.pages) + len(pages_generator.translations),
+        pluralized_articles = maybe_pluralize(
+            len(articles_generator.articles) +
+                len(articles_generator.translations),
+            'article',
+            'articles')
+        pluralized_drafts = maybe_pluralize(
+            len(articles_generator.drafts) +
+                len(articles_generator.drafts_translations),
+            'draft',
+            'drafts')
+        pluralized_pages = maybe_pluralize(
+            len(pages_generator.pages) +
+                len(pages_generator.translations),
+            'page',
+            'pages')
+        pluralized_hidden_pages = maybe_pluralize(
+            len(pages_generator.hidden_pages) +
+                len(pages_generator.hidden_translations),
+            'hidden page',
+            'hidden pages')
+
+        print('Done: Processed {}, {}, {} and {} in {:.2f} seconds.'.format(
+            pluralized_articles,
+            pluralized_drafts,
+            pluralized_pages,
+            pluralized_hidden_pages,
             time.time() - start_time))
 
     def get_generator_classes(self):
diff --git a/pelican/utils.py b/pelican/utils.py
--- a/pelican/utils.py
+++ b/pelican/utils.py
@@ -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)


Test patch:
diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py
--- a/pelican/tests/test_utils.py
+++ b/pelican/tests/test_utils.py
@@ -358,6 +358,12 @@ def test_strftime_locale_dependent_french(self):
         locale.setlocale(locale.LC_ALL, old_locale)
 
 
+    def test_maybe_pluralize(self):
+        self.assertEqual(utils.maybe_pluralize(0, 'Article', 'Articles'), '0 Articles')
+        self.assertEqual(utils.maybe_pluralize(1, 'Article', 'Articles'), '1 Article')
+        self.assertEqual(utils.maybe_pluralize(2, 'Article', 'Articles'), '2 Articles')
+
+
 class TestCopy(unittest.TestCase):
     '''Tests the copy utility'''