From 6d5aa8c222b50ebbcc85d2eede9e44bb9b9743ef Mon Sep 17 00:00:00 2001 From: pictuga Date: Tue, 17 Mar 2020 13:59:51 +0100 Subject: [PATCH] feeds: clean up .append() --- morss/feeds.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/morss/feeds.py b/morss/feeds.py index 6201d7f..bad9ede 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -440,12 +440,16 @@ class Feed(object): if new is None: return - for attr in globals()[self.itemsClass].dic: - if hasattr(new, attr): + for attr in self.dic: + try: setattr(item, attr, getattr(new, attr)) - elif attr in new: - setattr(item, attr, new[attr]) + except AttributeError: + try: + setattr(item, attr, new[attr]) + + except (IndexError, TypeError): + pass def __getitem__(self, key): return self.wrap_items(self.get_raw('items'))[key]