diff options
Diffstat (limited to 'afeedprocessor/adescription.py')
-rw-r--r-- | afeedprocessor/adescription.py | 21 |
1 files changed, 21 insertions, 0 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 @@ | |||
1 | class 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) | ||