From 1e714ab34b460c8c910a61ea55f28c11b0ac0a72 Mon Sep 17 00:00:00 2001 From: pictuga Date: Tue, 17 Mar 2020 14:02:24 +0100 Subject: [PATCH] feeds: add ability to convert to another typo of feed --- morss/feeds.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/morss/feeds.py b/morss/feeds.py index 43e3f89..25c0573 100644 --- a/morss/feeds.py +++ b/morss/feeds.py @@ -133,6 +133,19 @@ class ParserBase(object): template = engine.get_template('reader') return template.render({'feed': self}).encode('utf-8') + def convert(self, TargetParser): + target = TargetParser() + + for attr in target.dic: + if attr == 'items': + for item in self.items: + target.append(item) + + else: + setattr(target, attr, getattr(self, attr)) + + return target + def iterdic(self): for element in self.dic: value = getattr(self, element)