Index: trunk/tools/editor_trends/analyses/plugins/taxonomy_list_makers.py |
— | — | @@ -31,6 +31,7 @@ |
32 | 32 | titles that begin with "List of..." |
33 | 33 | """ |
34 | 34 | data = kwargs.get('data', None) |
| 35 | + treshold = kwargs.get('treshold', 10) |
35 | 36 | today = datetime.today() |
36 | 37 | |
37 | 38 | if data == None: |
— | — | @@ -38,25 +39,27 @@ |
39 | 40 | sys.exit(-1) |
40 | 41 | |
41 | 42 | articles_edited = editor['articles_edited'] |
42 | | - print articles_edited |
43 | | - #print data |
| 43 | + |
44 | 44 | count = 0 |
45 | 45 | years = articles_edited.keys() |
46 | 46 | for year in years: |
47 | 47 | months = articles_edited[year].keys() |
48 | 48 | 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 |
55 | 58 | |
56 | 59 | """ Add all editors with an edit count of more than 10 """ |
57 | 60 | |
58 | | - if count > 10: |
| 61 | + if count > treshold: |
59 | 62 | var.add(today, count, {'username': editor['username']}) |
60 | | - |
| 63 | + print editor['username'], count |
61 | 64 | return var |
62 | 65 | |
63 | 66 | |
Index: trunk/tools/editor_trends/classes/buffer.py |
— | — | @@ -175,10 +175,10 @@ |
176 | 176 | #row = '\t'.join([article_id, title]) + '\n' |
177 | 177 | rows.append(row) |
178 | 178 | file_utils.write_list_to_csv(rows, self.fh_articles, newline=False) |
179 | | - self.articles = {} |
180 | 179 | except Exception, error: |
181 | 180 | print '''Encountered the following error while writing article |
182 | 181 | data to %s: %s''' % (self.fh_articles, error) |
| 182 | + self.articles = {} |
183 | 183 | #t1 = datetime.datetime.now() |
184 | 184 | #print '%s articles took %s' % (len(self.articles.keys()), (t1 - t0)) |
185 | 185 | |
Index: trunk/tools/editor_trends/classes/storage.py |
— | — | @@ -115,6 +115,11 @@ |
116 | 116 | print 'It seems that you are running out of disk space. \ |
117 | 117 | Error message: %s' % error |
118 | 118 | 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) |
119 | 124 | |
120 | 125 | def update(self, key, value, data): |
121 | 126 | assert isinstance(data, dict), 'You need to feed me dictionaries.' |
Index: trunk/tools/editor_trends/classes/dataset.py |
— | — | @@ -477,7 +477,10 @@ |
478 | 478 | n = len(number_list) |
479 | 479 | for i in number_list: |
480 | 480 | 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 '.' |
482 | 485 | |
483 | 486 | def get_median(self, number_list): |
484 | 487 | if number_list == []: |
Index: trunk/tools/editor_trends/classes/analytics.py |
— | — | @@ -82,7 +82,7 @@ |
83 | 83 | Generic loop function that loops over all the editors of a Wikipedia |
84 | 84 | project and then calls the plugin that does the actual mapping. |
85 | 85 | ''' |
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) |
87 | 87 | while True: |
88 | 88 | try: |
89 | 89 | task = self.tasks.get(block=False) |