r92210 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92209‎ | r92210 | r92211 >
Date:22:48, 14 July 2011
Author:halfak
Status:deferred
Tags:
Comment:
Added recording file wrapper
Modified paths:
  • /trunk/tools/wsor/scripts/classes/file_wrapper.py (modified) (history)

Diff [purge]

Index: trunk/tools/wsor/scripts/classes/file_wrapper.py
@@ -1,6 +1,30 @@
22 import sys
33 from StringIO import StringIO
 4+from collections import deque
45
 6+class RecordingFileWrapper(FileWrapper):
 7+
 8+ def __init__(self, fp, pre='', post='', record=10000):
 9+ self.history = deque(maxsize=record)
 10+ FileWrapper.__init__(self, fp, pre=pre, post=post)
 11+
 12+ def read(self, bytes=sys.maxint):
 13+ outBytes = FileWrapper.read(self, bytes)
 14+ self.history.extend(outBytes)
 15+ return outBytes
 16+
 17+ def readline(self):
 18+ outBytes = FileWrapper.readline(self)
 19+ self.history.extend(outBytes)
 20+ return outBytes
 21+
 22+ def getHistory(self):
 23+ return ''.join(self.history)
 24+
 25+
 26+
 27+
 28+
529 class FileWrapper:
630
731 def __init__(self, fp, pre='', post=''):

Status & tagging log