http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10782
Revision: 10782 Author: xqt Date: 2012-12-11 10:55:23 +0000 (Tue, 11 Dec 2012) Log Message: ----------- some PEP8 changes
Modified Paths: -------------- branches/rewrite/pywikibot/data/logentries.py
Modified: branches/rewrite/pywikibot/data/logentries.py =================================================================== --- branches/rewrite/pywikibot/data/logentries.py 2012-12-11 10:53:08 UTC (rev 10781) +++ branches/rewrite/pywikibot/data/logentries.py 2012-12-11 10:55:23 UTC (rev 10782) @@ -3,7 +3,7 @@ Objects representing Mediawiki log entries """ # -# (C) Pywikipedia bot team, 2007-08 +# (C) Pywikipedia bot team, 2007-12 # # Distributed under the terms of the MIT license. # @@ -14,6 +14,7 @@
_logger = "wiki"
+ class LogDict(dict): """ Simple custom dictionary that raises a custom KeyError and logs @@ -24,6 +25,7 @@ _logger) raise KeyError("Log entry has no '%s' key" % key, key)
+ class LogEntry(object): """Generic log entry"""
@@ -36,7 +38,7 @@ """Initialize object from a logevent dict returned by MW API""" self.data = LogDict(apidata) if self._expectedType is not None and self._expectedType != self.type(): - raise Error("Wrong log type! Expecting %s, received %s instead." \ + raise Error("Wrong log type! Expecting %s, received %s instead." % (self._expectedType, self.type()))
def __hash__(self): @@ -77,6 +79,7 @@ def comment(self): return self.data['comment']
+ class BlockEntry(LogEntry): _expectedType = 'block' def __init__(self, apidata): @@ -149,6 +152,7 @@ self._getBlockDetails()['expiry']) return self._expiry
+ class ProtectEntry(LogEntry): _expectedType = 'protect'
@@ -161,6 +165,7 @@ class UploadEntry(LogEntry): _expectedType = 'upload'
+ class MoveEntry(LogEntry): _expectedType = 'move'
@@ -170,7 +175,7 @@ def new_title(self): """Page object of the new title""" if not hasattr(self, '_new_title'): - self._new_title = pywikibot.Page(pywikibot.Link( \ + self._new_title = pywikibot.Page(pywikibot.Link( self.data['move']['new_title'])) return self._new_title