comparison scripts/list_plugins/list_plugins.py @ 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 2ff373d2571a
children
comparison
equal deleted inserted replaced
68:831c4f264650 69:cea50c3e94f0
67 67
68 def get_infos(): 68 def get_infos():
69 result = {} 69 result = {}
70 doc = lxml.html.parse(XEPS_URL) 70 doc = lxml.html.parse(XEPS_URL)
71 71
72 def setXEP(name):
73 url = "http://xmpp.org/extensions/%s.html" % name.lower()
74 # use the XEP name as description
75 desc = doc.xpath("//tr[@id='%s']/td" % name.lower().replace("-", ""))[1].text
76 desc = '{% trans "' + desc.replace('"', '\\"') + '" %}'
77 result.setdefault("xep", []).append((name, url, desc))
78
79 def setEXP(name):
80 desc = infos['description']
81 if desc.startswith('Implementation of '):
82 desc = desc[18:]
83 desc = '{% trans "' + desc.replace('"', '\\"') + '" %}'
84 result.setdefault("exp", []).append((name, None, desc))
85
72 for loader, module_name, is_pkg in pkgutil.walk_packages(plugins.__path__): 86 for loader, module_name, is_pkg in pkgutil.walk_packages(plugins.__path__):
73 module = loader.find_module(module_name).load_module(module_name) 87 module = loader.find_module(module_name).load_module(module_name)
74 infos = getattr(module, 'PLUGIN_INFO') 88 infos = getattr(module, 'PLUGIN_INFO')
75 89
76 if infos['type'] == 'XEP': 90 if infos['type'] == 'XEP':
77 name = infos['import_name'] 91 name = infos['import_name']
78 url = "http://xmpp.org/extensions/%s.html" % name.lower() 92 setXEP(name)
79 key = "xep" 93 protocols = infos['protocols']
80 # use the XEP name as description 94 for protocol in protocols:
81 desc = doc.xpath("//tr[@id='%s']/td" % name.lower().replace("-", ""))[1].text 95 if protocol != name:
96 setXEP(protocol)
82 else: 97 else:
83 name = '{% trans "' + infos['name'] + '" %}' 98 name = '{% trans "' + infos['name'] + '" %}'
84 url = None 99 setEXP(name)
85 key = "exp"
86 desc = infos['description']
87 if desc.startswith('Implementation of '):
88 desc = desc[18:]
89 desc = '{% trans "' + desc.replace('"', '\\"') + '" %}'
90 result.setdefault(key, []).append((name, url, desc))
91 100
92 return result 101 return result
93 102
94 103
95 def print_infos(infos, file): 104 def print_infos(infos, file):