feeds: add ability to convert to another typo of feed
parent
4ba4d73ce6
commit
1e714ab34b
|
@ -133,6 +133,19 @@ class ParserBase(object):
|
||||||
template = engine.get_template('reader')
|
template = engine.get_template('reader')
|
||||||
return template.render({'feed': self}).encode('utf-8')
|
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):
|
def iterdic(self):
|
||||||
for element in self.dic:
|
for element in self.dic:
|
||||||
value = getattr(self, element)
|
value = getattr(self, element)
|
||||||
|
|
Loading…
Reference in New Issue