From 08e39f5631030893a0e9a6b0f31d43635050b953 Mon Sep 17 00:00:00 2001 From: pictuga Date: Fri, 20 Mar 2020 12:20:15 +0100 Subject: [PATCH] feeds: give simpler name to helper functions --- morss/feeds.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/morss/feeds.py b/morss/feeds.py index 90c6530..1e6959e 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -245,7 +245,7 @@ class ParserBase(object): return self.rule_search_all(self.rules[rule_name]) - def get_str(self, rule_name): + def get(self, rule_name): # simple function to get nice text from the rule name # for use in @property, ie. self.get_str('title') if rule_name not in self.rules: @@ -253,7 +253,7 @@ class ParserBase(object): return self.rule_str(self.rules[rule_name]) - def set_str(self, rule_name, value): + def set(self, rule_name, value): if rule_name not in self.rules: return None @@ -607,12 +607,12 @@ class Feed(object): return [itemsClass(x, self.rules, self) for x in items] title = property( - lambda f: f.get_str('title'), - lambda f,x: f.set_str('title', x), + lambda f: f.get('title'), + lambda f,x: f.set('title', x), lambda f: f.rmv('title') ) description = desc = property( - lambda f: f.get_str('desc'), - lambda f,x: f.set_str('desc', x), + lambda f: f.get('desc'), + lambda f,x: f.set('desc', x), lambda f: f.rmv('desc') ) items = property( lambda f: f ) @@ -659,28 +659,28 @@ class Item(Uniq): return id(xml) title = property( - lambda f: f.get_str('item_title'), - lambda f,x: f.set_str('item_title', x), + lambda f: f.get('item_title'), + lambda f,x: f.set('item_title', x), lambda f: f.rmv('item_title') ) link = property( - lambda f: f.get_str('item_link'), - lambda f,x: f.set_str('item_link', x), + lambda f: f.get('item_link'), + lambda f,x: f.set('item_link', x), lambda f: f.rmv('item_link') ) description = desc = property( - lambda f: f.get_str('item_desc'), - lambda f,x: f.set_str('item_desc', x), + lambda f: f.get('item_desc'), + lambda f,x: f.set('item_desc', x), lambda f: f.rmv('item_desc') ) content = property( - lambda f: f.get_str('item_content'), - lambda f,x: f.set_str('item_content', x), + lambda f: f.get('item_content'), + lambda f,x: f.set('item_content', x), lambda f: f.rmv('item_content') ) time = property( - lambda f: f.time_prs(f.get_str('item_time')), - lambda f,x: f.set_str('item_time', f.time_fmt(x)), + lambda f: f.time_prs(f.get('item_time')), + lambda f,x: f.set('item_time', f.time_fmt(x)), lambda f: f.rmv('item_time') ) updated = property( - lambda f: f.time_prs(f.get_str('item_updated')), - lambda f,x: f.set_str('item_updated', f.time_fmt(x)), + lambda f: f.time_prs(f.get('item_updated')), + lambda f,x: f.set('item_updated', f.time_fmt(x)), lambda f: f.rmv('item_updated') )