From 45ff578f69df5c0f8eb3728569e9e583469d7f1c Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 10 Aug 2015 15:44:13 -0400 Subject: [PATCH] Added optional override_output to write_feed. The write_feed function now takes an override_output parameter that does the same thing as override_output does to write_file. Implemented for custom generators. --- pelican/writers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pelican/writers.py b/pelican/writers.py index e90a0004..36d2f038 100644 --- a/pelican/writers.py +++ b/pelican/writers.py @@ -79,7 +79,8 @@ class Writer(object): self._written_files.add(filename) return open(filename, 'w', encoding=encoding) - def write_feed(self, elements, context, path=None, feed_type='atom'): + def write_feed(self, elements, context, path=None, feed_type='atom', + override_output=False): """Generate a feed with the list of articles provided Return the feed. If no path or output_path is specified, just @@ -89,6 +90,9 @@ class Writer(object): :param context: the context to get the feed metadata. :param path: the path to output. :param feed_type: the feed type to use (atom or rss) + :param override_output: boolean telling if we can override previous + output with the same name (and if next files written with the same + name should be skipped to keep that one) """ if not is_selected_for_writing(self.settings, path): return @@ -115,7 +119,7 @@ class Writer(object): pass encoding = 'utf-8' if six.PY3 else None - with self._open_w(complete_path, encoding) as fp: + with self._open_w(complete_path, encoding, override_output) as fp: feed.write(fp, 'utf-8') logger.info('Writing %s', complete_path)