r85095 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85094‎ | r85095 | r85096 >
Date:22:07, 31 March 2011
Author:diederik
Status:deferred
Tags:
Comment:
Incorporated fixes suggested by pylint
Modified paths:
  • /trunk/tools/editor_trends/etl/sort.py (modified) (history)

Diff [purge]

Index: trunk/tools/editor_trends/etl/sort.py
@@ -19,18 +19,19 @@
2020
2121
2222 import heapq
23 -import sys
24 -import os
2523 import multiprocessing
2624 import progressbar
2725 from Queue import Empty
2826
2927 from utils import file_utils
30 -from utils import messages
3128 from classes import consumers
3229
3330
3431 class Sorter(consumers.BaseConsumer):
 32+ '''
 33+ This class takes care of sorting the different csv files as they have been
 34+ generated by the Extracter task. A merge sort is used for this purpose.
 35+ '''
3536 def run(self):
3637 '''
3738 The feeder function is called by the launcher and gives it a task to
@@ -43,7 +44,8 @@
4445 if filename == None:
4546 self.result.put(None)
4647 break
47 - elif filename.startswith('comments') or filename.startswith('title'):
 48+ elif filename.startswith('comments') or \
 49+ filename.startswith('title'):
4850 continue
4951 fh = file_utils.create_txt_filehandle(self.rts.txt,
5052 filename,
@@ -59,10 +61,10 @@
6062 sorted_data = mergesort(data)
6163 write_sorted_file(sorted_data, filename, self.rts)
6264 self.result.put(True)
63 - except UnicodeDecodeError, e:
64 - print 'Error: %s, (%s)' % (e, filename)
65 - except MemoryError, e:
66 - print 'Error: %s, (%s)' % (e, filename)
 65+ except UnicodeDecodeError, error:
 66+ print 'Error: %s, (%s)' % (error, filename)
 67+ except MemoryError, error:
 68+ print 'Error: %s, (%s)' % (error, filename)
6769 except Empty:
6870 pass
6971
@@ -102,11 +104,9 @@
103105 """Merge two sorted lists together. Returns the merged list."""
104106 result = []
105107 while front and back:
106 - '''
107 - pick the smaller one from the front and stick it on
 108+ '''pick the smaller one from the front and stick it on
108109 note that list.pop(0) is a linear operation, so this gives quadratic
109 - running time...
110 - '''
 110+ running time...'''
111111 result.append(front.pop(0) if front[0] <= back[0] else back.pop(0))
112112 # add the remaining end
113113 result.extend(front or back)