Revision: 8309
Author: filnik
Date: 2010-06-19 10:13:14 +0000 (Sat, 19 Jun 2010)
Log Message:
-----------
Two bugfix in the duplicate function
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2010-06-18 17:04:08 UTC (rev 8308)
+++ trunk/pywikipedia/checkimages.py 2010-06-19 10:13:14 UTC (rev 8309)
@@ -433,7 +433,7 @@
# Regex to detect the template put in the image's decription to find the dupe
duplicatesRegex = {
'_default':None,
- 'commons': r'\{\{(?:[Tt]emplate:|)[Dd]upe[|}]',
+ 'commons': r'\{\{(?:[Tt]emplate:|)(?:[Dd]up(?:licat|)e|[Bb]ad[ _][Nn]ame)[|}]',
'it' : r'\{\{(?:[Tt]emplate:|)[Pp]rogetto:[Cc]oordinamento/Immagini/Bot/Template duplicati[|}]',
}
# Category with the licenses and / or with subcategories with the other licenses.
@@ -917,13 +917,10 @@
for duplicate in duplicates:
DupePage = wikipedia.ImagePage(self.site, duplicate)
-
- if DupePage.urlname() == self.image.urlname() and self.timestamp != None:
- imagedata = self.timestamp
- else:
- imagedata = DupePage.getLatestUploader()[1]
- # '2008-06-18T08:04:29Z'
- data = time.strptime(imagedata, u"%Y-%m-%dT%H:%M:%SZ")
+
+ if DupePage.urlname() != self.image.urlname() or self.timestamp == None:
+ self.timestamp = DupePage.getLatestUploader()[1]
+ data = time.strptime(self.timestamp, u"%Y-%m-%dT%H:%M:%SZ")
data_seconds = time.mktime(data)
time_image_list.append([data_seconds, duplicate])
time_list.append(data_seconds)
@@ -952,7 +949,7 @@
# string += "*[[:%s%s]]" % (self.image_namespace, duplicate)
else:
wikipedia.output(u"Already put the dupe-template in the files's page or in the dupe's page. Skip.")
- return True # Ok - No problem. Let's continue the checking phase
+ return False # Ok - No problem. Let's continue the checking phase
older_image_ns = u'%s%s' % (self.image_namespace, older_image) # adding the namespace
only_report = False # true if the image are not to be tagged as dupes
Revision: 8307
Author: xqt
Date: 2010-06-18 15:52:34 +0000 (Fri, 18 Jun 2010)
Log Message:
-----------
fix for replaceExcept() with exceptionRegexes['template'] because a infinite loop occures by some maths expression even they are excluded by 'math'. Example: <math>\mathrm{{}^{9}_4 Be + {}^{4}_2 \alpha \to {}^{1}{}^{2}_6 C + {}^{1}_0 n }</math>
Modified Paths:
--------------
branches/rewrite/pywikibot/textlib.py
trunk/pywikipedia/pywikibot/textlib.py
Modified: branches/rewrite/pywikibot/textlib.py
===================================================================
--- branches/rewrite/pywikibot/textlib.py 2010-06-18 10:55:33 UTC (rev 8306)
+++ branches/rewrite/pywikibot/textlib.py 2010-06-18 15:52:34 UTC (rev 8307)
@@ -80,7 +80,7 @@
# templates cascaded up to level 2, but no deeper. For arbitrary
# depth, we'd need recursion which can't be done in Python's re.
# After all, the language of correct parenthesis words is not regular.
- 'template': re.compile(r'(?s){{(({{.*?}})?.*?)*}}'),
+ 'template': re.compile(r'(?s){{(({{.*?}})|.)*}}'),
'hyperlink': compileLinkR(),
'gallery': re.compile(r'(?is)<gallery.*?>.*?</gallery>'),
# this matches internal wikilinks, but also interwiki, categories, and
Modified: trunk/pywikipedia/pywikibot/textlib.py
===================================================================
--- trunk/pywikipedia/pywikibot/textlib.py 2010-06-18 10:55:33 UTC (rev 8306)
+++ trunk/pywikipedia/pywikibot/textlib.py 2010-06-18 15:52:34 UTC (rev 8307)
@@ -80,7 +80,7 @@
# templates cascaded up to level 2, but no deeper. For arbitrary
# depth, we'd need recursion which can't be done in Python's re.
# After all, the language of correct parenthesis words is not regular.
- 'template': re.compile(r'(?s){{(({{.*?}})?.*?)*}}'),
+ 'template': re.compile(r'(?s){{(({{.*?}})|.)*}}'),
'hyperlink': compileLinkR(),
'gallery': re.compile(r'(?is)<gallery.*?>.*?</gallery>'),
# this matches internal wikilinks, but also interwiki, categories, and
Revision: 8304
Author: cydeweys
Date: 2010-06-16 17:54:08 +0000 (Wed, 16 Jun 2010)
Log Message:
-----------
Update to handle parsing of date links from CFD template parameters.
Modified Paths:
--------------
trunk/pywikipedia/category.py
trunk/pywikipedia/cfd.py
Modified: trunk/pywikipedia/category.py
===================================================================
--- trunk/pywikipedia/category.py 2010-06-16 15:28:12 UTC (rev 8303)
+++ trunk/pywikipedia/category.py 2010-06-16 17:54:08 UTC (rev 8304)
@@ -429,7 +429,7 @@
"""Robot to move pages from one category to another."""
def __init__(self, oldCatTitle, newCatTitle, batchMode=False,
editSummary='', inPlace=False, moveCatPage=True,
- deleteEmptySourceCat=True, titleRegex=None):
+ deleteEmptySourceCat=True, titleRegex=None, useSummaryForDeletion=True):
site = pywikibot.getSite()
self.editSummary = editSummary
self.oldCat = catlib.Category(site, oldCatTitle)
@@ -439,6 +439,7 @@
self.batchMode = batchMode
self.deleteEmptySourceCat = deleteEmptySourceCat
self.titleRegex = titleRegex
+ self.useSummaryForDeletion = useSummaryForDeletion
def run(self):
site = pywikibot.getSite()
@@ -450,6 +451,13 @@
except TypeError:
self.editSummary = pywikibot.translate(site, msg_change) % self.oldCat.title()
+ if self.useSummaryForDeletion and self.editSummary:
+ reason = self.editSummary
+ else:
+ reason = pywikibot.translate(site, deletion_reason_move) \
+ % (self.newCatTitle, self.newCatTitle)
+
+
# Copy the category contents to the new category page
copied = False
oldMovedTalk = None
@@ -459,8 +467,6 @@
pywikibot.translate(site, cfd_templates))
# Also move the talk page
if copied:
- reason = pywikibot.translate(site, deletion_reason_move) \
- % (self.newCatTitle, self.newCatTitle)
oldTalk = self.oldCat.toggleTalkPage()
if oldTalk.exists():
newTalkTitle = newCat.toggleTalkPage().title()
@@ -494,14 +500,13 @@
if not self.titleRegex or re.search(self.titleRegex,
subcategory.title()):
catlib.change_category(subcategory, self.oldCat, newCat,
+
comment=self.editSummary,
inPlace=self.inPlace)
# Delete the old category and its moved talk page
if copied and self.deleteEmptySourceCat == True:
if self.oldCat.isEmpty():
- reason = pywikibot.translate(site, deletion_reason_move) \
- % (self.newCatTitle, self.newCatTitle)
confirm = not self.batchMode
self.oldCat.delete(reason, confirm, mark = True)
if oldMovedTalk is not None:
Modified: trunk/pywikipedia/cfd.py
===================================================================
--- trunk/pywikipedia/cfd.py 2010-06-16 15:28:12 UTC (rev 8303)
+++ trunk/pywikipedia/cfd.py 2010-06-16 17:54:08 UTC (rev 8304)
@@ -17,9 +17,13 @@
import re
import category
-# The locateion of the CFD working page.
+# The location of the CFD working page.
cfdPage = 'Wikipedia:Categories for discussion/Working'
+# A list of templates that are used on category pages as part of the CFD
+# process that contain information such as the link to the per-day discussion page.
+cfdTemplates = ['Cfd full', 'Cfr full']
+
# Regular expression declarations
# See the en-wiki CFD working page at [[Wikipedia:Categories for discussion/Working]]
# to see how these work in context. To get this bot working on other wikis you will
@@ -83,13 +87,15 @@
day = "None"
elif (m.check(dateheader, line)):
day = m.result.group(1)
+ wikipedia.output("Found day header: %s" % day)
elif (m.check(movecat, line)):
src = m.result.group(1)
dest = m.result.group(2)
- if (mode == "Move" and day != "None"):
- summary = "Robot - Moving category " + src + " to " + dest + " per [[WP:CFD|CFD]] at " + findDay(src, day) + "."
+ thisDay = findDay(src, day)
+ if (mode == "Move" and thisDay != "None"):
+ summary = "Robot - Moving category " + src + " to " + dest + " per [[WP:CFD|CFD]] at " + thisDay + "."
elif (mode == "Speedy"):
- summary = "Robot - Speedily moving category " + src + " to " + dest + " per [[WP:CFD|CFD]]."
+ summary = "Robot - Speedily moving category " + src + " to " + dest + " per [[WP:CFDS|CFDS]]."
else:
continue
# If the category is redirect, we do NOT want to move articles to
@@ -104,14 +110,15 @@
else:
robot = category.CategoryMoveRobot(oldCatTitle=src, newCatTitle=dest, batchMode=True,
editSummary=summary, inPlace=True, moveCatPage=True,
- deleteEmptySourceCat=True)
+ deleteEmptySourceCat=True, useSummaryForDeletion=True)
elif (m.check(deletecat, line)):
src = m.result.group(1)
# I currently don't see any reason to handle these two cases separately, though
# if are guaranteed that the category in the "Delete" case is empty, it might be
# easier to call delete.py on it.
- if ((mode == "Empty" or mode == "Delete") and day != "None"):
- summary = "Robot - Removing category " + src + " per [[WP:CFD|CFD]] at " + findDay(src, day) + "."
+ thisDay = findDay(src, day)
+ if ((mode == "Empty" or mode == "Delete") and thisDay != "None"):
+ summary = "Robot - Removing category " + src + " per [[WP:CFD|CFD]] at " + thisDay + "."
else:
continue
robot = category.CategoryRemoveRobot(catTitle=src, batchMode=True, editSummary=summary,
@@ -142,7 +149,22 @@
if (m != None):
return "[[" + m.group(1) + "]]"
else:
- wikipedia.output("Could not find CFD day link on Category:" + pageTitle + "\n", toStdout=True)
+ # Try to parse day link from CFD template parameters.
+ templates = page.templatesWithParams()
+ for template in templates:
+ if template[0] in cfdTemplates:
+ params = template[1]
+ (day, month, year) = [None, None, None]
+ for param in params:
+ (paramName, paramVal) = param.split('=', 1)
+ if (paramName == 'day'):
+ day = paramVal
+ elif (paramName == 'month'):
+ month = paramVal
+ elif (paramName == 'year'):
+ year = paramVal
+ if (day and month and year):
+ return "[[Wikipedia:Categories for discussion/Log/%s %s %s]]" % (year, month, day)
return oldDay
if __name__ == "__main__":
Revision: 8301
Author: multichill
Date: 2010-06-15 18:20:56 +0000 (Tue, 15 Jun 2010)
Log Message:
-----------
Add PD-user to the skip list. Bot should only be used on own work images (for now at least).
Modified Paths:
--------------
trunk/pywikipedia/imagecopy_enwp.py
Modified: trunk/pywikipedia/imagecopy_enwp.py
===================================================================
--- trunk/pywikipedia/imagecopy_enwp.py 2010-06-15 18:02:47 UTC (rev 8300)
+++ trunk/pywikipedia/imagecopy_enwp.py 2010-06-15 18:20:56 UTC (rev 8301)
@@ -108,6 +108,7 @@
u'PUI',
u'Pui',
u'Ffd',
+ u'PD-user', # Only the self templates are supported for now.
]