Mercurial > sat_docs
view scripts/list_plugins/list_plugins.py @ 59:e09702e8d96f
add some schemas
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 20 Oct 2015 15:42:48 +0200 |
parents | 2ff373d2571a |
children | cea50c3e94f0 |
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) 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 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)) 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_))