feeds: make it possible to append empty items

And return the newly appended items, to make it easy to edit them
master
pictuga 2020-10-03 16:56:07 +02:00
parent 6966e03bef
commit 8cb7002fe6
1 changed files with 2 additions and 3 deletions

View File

@ -668,9 +668,6 @@ class Feed(object):
self.rule_create(self.rules['items']) self.rule_create(self.rules['items'])
item = self.items[-1] item = self.items[-1]
if new is None:
return
for attr in self.itemsClass.dic: for attr in self.itemsClass.dic:
try: try:
setattr(item, attr, getattr(new, attr)) setattr(item, attr, getattr(new, attr))
@ -682,6 +679,8 @@ class Feed(object):
except (IndexError, TypeError): except (IndexError, TypeError):
pass pass
return item
def __getitem__(self, key): def __getitem__(self, key):
return self.wrap_items(self.get_raw('items'))[key] return self.wrap_items(self.get_raw('items'))[key]