From 3c7f512583c87708d8192ee0b3f3ed46c511622f Mon Sep 17 00:00:00 2001 From: pictuga Date: Thu, 9 Apr 2020 19:09:10 +0200 Subject: [PATCH] feeds: handle several errors --- morss/feeds.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/morss/feeds.py b/morss/feeds.py index 98d174f..d66cd4b 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -269,8 +269,15 @@ class ParserBase(object): except AttributeError: # does not exist, have to create it - self.rule_create(self.rules[rule_name]) - self.rule_set(self.rules[rule_name], value) + try: + self.rule_create(self.rules[rule_name]) + + except AttributeError: + # no way to create it, give up + pass + + else: + self.rule_set(self.rules[rule_name], value) def rmv(self, rule_name): # easy deleter @@ -469,6 +476,9 @@ class ParserHTML(ParserXML): element = deepcopy(match) match.getparent().append(element) + else: + raise AttributeError('no way to create item') + def parse_time(value): if value is None or value == 0: