Browse Source

Add makewiki.py

Makewiki.py is a script that can be used to create mediawiki
syntax from a groups JSON file in format for group portal use.

This patch also changes Australia and New Zealand to move into
the Asia Pacific region.

Change-Id: Ifcc949f61fa0f1d1c3145c0781de159e144fa547
changes/14/113514/1
Tom Fifield 4 years ago
parent
commit
a90d9ec01f
2 changed files with 101 additions and 2 deletions
  1. 2
    2
      groups.json
  2. 99
    0
      makewiki.py

+ 2
- 2
groups.json View File

@@ -464,7 +464,7 @@
464 464
       "id": "a1341112-f9ea-4727-9171-a410e132eafe",
465 465
       "location": {
466 466
         "country": "AU",
467
-        "continent": "OC",
467
+        "continent": "AS",
468 468
         "lat": "0",
469 469
         "lng": "0"
470 470
       },
@@ -481,7 +481,7 @@
481 481
       "id": "d3e72761-f39f-41d3-8ac2-df0f717d905e",
482 482
       "location": {
483 483
         "country": "NZ",
484
-        "continent": "OC",
484
+        "continent": "AS",
485 485
         "lat": "0",
486 486
         "lng": "0"
487 487
       },

+ 99
- 0
makewiki.py View File

@@ -0,0 +1,99 @@
1
+#!/usr/bin/env python
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#    http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
+# implied.
13
+# See the License for the specific language governing permissions and
14
+# limitations under the License.
15
+
16
+""" Make the UserGroups Wiki page.
17
+
18
+Takes a JSON file made for the User Group Portal and generates a mediawiki
19
+format page.
20
+"""
21
+
22
+import json
23
+import logging
24
+
25
+groups_json = json.load(open('groups.json'))
26
+groups = {}
27
+logger = logging.getLogger('makewiki')
28
+continent_names = {'AF': 'Africa', 'AS': 'Asia Pacific', 'EU': 'Europe',
29
+                   'ME': 'Middle East', 'NA': 'North America',
30
+                   'SA': 'South America'}
31
+
32
+def nice_label(attribute):
33
+    nice_labels = {'facebook': 'Facebook Group', 'meetup' : 'Meetup details here',
34
+                   'linkedin': 'LinkedIn Group', 'irc': 'IRC',
35
+                   'twitter': 'Twitter', 'website': 'Website',
36
+                   'google-groups': 'Google Group', 'blog': 'Blog',
37
+                   'coordinators': 'Coordinators',
38
+                   'google-plus': 'Google Plus Community',
39
+                   'mailing-list': 'Mailing List'}
40
+
41
+    if attribute in nice_labels:
42
+        return nice_labels[attribute]
43
+    else:
44
+        return attribute
45
+
46
+def make_header(continent_groups):
47
+    print '__NOTOC__'
48
+    print 'Welcome to the list of the OpenStack User Groups!'
49
+    print
50
+    print "Can't find one nearby? Want to start one? The\
51
+[[Teams#Community_team|OpenStack International Community team]] is your main\
52
+contact point. Join\
53
+[http://lists.openstack.org/cgi-bin/mailman/listinfo/community the mailing\
54
+list] and read [[OpenStackUserGroups/HowTo|the HowTo page]] if you are hosting\
55
+or want to start a user group with meetups, hackathons and other social events\
56
+talking about OpenStack and free/libre open source software for the cloud. You\
57
+can also edit this page to add your group, but remember - we're an [[Open]]\
58
+community."
59
+    print
60
+    print '<div style="column-count:3;-moz-column-count:3;-webkit-column-count:3">'
61
+    for continent in sorted(continent_groups.iterkeys()):
62
+        print ( "* '''[[#" + continent_names[continent] + '|' +
63
+               continent_names[continent] + "]]'''" )
64
+        for group in continent_groups[continent]:
65
+            print "** [[#" + group + '|' + group + "]]"
66
+    print '</div>'
67
+    pass
68
+
69
+def make_continent(continent):
70
+    print "== " + continent_names[continent] + " =="
71
+
72
+def make_group (group):
73
+    print "=== " + group + " ==="
74
+    for attribute in groups_json['groups'][group_indexes[group]]['attributes']:
75
+        for key,value in attribute.iteritems():
76
+            print '* ' + nice_label(key) + ': ' + value.encode('utf-8')
77
+    print
78
+
79
+
80
+continents = []
81
+continent_groups = {}
82
+group_indexes = {}
83
+counter = 0
84
+for group in groups_json['groups']:
85
+    continent = group['location']['continent']
86
+    if continent not in continents:
87
+        continents.append(continent)
88
+        continent_groups[continent] = []
89
+    continent_groups[continent].append(group['title'])
90
+    group_indexes[group['title']] = counter
91
+    counter = counter + 1
92
+
93
+make_header(continent_groups)
94
+
95
+for continent in continents:
96
+    make_continent(continent)
97
+    for group in continent_groups[continent]:
98
+        make_group(group)
99
+

Loading…
Cancel
Save