| 86 | | |
| 87 | | class ScrapedItem(BaseItem): |
| 88 | | |
| 89 | | def __init__(self, data=None): |
| 90 | | """ |
| 91 | | A ScrapedItem can be initialised with a dictionary that will be |
| 92 | | squirted directly into the object. |
| 93 | | """ |
| 94 | | import warnings |
| 95 | | warnings.warn("scrapy.item.ScrapedItem is deprecated, use scrapy.item.Item instead", |
| 96 | | DeprecationWarning, stacklevel=2) |
| 97 | | if isinstance(data, dict): |
| 98 | | for attr, value in data.iteritems(): |
| 99 | | setattr(self, attr, value) |
| 100 | | elif data is not None: |
| 101 | | raise TypeError("Initialize with dict, not %s" % data.__class__.__name__) |
| 102 | | |
| 103 | | def __repr__(self): |
| 104 | | """ |
| 105 | | Generate the following format so that items can be deserialized |
| 106 | | easily: ClassName({'attrib': value, ...}) |
| 107 | | """ |
| 108 | | reprdict = dict(items for items in self.__dict__.iteritems() \ |
| 109 | | if not items[0].startswith('_')) |
| 110 | | return "%s(%s)" % (self.__class__.__name__, repr(reprdict)) |
| 111 | | |