add simple write method
This commit is contained in:
@@ -1 +1,31 @@
|
||||
__author__ = 'stubbfel'
|
||||
|
||||
import feedparser
|
||||
from utilities.textfile import TextFile
|
||||
|
||||
|
||||
class FeedFile(TextFile):
|
||||
|
||||
def __init__(self, filename):
|
||||
"""
|
||||
init class
|
||||
:param filename: path to the file
|
||||
"""
|
||||
super(FeedFile, self).__init__(filename)
|
||||
|
||||
def read_feed_file(self):
|
||||
"""
|
||||
method read and convert the content of the file to a FeedParserDict
|
||||
:return: dict - feed object
|
||||
"""
|
||||
feed_str = self.read_text_file()
|
||||
return feedparser.parse(feed_str)
|
||||
|
||||
def write_feed_file(self, feed, serializer):
|
||||
assert isinstance(feed, feedparser.FeedParserDict)
|
||||
|
||||
if serializer is None:
|
||||
feed_string = str(feed)
|
||||
else:
|
||||
feed_string = serializer.toString(feed)
|
||||
self.write_text_file(feed_string)
|
||||
Reference in New Issue
Block a user