Revision: 4199
Author: russblau
Date: 2007-09-05 15:43:39 +0000 (Wed, 05 Sep 2007)
Log Message:
-----------
Untabify; catch LockedPage exception
Modified Paths:
--------------
trunk/pywikipedia/catlib.py
Modified: trunk/pywikipedia/catlib.py
===================================================================
--- trunk/pywikipedia/catlib.py 2007-09-05 15:20:55 UTC (rev 4198)
+++ trunk/pywikipedia/catlib.py 2007-09-05 15:43:39 UTC (rev 4199)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Library to work with category pages on Wikipedia
@@ -50,6 +50,7 @@
l.sort()
return l
+
class Category(wikipedia.Page):
"""Subclass of Page that has some special tricks that only work for
category: pages"""
@@ -81,7 +82,6 @@
else:
return '[[%s]]' % titleWithSortKey
-
def _getContentsAndSupercats(self, recurse=False, purge=False,
startFrom=None):
"""
@@ -392,17 +392,17 @@
wikipedia.output('Moving text from %s to %s.' % (self.title(),
targetCat.title()))
authors = ', '.join(self.contributingUsers())
creationSummary = wikipedia.translate(wikipedia.getSite(),
msg_created_for_renaming) % (self.title(), authors)
- newtext = self.get()
- for regexName in cfdTemplates:
- matchcfd = re.compile(r"{{%s.*?}}" % regexName, re.IGNORECASE)
- newtext = matchcfd.sub('',newtext)
+ newtext = self.get()
+ for regexName in cfdTemplates:
+ matchcfd = re.compile(r"{{%s.*?}}" % regexName, re.IGNORECASE)
+ newtext = matchcfd.sub('',newtext)
matchcomment = re.compile(r"<!--BEGIN CFD TEMPLATE-->.*<!--END
CFD TEMPLATE-->", re.IGNORECASE | re.MULTILINE | re.DOTALL)
newtext = matchcomment.sub('',newtext)
pos = 0
while (newtext[pos:pos+1] == "\n"):
pos = pos + 1
newtext = newtext[pos:]
- targetCat.put(newtext, creationSummary)
+ targetCat.put(newtext, creationSummary)
return True
#def Category(code, name):
@@ -461,9 +461,15 @@
try:
article.put(text, comment)
except wikipedia.EditConflict:
- wikipedia.output(u'Skipping %s because of edit conflict' %
(article.title()))
+ wikipedia.output(
+ u'Skipping %s because of edit conflict' % article.title())
except wikipedia.SpamfilterError, e:
- wikipedia.output(u'Skipping %s because of blacklist entry %s' %
(page.title(), e.url))
+ wikipedia.output(
+ u'Skipping %s because of blacklist entry %s'
+ % (page.title(), e.url))
+ except wikipedia.LockedPage:
+ wikipedia.output(
+ u'Skipping %s because page is locked' % article.title())
def test():
site = wikipedia.getSite()
Show replies by date