mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #1797 from TC01/feeds_override
Add optional override_output to write_feed
This commit is contained in:
commit
f16ae07d78
1 changed files with 6 additions and 2 deletions
|
|
@ -81,7 +81,8 @@ class Writer(object):
|
||||||
self._written_files.add(filename)
|
self._written_files.add(filename)
|
||||||
return open(filename, 'w', encoding=encoding)
|
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
|
"""Generate a feed with the list of articles provided
|
||||||
|
|
||||||
Return the feed. If no path or output_path is specified, just
|
Return the feed. If no path or output_path is specified, just
|
||||||
|
|
@ -91,6 +92,9 @@ class Writer(object):
|
||||||
:param context: the context to get the feed metadata.
|
:param context: the context to get the feed metadata.
|
||||||
:param path: the path to output.
|
:param path: the path to output.
|
||||||
:param feed_type: the feed type to use (atom or rss)
|
: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):
|
if not is_selected_for_writing(self.settings, path):
|
||||||
return
|
return
|
||||||
|
|
@ -117,7 +121,7 @@ class Writer(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
encoding = 'utf-8' if six.PY3 else None
|
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')
|
feed.write(fp, 'utf-8')
|
||||||
logger.info('Writing %s', complete_path)
|
logger.info('Writing %s', complete_path)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue