aboutsummaryrefslogtreecommitdiff
path: root/src/AtomFeed.py
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2011-11-28 18:25:51 +0100
committerChristian Weiske <cweiske@cweiske.de>2011-11-28 18:25:51 +0100
commit8d8587bc8cd3a8639de5887760db2aef7ca917ce (patch)
tree97ac3d8d52159de90a6b5e00006310ec2b66f00c /src/AtomFeed.py
parentea9c06ee0676f33f0d1fd370281328fa7219e22b (diff)
downloadenigma2-curlytx-8d8587bc8cd3a8639de5887760db2aef7ca917ce.tar.gz
enigma2-curlytx-8d8587bc8cd3a8639de5887760db2aef7ca917ce.zip
method docblocks
Diffstat (limited to 'src/AtomFeed.py')
-rw-r--r--src/AtomFeed.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/AtomFeed.py b/src/AtomFeed.py
index e24fee1..7a9fe78 100644
--- a/src/AtomFeed.py
+++ b/src/AtomFeed.py
@@ -6,10 +6,13 @@ from twisted.web.client import getPage
from xml.etree.cElementTree import fromstring
class AtomFeed:
- """Simple XML parser that extracts pages from a atom feed
- """
+ """ Simple XML parser that extracts pages from a atom feed """
ns = "{http://www.w3.org/2005/Atom}"
def __init__(self, url, callback):
+ """ Fetches the URL
+
+ Parsed pages are sent back to callback by parse()
+ """
getPage(url).addCallback(self.parse, callback).addErrback(self.fail)
@@ -17,6 +20,7 @@ class AtomFeed:
print("CurlyTx", msg)
def parse(self, data, callback):
+ """ Parse atom feed data into pages list and run callback """
xml = fromstring(data)
pages = []
for entry in xml.findall("{0}entry".format(self.ns)):
@@ -28,6 +32,7 @@ class AtomFeed:
callback(pages)
def bestLink(self, list):
+ """ Fetch the best matching link from an atom feed entry """
foundLevel = -1
foundHref = None
for link in list:
@@ -41,6 +46,11 @@ class AtomFeed:
return foundHref
def level(self, link):
+ """ Determines the level of a link
+
+ "text/plain" type links are best, links without type are second.
+ All others have the lowest level 1.
+ """
type = link.get("type")
if type == "text/plain":
return 3