diff options
author | neodarz <neodarz@neodarz.net> | 2018-07-30 20:37:26 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-07-30 20:37:26 +0200 |
commit | 8e8d884d1c78641fbb967479bd4ddcb320da150e (patch) | |
tree | 5fc204439b7302dbb314a13396c750a501f08c47 /rss/atom_entry.py | |
parent | ccc5b05ef9eb706e8fbb8b1e6607f2fab6e42e67 (diff) | |
download | my_new_personal_website-8e8d884d1c78641fbb967479bd4ddcb320da150e.tar.xz my_new_personal_website-8e8d884d1c78641fbb967479bd4ddcb320da150e.zip |
Move rss code to a package
Diffstat (limited to 'rss/atom_entry.py')
-rw-r--r-- | rss/atom_entry.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/rss/atom_entry.py b/rss/atom_entry.py new file mode 100644 index 00000000..4b6e116a --- /dev/null +++ b/rss/atom_entry.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 + +import lxml.etree as ET + +class AtomEntry(object): + """Class for storing atom:entry data and metadata.""" + + # pylint: disable=invalid-name,too-many-instance-attributes + + def __init__(self): + """Define available attributes.""" + self.author = None # atom:author + self.id_text = None # atom:id, just use URI + self.id = None # atom:id + self.relpath = None # HTML page path relative to home + self.link = None # atom:link + self.title_text = None # plain text title + self.title = None # atom:title + self.updated_datetime = None # update time as a datetime object + self.updated = None # atom:updated + self.content_html = None # content as HTML markup + self.content = None # atom:content + self.entry = None # atom:entry, assembled + + def assemble_entry(self): + """Assemble atom:entry.""" + self.entry = ET.Element("entry") + self.entry.append(self.title) + self.entry.append(self.link) + self.entry.append(self.updated) + self.entry.append(self.id) + self.entry.append(self.author) + self.entry.append(self.content) + + def dump_entry(self): + """Dump atom:entry XML.""" + if self.entry is None: + self.assemble_entry() + return ET.tostring(self.entry).decode("utf-8") |