mirror of https://github.com/scrapy/scrapy.git
Make check of placeholder less strict
This commit is contained in:
parent
1e245046ed
commit
6454d456d2
|
|
@ -448,11 +448,12 @@ generated:
|
|||
* ``%(batch_time)s`` - gets replaced by a timestamp when the feed is being created
|
||||
(e.g. ``2020-03-28T14-45-08.237134``)
|
||||
|
||||
* ``%(batch_id)0xd`` - gets replaced by the sequence number of the batch.
|
||||
By replacing ``x`` with an integer you set the number of leading zeroes to prevent
|
||||
inappropriate sorting like this: [``'1'``, ``'10'``, ``'2'``]. Here are some examples:
|
||||
``%(batch_id)01d`` for the second batch gets replaced by ``2``
|
||||
``%(batch_id)05d`` for the third batch gets replaced by ``00003``
|
||||
* ``%(batch_id)d`` - gets replaced by the sequence number of the batch.
|
||||
|
||||
Use :ref:`printf-style string formatting <python:old-string-formatting>` to
|
||||
alter the number format. For example, to make the batch ID a 5-digit
|
||||
number by introducing leading zeroes as needed, use ``%(batch_id)05d``
|
||||
(e.g. ``3`` becomes ``00003``, ``123`` becomes ``00123``).
|
||||
|
||||
For instance, if your settings include::
|
||||
|
||||
|
|
|
|||
|
|
@ -375,9 +375,9 @@ class FeedExporter:
|
|||
%(batch_time)s or %(batch_id)s to distinguish different files of partial output
|
||||
"""
|
||||
for uri_template, values in self.feeds.items():
|
||||
if values['batch_item_count'] and not re.findall(r'(%\(batch_time\)s|(%\(batch_id\)0\d*d))', uri_template):
|
||||
if values['batch_item_count'] and not re.search(r'%\(batch_time\)s|%\(batch_id\)', uri_template):
|
||||
logger.error(
|
||||
'%(batch_time)s or %(batch_id)0xd must be in uri({}) if FEED_EXPORT_BATCH_ITEM_COUNT setting '
|
||||
'%(batch_time)s or %(batch_id) must be in uri({}) if FEED_EXPORT_BATCH_ITEM_COUNT setting '
|
||||
'or FEEDS.batch_item_count is specified and greater than 0. For more info see:'
|
||||
'https://docs.scrapy.org/en/latest/topics/feed-exports.html#feed-export-batch-item-count'
|
||||
''.format(uri_template)
|
||||
|
|
|
|||
|
|
@ -1265,7 +1265,7 @@ class BatchDeliveriesTest(FeedExportTestBase):
|
|||
yield self.assertExported(items, header, rows, settings=Settings(settings))
|
||||
|
||||
def test_wrong_path(self):
|
||||
""" If path is without %(batch_time)s and %(batch_id)0xd an exception must be raised """
|
||||
""" If path is without %(batch_time)s and %(batch_id) an exception must be raised """
|
||||
settings = {
|
||||
'FEEDS': {
|
||||
self._random_temp_filename(): {'format': 'xml'},
|
||||
|
|
|
|||
Loading…
Reference in New Issue