aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AtomFeed.py14
-rw-r--r--src/__init__.py2
-rw-r--r--src/config.py1
-rw-r--r--src/plugin.py3
4 files changed, 18 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
diff --git a/src/__init__.py b/src/__init__.py
index 3540b5a..ee83253 100644
--- a/src/__init__.py
+++ b/src/__init__.py
@@ -8,11 +8,13 @@ from os import environ as os_environ
import gettext
def localeInit():
+ """ Prepare settings for gettext usage """
lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
os_environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
gettext.bindtextdomain("CurlyTx", resolveFilename(SCOPE_PLUGINS, "Extensions/CurlyTx/locale"))
def _(txt):
+ """ Custom gettext translation function that uses the CurlyTx domain """
t = gettext.dgettext("CurlyTx", txt)
if t == txt:
#print "[CurlyTx] fallback to default translation for", txt
diff --git a/src/config.py b/src/config.py
index 7f4d681..496fb42 100644
--- a/src/config.py
+++ b/src/config.py
@@ -5,6 +5,7 @@
from Components.config import config, ConfigYesNo, ConfigSelection, ConfigNumber, ConfigText, ConfigSubsection, ConfigSubList, ConfigInteger
def createPage():
+ """ Create and return a configuration page object """
s = ConfigSubsection()
s.uri = ConfigText(default="http://", fixed_size=False)
s.title = ConfigText(
diff --git a/src/plugin.py b/src/plugin.py
index e67db88..3c1794a 100644
--- a/src/plugin.py
+++ b/src/plugin.py
@@ -10,6 +10,7 @@ from Components.config import config
def main(session, **kwargs):
+ """ Opens the main window """
try:
session.open(CurlyTx.CurlyTx)
except:
@@ -17,12 +18,14 @@ def main(session, **kwargs):
traceback.print_exc()
def menuHook(menuid):
+ """ Called whenever a menu is created """
if menuid == "mainmenu" and config.plugins.CurlyTx.menuMain.value:
return [(config.plugins.CurlyTx.menuTitle.value, main, "curlytx", 41)]
return [ ]
def Plugins(**kwargs):
+ """ Register CurlyTx in the extension list and main menu """
list = [
# PluginDescriptor(name = config.plugins.CurlyTx.menuTitle.value,
# description = "View remote text files",