mirror of https://github.com/scrapy/scrapy.git
added marshal to formats supported by feed exports
This commit is contained in:
parent
884dc93ab7
commit
cb95d7a5af
|
|
@ -64,6 +64,15 @@ XML
|
|||
* :setting:`FEED_FORMAT`: ``xml``
|
||||
* Exporter used: :class:`~scrapy.contrib.exporter.XmlItemExporter`
|
||||
|
||||
.. _topics-feed-format-marshal:
|
||||
|
||||
Marshal
|
||||
-------
|
||||
|
||||
* :setting:`FEED_FORMAT`: ``marshal``
|
||||
* Exporter used: :class:`~scrapy.contrib.exporter.MarshalItemExporter`
|
||||
|
||||
|
||||
.. _topics-feed-storage:
|
||||
|
||||
Storages
|
||||
|
|
@ -267,6 +276,7 @@ Default::
|
|||
'jsonlines': 'scrapy.contrib.exporter.JsonLinesItemExporter',
|
||||
'csv': 'scrapy.contrib.exporter.CsvItemExporter',
|
||||
'xml': 'scrapy.contrib.exporter.XmlItemExporter',
|
||||
'marshal': 'scrapy.contrib.exporter.MarshalItemExporter',
|
||||
}
|
||||
|
||||
A dict containing the built-in feed exporters supported by Scrapy.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ Item Exporters are used to export/serialize items into different formats.
|
|||
|
||||
import csv
|
||||
import pprint
|
||||
import marshal
|
||||
from cPickle import Pickler
|
||||
from xml.sax.saxutils import XMLGenerator
|
||||
|
||||
|
|
@ -12,7 +13,7 @@ from scrapy.utils.py26 import json
|
|||
|
||||
__all__ = ['BaseItemExporter', 'PprintItemExporter', 'PickleItemExporter', \
|
||||
'CsvItemExporter', 'XmlItemExporter', 'JsonLinesItemExporter', \
|
||||
'JsonItemExporter']
|
||||
'JsonItemExporter', 'MarshalItemExporter']
|
||||
|
||||
class BaseItemExporter(object):
|
||||
|
||||
|
|
@ -185,6 +186,16 @@ class PickleItemExporter(BaseItemExporter):
|
|||
self.pickler.dump(dict(self._get_serialized_fields(item)))
|
||||
|
||||
|
||||
class MarshalItemExporter(BaseItemExporter):
|
||||
|
||||
def __init__(self, file, **kwargs):
|
||||
self._configure(kwargs)
|
||||
self.file = file
|
||||
|
||||
def export_item(self, item):
|
||||
marshal.dump(dict(self._get_serialized_fields(item)), self.file)
|
||||
|
||||
|
||||
class PprintItemExporter(BaseItemExporter):
|
||||
|
||||
def __init__(self, file, **kwargs):
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ FEED_EXPORTERS_BASE = {
|
|||
'jsonlines': 'scrapy.contrib.exporter.JsonLinesItemExporter',
|
||||
'csv': 'scrapy.contrib.exporter.CsvItemExporter',
|
||||
'xml': 'scrapy.contrib.exporter.XmlItemExporter',
|
||||
'marshal': 'scrapy.contrib.exporter.MarshalItemExporter',
|
||||
}
|
||||
|
||||
HTTPCACHE_ENABLED = False
|
||||
|
|
|
|||
Loading…
Reference in New Issue