From 0ba53f985475cd303fc798bb1c4f1d968ccbaa33 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Mon, 19 Mar 2012 03:22:37 +0100 Subject: Add script on stats that are asked upon registration at LinuxTag Berlin --- linuxtag-berlin-germany.py | 98 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100755 linuxtag-berlin-germany.py diff --git a/linuxtag-berlin-germany.py b/linuxtag-berlin-germany.py new file mode 100755 index 0000000..01b836f --- /dev/null +++ b/linuxtag-berlin-germany.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Written by Sebastian Pipping +# 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) -- cgit v1.2.3-65-gdbad