changeset 69:cea50c3e94f0

list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
author souliane <souliane@mailoo.org>
date Wed, 02 Dec 2015 00:14:31 +0100
parents 831c4f264650
children bf0fab14112f
files scripts/list_plugins/list_plugins.py
diffstat 1 files changed, 20 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/list_plugins/list_plugins.py	Tue Dec 01 17:50:15 2015 +0100
+++ b/scripts/list_plugins/list_plugins.py	Wed Dec 02 00:14:31 2015 +0100
@@ -69,25 +69,34 @@
     result = {}
     doc = lxml.html.parse(XEPS_URL)
 
+    def setXEP(name):
+        url = "http://xmpp.org/extensions/%s.html" % name.lower()
+        # use the XEP name as description
+        desc = doc.xpath("//tr[@id='%s']/td" % name.lower().replace("-", ""))[1].text
+        desc = '{% trans "' + desc.replace('"', '\\"') + '" %}'
+        result.setdefault("xep", []).append((name, url, desc))
+
+    def setEXP(name):
+        desc = infos['description']
+        if desc.startswith('Implementation of '):
+            desc = desc[18:]
+        desc = '{% trans "' + desc.replace('"', '\\"') + '" %}'
+        result.setdefault("exp", []).append((name, None, desc))
+
     for loader, module_name, is_pkg in  pkgutil.walk_packages(plugins.__path__):
         module = loader.find_module(module_name).load_module(module_name)
         infos = getattr(module, 'PLUGIN_INFO')
 
         if infos['type'] == 'XEP':
             name = infos['import_name']
-            url = "http://xmpp.org/extensions/%s.html" % name.lower()
-            key = "xep"
-            # use the XEP name as description
-            desc = doc.xpath("//tr[@id='%s']/td" % name.lower().replace("-", ""))[1].text
+            setXEP(name)
+            protocols = infos['protocols']
+            for protocol in protocols:
+                if protocol != name:
+                    setXEP(protocol)
         else:
             name = '{% trans "' + infos['name'] + '" %}'
-            url = None
-            key = "exp"
-            desc = infos['description']
-            if desc.startswith('Implementation of '):
-                desc = desc[18:]
-        desc = '{% trans "' + desc.replace('"', '\\"') + '" %}'
-        result.setdefault(key, []).append((name, url, desc))
+            setEXP(name)
 
     return result