aboutsummaryrefslogtreecommitdiff
path: root/rss/atom_entry.py
diff options
context:
space:
mode:
Diffstat (limited to 'rss/atom_entry.py')
-rw-r--r--rss/atom_entry.py39
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")