From ce30952fa2c670a78a3fd99f906f8c0cafcc5adf Mon Sep 17 00:00:00 2001 From: pictuga Date: Mon, 16 Mar 2020 17:46:04 +0100 Subject: [PATCH] feeds: make "rule" split clearer "rrule" var name to tell appart the original "rule" from the parsed one --- morss/feeds.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/morss/feeds.py b/morss/feeds.py index bbd958e..e0cbb2f 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -278,14 +278,14 @@ class ParserXML(ParserBase): def rule_create(self, rule): # duplicate, copy from template or create from scratch - rule, key = self._rule_parse(rule) + rrule, key = self._rule_parse(rule) - # try recreating based on the rule (for really basic rules, ie. plain RSS) - if re.search(r'^[a-zA-Z0-9/:]+$', rule): - chain = rule.strip('/').split('/') + # try recreating based on the rule (for really basic rules, ie. plain RSS) `/feed/item` + if re.search(r'^[a-zA-Z0-9/:]+$', rrule): + chain = rrule.strip('/').split('/') current = self.root - if rule[0] == '/': + if rrule[0] == '/': chain = chain[1:] for (i, node) in enumerate(chain): @@ -304,7 +304,7 @@ class ParserXML(ParserBase): return current # try duplicating from existing (works well with fucked up structures) - match = self.rule_search_last(rule) + match = self.rule_search_last(rrule) if match: element = deepcopy(match) match.getparent().append(element) @@ -317,9 +317,9 @@ class ParserXML(ParserBase): return None def rule_remove(self, rule): - rule, key = self._rule_parse(rule) + rrule, key = self._rule_parse(rule) - match = self.rule_search(rule) + match = self.rule_search(rrule) if match is None: return @@ -331,9 +331,9 @@ class ParserXML(ParserBase): match.getparent().remove(match) def rule_set(self, rule, value): - rule, key = self._rule_parse(rule) + rrule, key = self._rule_parse(rule) - match = self.rule_search(rule) + match = self.rule_search(rrule) if key is not None: match.attrib[key] = value