getpelican/pelican — pull request #857 by avaris (2013-04-19 17:56:57+00:00)
Title: add feedback to user and refactor 'autoreload' code

Currently Pelican works very silently. Too silently in fact. This PR adds feedback capabilities. In order to that, ``autoreload`` code had a face lift. It was using two functions (``file_changed`` and ``files_changed``) from ``utils``. They were using globals. They are now replaced with generator versions which eliminates the use of globals. And the related test is updated.

As for the feedbacks, this is sample output:

##### Normal #####

$ pelican -s pelican.conf.py -t theme content
Done: Processed 11 articles and 2 pages in 1.51 seconds.

$ pelican -s pelican.conf.py -t theme -r content
--- AutoReload Mode: Monitoring `content`, `theme` and `settings` for changes. ---

-> Modified: content, theme, settings. re-generating...
Done: Processed 11 articles and 2 pages in 0.96 seconds.

-> Modified: settings. re-generating...
Done: Processed 11 articles and 2 pages in 1.29 seconds.

-> Modified: content. re-generating...
Done: Processed 11 articles and 2 pages in 1.00 seconds.

##### Empty Theme #####

$ pelican -s pelican.conf.py -t empty_theme content
WARNING: Empty theme folder. Using `basic` theme.
WARNING: skipped copy /home/extra/workspace/web/feedback/empty_theme/static to /home/extra/workspace/web/feedback/output/theme
Done: Processed 11 articles and 2 pages in 0.58 seconds.

$ pelican -s pelican.conf.py -t empty_theme -r content
--- AutoReload Mode: Monitoring `content`, `theme` and `settings` for changes. ---

-> Modified: content, settings. re-generating...
WARNING: Empty theme folder. Using `basic` theme.
WARNING: skipped copy /home/extra/workspace/web/feedback/empty_theme/static to /home/extra/workspace/web/feedback/output/theme
Done: Processed 11 articles and 2 pages in 0.65 seconds.

##### Empty Content #####

$ pelican -s pelican.conf.py -t theme empty_content
WARNING: No valid files found in content.
Done: Processed 0 articles and 0 pages in 0.13 seconds.

$ pelican -s pelican.conf.py -t theme -r empty_content
--- AutoReload Mode: Monitoring `content`, `theme` and `settings` for changes. ---

-> Modified: theme, settings. re-generating...
WARNING: No valid files found in content.
Done: Processed 0 articles and 0 pages in 0.14 seconds.

##### Exception #####

$ pelican -s pelican.conf.py -t theme -r content
--- AutoReload Mode: Monitoring `content`, `theme` and `settings` for changes. ---

-> Modified: content, theme, settings. re-generating...
Done: Processed 11 articles and 2 pages in 1.00 seconds.

-> Modified: theme. re-generating...
WARNING: Caught exception "'article_page' is undefined". Reloading.

-> Modified: theme. re-generating...
Done: Processed 11 articles and 2 pages in 0.92 seconds.