http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10797
Revision: 10797 Author: xqt Date: 2012-12-15 13:08:17 +0000 (Sat, 15 Dec 2012) Log Message: ----------- strip trailing whitespace
Modified Paths: -------------- trunk/pywikipedia/casechecker.py trunk/pywikipedia/cosmetic_changes.py
Modified: trunk/pywikipedia/casechecker.py =================================================================== --- trunk/pywikipedia/casechecker.py 2012-12-15 13:06:49 UTC (rev 10796) +++ trunk/pywikipedia/casechecker.py 2012-12-15 13:08:17 UTC (rev 10797) @@ -220,7 +220,7 @@
if not os.path.isabs(self.failedTitles): self.failedTitles = pywikibot.config.datafilepath(self.failedTitles) - + if self.doFailed: with codecs.open(self.failedTitles, 'r', 'utf-8') as f: self.titleList = [self.Page(t) for t in f] @@ -274,7 +274,7 @@ if len(data['query']['pageids']) == 1: pageid = data['query']['pageids'][0] links = data['query']['pages'][pageid]['links'] - + allWords = [nn for n in links for nn in self.FindBadWords(n['title'])]
self.knownWords = set(allWords) @@ -301,7 +301,7 @@
# Process received data yield data - + # Clear any continuations first if 'clcontinue' in params: del params['clcontinue'] if 'plcontinue' in params: del params['plcontinue'] @@ -320,7 +320,7 @@ else: raise ValueError(u'Unexpected query-continue values: %s' % qc) continue - + def Run(self): try: self.lastLetter = '' @@ -357,7 +357,7 @@
firstItem = True for pageID, page in data['query']['pages'].iteritems(): - + printed = False title = page['title'] self.currentTitle = title @@ -479,7 +479,7 @@ if self.PutNewPage(pageObj, pageTxt, msg): # done, no need to log anything foundSuggestions = False - + if foundSuggestions: self.AppendLineToLog(self.failedTitles, title)
@@ -501,14 +501,14 @@ def ProcessTitle(self, title):
badWords = list(self.FindBadWords(title)) - + if len(badWords) > 0: # Allow known words, allow any roman numerals with local suffixes badWords = set([i for i in badWords if i not in self.knownWords and self.romanNumSfxPtrn.match(i) is not None]) - + if len(badWords) == 0 or self.Page(title).isImage(): return None - + count = 0 ambigBadWords = set() ambigBadWordsCount = 0 @@ -614,7 +614,7 @@ return (infoText, possibleAlternatives)
def PickTarget(self, title, original, candidates): - + if len(candidates) == 0: return None
@@ -719,13 +719,13 @@ bl = data['query']['backlinks'] cl = len(bl) redirs = len([i for i in bl if 'redirect' in i]) - + if cl > 0 and 'query-continue' in data: count = '50+' else: count = str(cl if cl > 0 else 'no backlinks') - - self.AppendLineToLog(self.nosuggestions, u'* %s (%s%s)' % + + self.AppendLineToLog(self.nosuggestions, u'* %s (%s%s)' % (self.MakeLink(title), count, u', %d redirects' % redirs if redirs > 0 else u'')) return False
@@ -764,7 +764,7 @@ return codecs.open(filename, 'a', 'utf-8') except IOError: return codecs.open(filename, 'w', 'utf-8') - + def AppendLineToLog(self, filename, text): with self.OpenLogFile(filename) as f: f.write(text + u'\n') @@ -788,6 +788,7 @@
return text
+ if __name__ == "__main__": try: bot = CaseChecker()
Modified: trunk/pywikipedia/cosmetic_changes.py =================================================================== --- trunk/pywikipedia/cosmetic_changes.py 2012-12-15 13:06:49 UTC (rev 10796) +++ trunk/pywikipedia/cosmetic_changes.py 2012-12-15 13:08:17 UTC (rev 10797) @@ -82,7 +82,7 @@ 'fr' : u'<!-- Autres langues -->', 'nn' : (u'<!--interwiki (no, sv, da first; then other languages alphabetically by name)-->', u'(<!-- ?interwiki \(no(?:/nb)?, ?sv, ?da first; then other languages alphabetically by name\) ?-->)') -} +}
# This is from interwiki.py; # move it to family file and implement global instances
pywikipedia-svn@lists.wikimedia.org