method docblocks
authorChristian Weiske <cweiske@cweiske.de>
Mon, 28 Nov 2011 17:25:51 +0000 (18:25 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 28 Nov 2011 17:25:51 +0000 (18:25 +0100)
src/AtomFeed.py
src/__init__.py
src/config.py
src/plugin.py

index e24fee1b8f9d201e616e242f9c9bb1f298f16fba..7a9fe780271909bb440fbb5e1263675cdd418dbc 100644 (file)
@@ -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
index 3540b5af0bb8ce2d33f761da0273b0d8d1a9735c..ee832536cb92a45efd9d49efbf8420eb4aec585a 100644 (file)
@@ -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
index 7f4d6810d652b60308e12320a4dcb5f2634cb1c0..496fb42ef3b639e82d8c5a9138fc829a7b08ccd5 100644 (file)
@@ -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(
index e67db88dc5351c16f24fa7e4de7cd553469e49ab..3c1794a7cf1b1393e9ac3c234515c30eb829f588 100644 (file)
@@ -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",