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)
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)):
callback(pages)
def bestLink(self, list):
+ """ Fetch the best matching link from an atom feed entry """
foundLevel = -1
foundHref = None
for link in list:
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
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
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(
def main(session, **kwargs):
+ """ Opens the main window """
try:
session.open(CurlyTx.CurlyTx)
except:
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",