aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--afeedprocessor/adescription.py21
-rw-r--r--afeedprocessor/anitemprocessor.py4
2 files changed, 24 insertions, 1 deletions
diff --git a/afeedprocessor/adescription.py b/afeedprocessor/adescription.py
new file mode 100644
index 0000000..7bc1aa7
--- /dev/null
+++ b/afeedprocessor/adescription.py
@@ -0,0 +1,21 @@
1class Description:
2 def __init__(self, description):
3 self.tag = 'description'
4 self.description = description
5
6 def is_cdata(self):
7 if self.description is None:
8 return False
9
10 return self.description.startswith('<![CDATA[') and self.description.endswith(']]>')
11
12 def publish(self, handler):
13 handler.startElement(self.tag, {})
14
15 if self.description is not None:
16 if self.is_cdata():
17 handler._write(self.description)
18 else:
19 handler.characters(self.description)
20
21 handler.endElement(self.tag)
diff --git a/afeedprocessor/anitemprocessor.py b/afeedprocessor/anitemprocessor.py
index 3f0eabc..f281e15 100644
--- a/afeedprocessor/anitemprocessor.py
+++ b/afeedprocessor/anitemprocessor.py
@@ -1,5 +1,7 @@
1import PyRSS2Gen 1import PyRSS2Gen
2 2
3from afeedprocessor.adescription import Description
4
3 5
4class ItemProcessor: 6class ItemProcessor:
5 def get_title(self, title, item): 7 def get_title(self, title, item):
@@ -36,7 +38,7 @@ class ItemProcessor:
36 return PyRSS2Gen.RSSItem( 38 return PyRSS2Gen.RSSItem(
37 title=self.get_title(item.title, item), 39 title=self.get_title(item.title, item),
38 link=self.get_link(item.link, item), 40 link=self.get_link(item.link, item),
39 description=self.get_description(item.description, item), 41 description=Description(self.get_description(item.description, item)),
40 author=self.get_author(item.author, item), 42 author=self.get_author(item.author, item),
41 categories=self.get_categories(item.categories, item), 43 categories=self.get_categories(item.categories, item),
42 comments=self.get_comments(item.comments, item), 44 comments=self.get_comments(item.comments, item),