annotate scripts/list_plugins/list_plugins.py @ 65:1f44c73975ab

schemas (decentralisasion): added simple oganisation schemas
author Goffi <goffi@goffi.org>
date Tue, 10 Nov 2015 14:14:19 +0100
parents 2ff373d2571a
children cea50c3e94f0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
1 #!/usr/bin/python
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
3 """
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
4 SàT website: Salut à Toi's presentation website
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
5 Copyright (C) 2015 Jérôme Poisson (goffi@goffi.org)
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
6 Copyright (C) 2015 Adrien Cossa (souliane@mailoo.org)
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
7
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
8 This file is part of SàT website.
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
9
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
10 SàT website is free software: you can redistribute it and/or modify
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
11 it under the terms of the GNU Affero General Public License as published by
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
12 the Free Software Foundation, either version 3 of the License, or
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
13 (at your option) any later version.
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
14
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
15 Foobar is distributed in the hope that it will be useful,
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
18 GNU Affero General Public License for more details.
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
19
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
20 You should have received a copy of the GNU Affero General Public License
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
21 along with Foobar. If not, see <http://www.gnu.org/licenses/>.
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
22 """
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
23
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
24
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
25 from sat import plugins
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
26 import pkgutil
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
27
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
28 WEBSITE = "/home/souliane/workspace/sat_website"
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
29
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
30 HEADER = u"""
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
31 {% comment %}
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
32 SàT website: Salut à Toi's presentation website
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
33 Copyright (C) 2012 Jérôme Poisson (goffi@goffi.org)
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
34 Copyright (C) 2015 Adrien Cossa (souliane@mailoo.org)
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
35
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
36 This file is part of SàT website.
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
37
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
38 SàT website is free software: you can redistribute it and/or modify
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
39 it under the terms of the GNU Affero General Public License as published by
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
40 the Free Software Foundation, either version 3 of the License, or
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
41 (at your option) any later version.
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
42
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
43 Foobar is distributed in the hope that it will be useful,
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
44 but WITHOUT ANY WARRANTY; without even the implied warranty of
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
45 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
46 GNU Affero General Public License for more details.
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
47
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
48 You should have received a copy of the GNU Affero General Public License
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
49 along with Foobar. If not, see <http://www.gnu.org/licenses/>.
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
50
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
51
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
52 NOTE: this file has been automatically generated by the following script:
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
53 http://repos.goffi.org/sat_docs/file/tip/scripts/list_plugins/list_plugins.py
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
54
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
55 Please avoid manual modification, try to update the script instead! Before /
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
56 after a regeneration, don't forget to save / merge the manual modifications.
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
57
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
58 {% endcomment %}
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
59 {% load i18n %}
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
60 """
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
61
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
62 import urllib2
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
63 import lxml.html
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
64
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
65 # use it to retrieve the XEP name from the official list
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
66 XEPS_URL = "http://xmpp.org/xmpp-protocols/xmpp-extensions/"
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
67
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
68 def get_infos():
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
69 result = {}
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
70 doc = lxml.html.parse(XEPS_URL)
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
71
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
72 for loader, module_name, is_pkg in pkgutil.walk_packages(plugins.__path__):
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
73 module = loader.find_module(module_name).load_module(module_name)
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
74 infos = getattr(module, 'PLUGIN_INFO')
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
75
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
76 if infos['type'] == 'XEP':
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
77 name = infos['import_name']
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
78 url = "http://xmpp.org/extensions/%s.html" % name.lower()
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
79 key = "xep"
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
80 # use the XEP name as description
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
81 desc = doc.xpath("//tr[@id='%s']/td" % name.lower().replace("-", ""))[1].text
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
82 else:
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
83 name = '{% trans "' + infos['name'] + '" %}'
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
84 url = None
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
85 key = "exp"
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
86 desc = infos['description']
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
87 if desc.startswith('Implementation of '):
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
88 desc = desc[18:]
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
89 desc = '{% trans "' + desc.replace('"', '\\"') + '" %}'
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
90 result.setdefault(key, []).append((name, url, desc))
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
91
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
92 return result
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
93
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
94
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
95 def print_infos(infos, file):
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
96 with open(file, 'w',) as f:
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
97 f.write(HEADER.encode("utf-8"))
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
98 for name, url, desc in infos:
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
99 name = ('<a href="%s" target="#">%s</a>' % (url, name)) if url else name
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
100 entry = u"""
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
101 <div class="row">
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
102 <div class="col-md-2">%s</div>
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
103 <div class="col-md-7 feature">%s</div>
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
104 </div>""" % (name, desc)
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
105 f.write(entry.encode("utf-8"))
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
106
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
107 infos = get_infos()
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
108 for type_ in ("xep", "exp"):
2ff373d2571a add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff changeset
109 print_infos(infos[type_], "%s/templates/sat_website/specifications_%s.html" % (WEBSITE, type_))