Mercurial > sat_docs
annotate 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 |
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 |
69
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
72 def setXEP(name): |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
73 url = "http://xmpp.org/extensions/%s.html" % name.lower() |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
74 # use the XEP name as description |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
75 desc = doc.xpath("//tr[@id='%s']/td" % name.lower().replace("-", ""))[1].text |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
76 desc = '{% trans "' + desc.replace('"', '\\"') + '" %}' |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
77 result.setdefault("xep", []).append((name, url, desc)) |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
78 |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
79 def setEXP(name): |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
80 desc = infos['description'] |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
81 if desc.startswith('Implementation of '): |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
82 desc = desc[18:] |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
83 desc = '{% trans "' + desc.replace('"', '\\"') + '" %}' |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
84 result.setdefault("exp", []).append((name, None, desc)) |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
85 |
45
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
86 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
|
87 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
|
88 infos = getattr(module, 'PLUGIN_INFO') |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
89 |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
90 if infos['type'] == 'XEP': |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
91 name = infos['import_name'] |
69
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
92 setXEP(name) |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
93 protocols = infos['protocols'] |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
94 for protocol in protocols: |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
95 if protocol != name: |
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
96 setXEP(protocol) |
45
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
97 else: |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
98 name = '{% trans "' + infos['name'] + '" %}' |
69
cea50c3e94f0
list_plugins script also takes in consideration the XEPs that are defined in the "protocols" field of PLUGIN_INFO
souliane <souliane@mailoo.org>
parents:
45
diff
changeset
|
99 setEXP(name) |
45
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
100 |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
101 return result |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
102 |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
103 |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
104 def print_infos(infos, file): |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
105 with open(file, 'w',) as f: |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
106 f.write(HEADER.encode("utf-8")) |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
107 for name, url, desc in infos: |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
108 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
|
109 entry = u""" |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
110 <div class="row"> |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
111 <div class="col-md-2">%s</div> |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
112 <div class="col-md-7 feature">%s</div> |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
113 </div>""" % (name, desc) |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
114 f.write(entry.encode("utf-8")) |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
115 |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
116 infos = get_infos() |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
117 for type_ in ("xep", "exp"): |
2ff373d2571a
add decentralisation schemas + script for listing the plugins
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
118 print_infos(infos[type_], "%s/templates/sat_website/specifications_%s.html" % (WEBSITE, type_)) |