forked from voc/schedule
-
Notifications
You must be signed in to change notification settings - Fork 1
/
schedule2wiki_allinone.py
executable file
·58 lines (45 loc) · 1.73 KB
/
schedule2wiki_allinone.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
import argparse
from collections import OrderedDict
from datetime import datetime
import voc.tools
from voc.schedule import Schedule
from urllib.parse import quote_plus
parser = argparse.ArgumentParser()
parser.add_argument('file', action="store", help="path to input.json")
# parser.add_argument('-o', action="store", dest="output", help="output filename, e.g. events.wiki")
args = parser.parse_args()
def to_wiki(event):
h, m = event['duration'].split(':', 2)
duration = int(h) * 60 + int(m)
wiki = '{{Event \n' + ("|Has subtitle={subtitle}\n|Has start time={startdate} \n" +
"|Has duration={duration} \n|Has session location=Room:{room}\n|GUID={guid}\n").format(
subtitle=event['title'],
startdate=datetime.strptime(event['date'], '%Y-%m-%dT%H:%M:%S').strftime('%Y/%m/%d %H:%M'),
duration=duration,
room=event['room'],
guid=event['guid']
) + '}}'
print(wiki)
def main(args):
schedule = Schedule.from_file(args.file)
lang_map = {
'de': 'de - German',
'en': 'en - English'
}
event = {}
event['title'] = "DLF"
pagename = quote_plus(event['title'].replace(' ', '_'))
print("\n")
print('https://events.ccc.de/congress/2017/wiki/index.php/Session:{}?action=edit'.format(pagename))
wiki = '{{Session \n' + ("|Is for kids=No\n|Has description={text}\n|Has session type={type}\n" +
"|Is organized by={persons}\n|Held in language={lang}\n|Has orga contact=\n").format(
text=event['title'],
type='',
persons='',
lang = lang_map['de']
) + '}}\n'
print(wiki)
schedule.foreach_event(to_wiki)
if __name__ == '__main__':
main(args)