summaryrefslogtreecommitdiff
blob: 01b836f2d5d7644138abe828b03422154e9c5442 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Written by Sebastian Pipping <sebastian@pipping.org>
# Licensed under GPL v2 or later

import xml.etree.ElementTree as ET  # Python 2.5
import re


# Disclaimer: I s*** at geometry, sorry.  I welcome patches!
_pattern_germany = re.compile('\\bGermany\\b')
_pattern_europe_without_germany = re.compile('\\b(?:Denmark|France|Ireland|Sweden|Switzerland|Austria|Poland|Spain|UK|Belarus|Belgium|Finland|Italy|Paris|Czech|Scotland|(?:[Tt]he )?[Nn]etherlands|England|Norway|United Kingdom|Channel Islands|(?:South )?Wales|Slovakia|Hungary|NL)\\b')
_pattern_non_europe = re.compile('(?:U\.S\.|\\b(?:USA|Russia|Missouri|Canada|Unknown|Mexico|Greece|New Zealand|Romania|Massachusetts|Israel|India|Tx|Bra[zs]il|Chile|Venezuela|Australia|South Africa|Egypt|US|Ohio|NZ|Taiwan|Japan|FL|California|TX|Singapore|Costa Rica|VA|Louisiana|Argentina|NJ|Turkey|Iceland|Portugal|Korea|Indiana|CA|Texas|Estonia|Colombia|Florida|OR|Silicon Valley|PA|Oklahoma City|China|Boston|Vietnam|San Antonio|New York|MN|IL|Peru|Cyprus|WA|NY|NC|TN|Salvador)\\b)')


def in_germany(location):
	return _pattern_germany.search(location) != None

def in_europe(location):
	return _pattern_europe_without_germany.search(location) != None

def other(location):
	return _pattern_non_europe.search(location) != None


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

	active = 0
	retired = 0

	europe = 0
	german_devs = list()

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

	for user in userlist.findall('user'):
		nick = user.attrib['username']
		location = user.find('location')

		realname = user.find('realname').attrib['fullname'].strip()

		# Retired?
		if user.find('retired') is not None:
			retired = retired + 1
			continue
		status = user.find('status')
		if status is not None \
				and status.text.strip() == 'retired':
			retired = retired + 1
			continue
		active = active + 1

		# Location?
		if location is None:
			continue
		location = location.text.strip()
		if in_germany(location):
			german_devs.append('%s <%s@gentoo.org>' % (realname, nick))
			europe = europe + 1
		elif in_europe(location):
			europe = europe + 1
		elif other(location):
			pass
		else:
			print 'ERROR:', nick, 'unmatched:', location
			import sys
			sys.exit(1)

	if german_devs:
		print 'German developers (active only):'
		for i in sorted(german_devs):
			print '  ' + i

	print
	print 'Activity (global):'
	print '  active   %4d' % active
	print '  retired  %4d' % retired
	print '  -------------'
	print '  total    %4d' % (active + retired)
	print
	print 'Location (active only):'
	print '  Germany                    %4d' % len(german_devs)
	print '  Europe (including Germany) %4d' % europe
	print '  World (including Europe)   %4d' % active
	return 0


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