Mercurial > sat_docs
view scripts/list_plugins/list_plugins.py @ 123:f20fa03391f5
added big picture English file
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 28 Apr 2016 09:27:58 +0200 |
parents | cea50c3e94f0 |
children |
line wrap: on
line source
#!/usr/bin/python # -*- coding: utf-8 -*- """ SàT website: Salut à Toi's presentation website Copyright (C) 2015 Jérôme Poisson (goffi@goffi.org) Copyright (C) 2015 Adrien Cossa (souliane@mailoo.org) This file is part of SàT website. SàT website is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Foobar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Foobar. If not, see <http://www.gnu.org/licenses/>. """ from sat import plugins import pkgutil WEBSITE = "/home/souliane/workspace/sat_website" HEADER = u""" {% comment %} SàT website: Salut à Toi's presentation website Copyright (C) 2012 Jérôme Poisson (goffi@goffi.org) Copyright (C) 2015 Adrien Cossa (souliane@mailoo.org) This file is part of SàT website. SàT website is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Foobar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with Foobar. If not, see <http://www.gnu.org/licenses/>. NOTE: this file has been automatically generated by the following script: http://repos.goffi.org/sat_docs/file/tip/scripts/list_plugins/list_plugins.py Please avoid manual modification, try to update the script instead! Before / after a regeneration, don't forget to save / merge the manual modifications. {% endcomment %} {% load i18n %} """ import urllib2 import lxml.html # use it to retrieve the XEP name from the official list XEPS_URL = "http://xmpp.org/xmpp-protocols/xmpp-extensions/" def get_infos(): 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'] setXEP(name) protocols = infos['protocols'] for protocol in protocols: if protocol != name: setXEP(protocol) else: name = '{% trans "' + infos['name'] + '" %}' setEXP(name) return result def print_infos(infos, file): with open(file, 'w',) as f: f.write(HEADER.encode("utf-8")) for name, url, desc in infos: name = ('<a href="%s" target="#">%s</a>' % (url, name)) if url else name entry = u""" <div class="row"> <div class="col-md-2">%s</div> <div class="col-md-7 feature">%s</div> </div>""" % (name, desc) f.write(entry.encode("utf-8")) infos = get_infos() for type_ in ("xep", "exp"): print_infos(infos[type_], "%s/templates/sat_website/specifications_%s.html" % (WEBSITE, type_))