aboutsummaryrefslogtreecommitdiff
path: root/afeedprocessor/adescription.py
blob: 7bc1aa7eafcb2bbbadc175b75482a50871216607 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Description:
    def __init__(self, description):
        self.tag = 'description'
        self.description = description

    def is_cdata(self):
        if self.description is None:
            return False

        return self.description.startswith('<![CDATA[') and self.description.endswith(']]>')

    def publish(self, handler):
        handler.startElement(self.tag, {})

        if self.description is not None:
            if self.is_cdata():
                handler._write(self.description)
            else:
                handler.characters(self.description)

        handler.endElement(self.tag)