r85932 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85931‎ | r85932 | r85933 >
Date:23:46, 12 April 2011
Author:diederik
Status:deferred
Tags:
Comment:
Taxonomy list maker plugin is now working.
Modified paths:
  • /trunk/tools/editor_trends/analyses/plugins/taxonomy_list_makers.py (modified) (history)
  • /trunk/tools/editor_trends/classes/analytics.py (modified) (history)
  • /trunk/tools/editor_trends/classes/buffer.py (modified) (history)
  • /trunk/tools/editor_trends/classes/dataset.py (modified) (history)
  • /trunk/tools/editor_trends/classes/storage.py (modified) (history)

Diff [purge]

Index: trunk/tools/editor_trends/analyses/plugins/taxonomy_list_makers.py
@@ -31,6 +31,7 @@
3232 titles that begin with "List of..."
3333 """
3434 data = kwargs.get('data', None)
 35+ treshold = kwargs.get('treshold', 10)
3536 today = datetime.today()
3637
3738 if data == None:
@@ -38,25 +39,27 @@
3940 sys.exit(-1)
4041
4142 articles_edited = editor['articles_edited']
42 - print articles_edited
43 - #print data
 43+
4444 count = 0
4545 years = articles_edited.keys()
4646 for year in years:
4747 months = articles_edited[year].keys()
4848 for month in months:
49 - articles = articles_edited[year].get(month, [])
50 - for article in articles:
51 - try:
52 - count += data[article]
53 - except KeyError:
54 - pass
 49+ namespaces = articles_edited[year][month].keys()
 50+ for ns in namespaces:
 51+ articles = articles_edited[year][month].get(ns, [])
 52+ for article in articles:
 53+ #print article, data.get(article, None)
 54+ try:
 55+ count += data[article]
 56+ except KeyError:
 57+ pass
5558
5659 """ Add all editors with an edit count of more than 10 """
5760
58 - if count > 10:
 61+ if count > treshold:
5962 var.add(today, count, {'username': editor['username']})
60 -
 63+ print editor['username'], count
6164 return var
6265
6366
Index: trunk/tools/editor_trends/classes/buffer.py
@@ -175,10 +175,10 @@
176176 #row = '\t'.join([article_id, title]) + '\n'
177177 rows.append(row)
178178 file_utils.write_list_to_csv(rows, self.fh_articles, newline=False)
179 - self.articles = {}
180179 except Exception, error:
181180 print '''Encountered the following error while writing article
182181 data to %s: %s''' % (self.fh_articles, error)
 182+ self.articles = {}
183183 #t1 = datetime.datetime.now()
184184 #print '%s articles took %s' % (len(self.articles.keys()), (t1 - t0))
185185
Index: trunk/tools/editor_trends/classes/storage.py
@@ -115,6 +115,11 @@
116116 print 'It seems that you are running out of disk space. \
117117 Error message: %s' % error
118118 sys.exit(-1)
 119+ except OverflowError, error:
 120+ print '''It seems that you are trying to store an integer that is
 121+ too long. Error message: %s''' % error
 122+ print 'Offending data: %s' % data
 123+ sys.exit(-1)
119124
120125 def update(self, key, value, data):
121126 assert isinstance(data, dict), 'You need to feed me dictionaries.'
Index: trunk/tools/editor_trends/classes/dataset.py
@@ -477,7 +477,10 @@
478478 n = len(number_list)
479479 for i in number_list:
480480 std = std + (i - mean) ** 2
481 - return math.sqrt(std / float(n - 1))
 481+ try:
 482+ return math.sqrt(std / float(n - 1))
 483+ except ZeroDivisionError:
 484+ return '.'
482485
483486 def get_median(self, number_list):
484487 if number_list == []:
Index: trunk/tools/editor_trends/classes/analytics.py
@@ -82,7 +82,7 @@
8383 Generic loop function that loops over all the editors of a Wikipedia
8484 project and then calls the plugin that does the actual mapping.
8585 '''
86 - db = storage.Database(rts.storage, self.rts.dbname, self.rts.editors_dataset)
 86+ db = storage.Database(self.rts.storage, self.rts.dbname, self.rts.editors_dataset)
8787 while True:
8888 try:
8989 task = self.tasks.get(block=False)