From cfd758b6b527cda80e4c923aca7fa460f5d5202d Mon Sep 17 00:00:00 2001 From: pictuga Date: Fri, 26 Oct 2018 19:48:39 +0200 Subject: [PATCH] feeds: shift easy ones to @property --- morss/feeds.py | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/morss/feeds.py b/morss/feeds.py index 7aadb93..a2cd71f 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -363,8 +363,14 @@ class FeedParser(FeedBase): def get_items(self): return [] - title = FeedDescriptor('title') - description = desc = FeedDescriptor('desc') + title = property( + lambda f: f.get_title(), + lambda f,x: f.set_title(x), + lambda f: f.del_title() ) + description = desc = property( + lambda f: f.get_desc(), + lambda f,x: f.set_desc(x), + lambda f: f.del_desc() ) items = FeedListDescriptor('items') def tostring(self, **k): @@ -548,11 +554,26 @@ class FeedItem(FeedBase): def del_updated(self): self.updated = None - title = FeedDescriptor('title') - link = FeedDescriptor('link') - description = desc = FeedDescriptor('desc') - content = FeedDescriptor('content') - id = FeedDescriptor('id') + title = property( + lambda f: f.get_title(), + lambda f,x: f.set_title(x), + lambda f: f.del_title() ) + link = property( + lambda f: f.get_link(), + lambda f,x: f.set_link(x), + lambda f: f.del_link() ) + description = desc = property( + lambda f: f.get_desc(), + lambda f,x: f.set_desc(x), + lambda f: f.del_desc() ) + content = property( + lambda f: f.get_content(), + lambda f,x: f.set_content(x), + lambda f: f.del_content() ) + id = property( + lambda f: f.get_id(), + lambda f,x: f.set_id(x), + lambda f: f.del_id() ) is_permalink = FeedBool('is_permalink') time = FeedTime('time') updated = FeedTime('updated')