Index: trunk/tools/editor_trends/analyses/plugins/ppi_editor_productivity.py |
— | — | @@ -0,0 +1,46 @@ |
| 2 | +#!/usr/bin/python |
| 3 | +# -*- coding: utf-8 -*- |
| 4 | +''' |
| 5 | +Copyright (C) 2011 by Ryan Faulkner (rfaulkner@wikimedia.org) |
| 6 | +This program is free software; you can redistribute it and/or |
| 7 | +modify it under the terms of the GNU General Public License version 2 |
| 8 | +as published by the Free Software Foundation. |
| 9 | +This program is distributed in the hope that it will be useful, |
| 10 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | +See the GNU General Public License for more details, at |
| 13 | +http://www.fsf.org/licenses/gpl.html |
| 14 | +''' |
| 15 | + |
| 16 | +__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@gmail.com)', ]) |
| 17 | +__email__ = 'dvanliere at gmail dot com' |
| 18 | +__date__ = '2011-04-20' |
| 19 | +__version__ = '0.1' |
| 20 | + |
| 21 | +from datetime import datetime |
| 22 | + |
| 23 | +def ppi_editor_productivity(var, editor, **kwargs): |
| 24 | + new_wikipedian = editor['new_wikipedian'] |
| 25 | + if not new_wikipedian: |
| 26 | + return var |
| 27 | + |
| 28 | + edits = editor['character_count'] |
| 29 | + username = editor['username'] |
| 30 | + |
| 31 | + try: |
| 32 | + added = edits['2010']['11']['0']['added'] |
| 33 | + except KeyError: |
| 34 | + added = 0 |
| 35 | + if added > 0: |
| 36 | + key = datetime(2010, 11, 30) |
| 37 | + var.add(key, added , {'username': username}) |
| 38 | + |
| 39 | + try: |
| 40 | + added = edits['2010']['12']['0']['added'] |
| 41 | + except KeyError: |
| 42 | + added = 0 |
| 43 | + if added > 0: |
| 44 | + key = datetime(2010, 12, 31) |
| 45 | + var.add(key, added , {'username': username}) |
| 46 | + |
| 47 | + return var |
Property changes on: trunk/tools/editor_trends/analyses/plugins/ppi_editor_productivity.py |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 48 | + native |