summaryrefslogtreecommitdiff
blob: 5611a4a579bf8ade7dbd4d93014b74789df2c796 (plain)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Written by Sebastian Pipping <sebastian@pipping.org>
# Licensed under GPL v2 or later

from __future__ import print_function
import xml.etree.ElementTree as ET  # Python 2.5
import sys


_PAST_GENTOO_ACCOUNT, _CHAT_OR_LOCAL_ONLY = range(2)


_past_nicknames_for = {
	'chithanh': (
		('chithead', _CHAT_OR_LOCAL_ONLY),
	),
	'fauli': (
		('opfer', _PAST_GENTOO_ACCOUNT),
	),
	'stkn': (
		('aura', _CHAT_OR_LOCAL_ONLY),
	),
}


_external_contributors = {
	'caratorn': ('Charles Clément', 'caratorn@gmail.com'),
	'frquadrat': ('Frank-Ralph Reiser', 'frank.ralph.reiser@gmail.com'),
	'hey_neken': ('Mikel Olasgasti', 'hey_neken@mundurat.net'),
	'mellen': ('Tais M. Hansen', 'mellen@osd.dk'),
	'tacvbo': ('Octavio Ruiz', 'tacvbo@tacvbo.net'),
	'rambaldi': ('Rambaldi', 'rambaldi@xs4all.nl'),
	'svoop': ('Sven Schwyn', 'gentoo@bitcetera.com'),
	'zhllg': ('Zhang Le', 'robert.zhangle@gmail.com'),
}


def _produce_line(svn_nick, realname, address):
	line = '%s = %s <%s>' % (svn_nick, realname, address)
	print(line.encode('utf-8'))


def _gentoo_address(nick):
	return '%s@gentoo.org' % nick


def main(args):
	if len(args) != 2:
		print('USAGE:  %s GENTOO/xml/htdocs/proj/en/devrel/roll-call/userinfo.xml' % args[0])
		return 1

	try:
		userlist = ET.parse(args[1])
	except IOError as e:
		print(str(e), file=sys.stderr)
		return 1

	for user in userlist.findall('user'):
		svn_nick = user.attrib['username']
		location = user.find('location')
		realname = user.find('realname').attrib['fullname'].strip()

		_produce_line(svn_nick, realname, _gentoo_address(svn_nick))

		past_nicknames = _past_nicknames_for.get(svn_nick, [])
		for alias, kind in past_nicknames:
			if kind == _PAST_GENTOO_ACCOUNT:
				gentoo_nick=alias
			elif kind == _CHAT_OR_LOCAL_ONLY:
				gentoo_nick=svn_nick
			else:
				assert False, 'Invalid kind %s' % str(kind)
			_produce_line(alias, realname, _gentoo_address(gentoo_nick))

	for svn_nick, (realname, address) in sorted(_external_contributors.items()):
		_produce_line(svn_nick, realname.decode('utf-8'), address=address)

	return 0


if __name__ == '__main__':
	ret = main(sys.argv)
	sys.exit(ret)