Revision: 6146
Author: filnik
Date: 2008-12-14 11:16:08 +0000 (Sun, 14 Dec 2008)
Log Message:
-----------
Fixed more or less all the problems dued to the change of namespace
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2008-12-12 20:24:40 UTC (rev 6145)
+++ trunk/pywikipedia/checkimages.py 2008-12-14 11:16:08 UTC (rev 6146)
@@ -387,15 +387,15 @@
}
# Comment used by the bot while it reports the problem in the uploader's talk
duplicates_comment_talk = {
- 'commons': u'Bot: Dupe image found',
+ 'commons': u'Bot: Dupe file found',
'en' : None,
- 'it' : u"Bot: Notifico l'immagine doppia trovata",
+ 'it' : u"Bot: Notifico il file doppio trovato",
}
# Comment used by the bot while it reports the problem in the image
duplicates_comment_image = {
- 'commons': u'Bot: Tagging dupe image',
+ 'commons': u'Bot: Tagging dupe file',
'en' : None,
- 'it' : u'Bot: Immagine doppia, da cancellare',
+ 'it' : u'Bot: File doppio, da cancellare',
}
# Regex to detect the template put in the image's decription to find the dupe
duplicatesRegex = {
@@ -650,7 +650,7 @@
def tag_image(self, put = True):
""" Function to add the template in the image and to find out
- who's the user that has uploaded the image. """
+ who's the user that has uploaded the file. """
# Get the image's description
reportPageObject = wikipedia.ImagePage(self.site, self.image_namespace + self.image_to_report)
try:
@@ -670,7 +670,7 @@
else:
nick = reportPageObject.getLatestUploader()[0]
except wikipedia.NoPage:
- wikipedia.output(u"Seems that %s hasn't the image at all, but there is something in the description..." % self.image_to_report)
+ wikipedia.output(u"Seems that %s has only the description and not the file..." % self.image_to_report)
repme = u"\n*[[:File:%s]] problems '''with the APIs'''"
# We have a problem! Report and exit!
self.report_image(self.image_to_report, self.rep_page, self.com, repme)
@@ -742,7 +742,7 @@
emailClass.send(emailSubj, text_to_send)
def untaggedGenerator(self, untaggedProject, limit):
- """ Generator that yield the images without license. It's based on a tool of the toolserver. """
+ """ Generator that yield the files without license. It's based on a tool of the toolserver. """
lang = untaggedProject.split('.', 1)[0]
project = '.%s' % untaggedProject.split('.', 1)[1]
if lang == 'commons':
@@ -849,7 +849,7 @@
return number_edits
def checkImageOnCommons(self):
- """ Checking if the image is on commons """
+ """ Checking if the file is on commons """
wikipedia.output(u'Checking if %s is on commons...' % self.imageName)
commons_site = wikipedia.getSite('commons', 'commons')
regexOnCommons = r"\n\*\[\[:File:%s\]\] is also on '''Commons''': \[\[commons:File:.*?\]\](?: \(same name\)|)$" % re.escape(self.imageName)
@@ -864,7 +864,7 @@
imagePage = wikipedia.ImagePage(self.site, u'File:%s' % self.imageName)
on_commons_text = imagePage.getImagePageHtml()
if u"<div class='sharedUploadNotice'>" in on_commons_text:
- wikipedia.output(u"But, the image doesn't exist on your project! Skip...")
+ wikipedia.output(u"But, the file doesn't exist on your project! Skip...")
# Problems? Yes! We have to skip the check part for that image!
# Because it's on commons but someone has added something on your project.
return False
@@ -885,7 +885,7 @@
return True
def checkImageDuplicated(self, duplicates_rollback):
- """ Function to check the duplicated images. """
+ """ Function to check the duplicated files. """
# {{Dupe|File:Blanche_Montel.jpg}}
# Skip the stub images
#if 'stub' in self.imageName.lower() and self.project == 'wikipedia' and self.site.lang == 'it':
@@ -944,7 +944,7 @@
#else:
# string += "*[[:%s%s]]" % (self.image_namespace, duplicate)
else:
- wikipedia.output(u"Already put the dupe-template in the image's page or in the dupe's page. Skip.")
+ 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
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
@@ -996,7 +996,7 @@
return True # Ok - No problem. Let's continue the checking phase
def report_image(self, image_to_report, rep_page = None, com = None, rep_text = None, addings = True, regex = None):
- """ Function to report the images in the report page when needed. """
+ """ Function to report the files in the report page when needed. """
if rep_page == None: rep_page = self.rep_page
if com == None: com = self.com
if rep_text == None: rep_text = self.rep_text
@@ -1009,7 +1009,7 @@
except wikipedia.IsRedirectPage:
text_get = another_page.getRedirectTarget().get()
if len(text_get) >= self.logFulNumber:
- raise LogIsFull(u"The log page (%s) is full! Please delete the old images reported." % another_page.title())
+ raise LogIsFull(u"The log page (%s) is full! Please delete the old files reported." % another_page.title())
pos = 0
# The talk page includes "_" between the two names, in this way i replace them to " "
n = re.compile(regex, re.UNICODE|re.M)
@@ -1211,10 +1211,10 @@
return list_loaded
def skipImages(self, skip_number, limit):
- """ Given a number of images, skip the first -number- images. """
+ """ Given a number of files, skip the first -number- files. """
# If the images to skip are more the images to check, make them the same number
if skip_number == 0:
- wikipedia.output(u'\t\t>> No images to skip...<<')
+ wikipedia.output(u'\t\t>> No files to skip...<<')
return False
if skip_number > limit: skip_number = limit
# Print a starting message only if no images has been skipped
@@ -1240,62 +1240,67 @@
first x seconds.
"""
imagesToSkip = 0
- while 1:
- loadOtherImages = True # ensure that all the images loaded aren't to skip!
- for image in generator:
- if normal:
- imageData = image
- image = imageData[0]
- timestamp = imageData[1]
- else:
- timestamp = image.getLatestUploader()[1]
- #http://pytz.sourceforge.net/ <- maybe useful?
- # '2008-06-18T08:04:29Z'
- img_time = datetime.datetime.strptime(timestamp, u"%Y-%m-%dT%H:%M:%SZ") #not relative to localtime
- now = datetime.datetime.strptime(str(datetime.datetime.utcnow()).split('.')[0], "%Y-%m-%d %H:%M:%S") #timezones are UTC
- # + seconds to be sure that now > img_time
- while now < img_time:
- now = (now + datetime.timedelta(seconds=1))
- delta = now - img_time
- secs_of_diff = delta.seconds
- if waitTime > secs_of_diff:
- wikipedia.output(u'Skipping %s, uploaded %s seconds ago..' % (image.title(), int(secs_of_diff)))
- imagesToSkip += 1
- continue # Still wait
- else:
- loadOtherImages = False
- break # No ok, continue
- # if yes, we have skipped all the images given!
- if loadOtherImages:
- generator = self.site.newimages(number = limit, lestart = timestamp)
- imagesToSkip = 0
- # continue to load images! continue
- continue
- else:
- break # ok some other images, go below
# if normal, we can take as many images as "limit" has told us, otherwise, sorry, nope.
if normal:
- newGen = list()
- imagesToSkip += 1 # some calcs, better add 1
- # Add new images, instead of the images skipped
- newImages = self.site.newimages(number = imagesToSkip, lestart = timestamp)
- for imageData in generator:
- if normal:
- image = imageData[0]
- timestamp = imageData[1]
- uploader = imageData[2]
- comment = imageData[3]
- newGen.append([image, timestamp, uploader, comment])
+ printWithTimeZone(u'Skipping the files uploaded less than %s seconds ago..' % waitTime)
+ while 1:
+ loadOtherImages = True # ensure that all the images loaded aren't to skip!
+ for image in generator:
+ image = wikipedia.ImagePage(self.site, image.title())
+ if normal:
+ imageData = image
+ image = imageData[0]
+ timestamp = imageData[1]
+ else:
+ timestamp = image.getLatestUploader()[1]
+ #http://pytz.sourceforge.net/ <- maybe useful?
+ # '2008-06-18T08:04:29Z'
+ img_time = datetime.datetime.strptime(timestamp, u"%Y-%m-%dT%H:%M:%SZ") #not relative to localtime
+ now = datetime.datetime.strptime(str(datetime.datetime.utcnow()).split('.')[0], "%Y-%m-%d %H:%M:%S") #timezones are UTC
+ # + seconds to be sure that now > img_time
+ while now < img_time:
+ now = (now + datetime.timedelta(seconds=1))
+ delta = now - img_time
+ secs_of_diff = delta.seconds
+ if waitTime > secs_of_diff:
+ wikipedia.output(u'Skipping %s, uploaded %s seconds ago..' % (image.title(), int(secs_of_diff)))
+ imagesToSkip += 1
+ continue # Still wait
+ else:
+ loadOtherImages = False
+ break # No ok, continue
+ # if yes, we have skipped all the images given!
+ if loadOtherImages:
+ generator = self.site.newimages(number = limit, lestart = timestamp)
+ imagesToSkip = 0
+ # continue to load images! continue
+ continue
else:
- image = imageData
- newGen.append(image)
- num = 0
- for imageData in newImages:
- newGen.append(imageData)
- return newGen
+ break # ok some other images, go below
+ newGen = list()
+ imagesToSkip += 1 # some calcs, better add 1
+ # Add new images, instead of the images skipped
+ newImages = self.site.newimages(number = imagesToSkip, lestart = timestamp)
+ for imageData in generator:
+ if normal:
+ image = imageData[0]
+ timestamp = imageData[1]
+ uploader = imageData[2]
+ comment = imageData[3]
+ newGen.append([image, timestamp, uploader, comment])
+ else:
+ image = imageData
+ newGen.append(image)
+ num = 0
+ for imageData in newImages:
+ newGen.append(imageData)
+ return newGen
+ else:
+ wikipedia.output(u"The wait option is available only with the standard generator.")
+ return generator
def isTagged(self):
- """ Understand if an image is already tagged or not. """
+ """ Understand if a file is already tagged or not. """
TextFind = wikipedia.translate(self.site, txt_find)
# Is the image already tagged? If yes, no need to double-check, skip
for i in TextFind:
@@ -1427,9 +1432,9 @@
# Here begins the check block.
if self.some_problem == True:
if self.mex_used in self.imageCheckText:
- wikipedia.output(u'Image already fixed. Skip.')
+ wikipedia.output(u'File already fixed. Skip.')
return True
- wikipedia.output(u"The image description for %s contains %s..." % (self.imageName, self.name_used))
+ wikipedia.output(u"The file's description for %s contains %s..." % (self.imageName, self.name_used))
if self.mex_used.lower() == 'default':
self.mex_used = unvertext
if self.imagestatus_used == False:
@@ -1440,7 +1445,7 @@
#if self.imagestatus_used == True:
self.report(self.mex_used, self.imageName, self.text_used, u"\n%s\n" % self.head_used, None, self.imagestatus_used, self.summary_used)
else:
- wikipedia.output(u"Skipping the image...")
+ wikipedia.output(u"Skipping the file...")
self.some_problem = False
return True
elif brackets == True and license_found != None:
@@ -1458,7 +1463,7 @@
delete = False
return True
elif self.imageCheckText in nothing:
- wikipedia.output(u"The image description for %s does not contain a license template!" % self.imageName)
+ wikipedia.output(u"The file's description for %s does not contain a license template!" % self.imageName)
if hiddenTemplateFound and HiddenTN != None and HiddenTN != '' and HiddenTN != ' ':
notification = HiddenTN % self.imageName
else:
@@ -1483,7 +1488,7 @@
limit = 80 # How many images check?
time_sleep = 30 # How many time sleep after the check?
skip_number = 0 # How many images to skip before checking?
- wait_number = 0 # How many time sleep before the check?
+ waitTime = 0 # How many time sleep before the check?
commonsActive = False # Check if on commons there's an image with the same name?
normal = False # Check the new images or use another generator?
urlUsed = False # Use the url-related function instead of the new-pages generator
@@ -1497,7 +1502,7 @@
for arg in wikipedia.handleArgs():
if arg.startswith('-limit'):
if len(arg) == 7:
- limit = int(wikipedia.input(u'How many images do you want to check?'))
+ limit = int(wikipedia.input(u'How many files do you want to check?'))
else:
limit = int(arg[7:])
if arg.startswith('-time'):
@@ -1522,22 +1527,23 @@
elif arg.startswith('-skip'):
if len(arg) == 5:
skip = True
- skip_number = int(wikipedia.input(u'How many images do you want to skip?'))
+ skip_number = int(wikipedia.input(u'How many files do you want to skip?'))
elif len(arg) > 5:
skip = True
skip_number = int(arg[6:])
elif arg.startswith('-wait'):
if len(arg) == 5:
wait = True
- wait_number = int(wikipedia.input(u'How many time do you want to wait before checking the images?'))
+ waitTime = int(wikipedia.input(u'How many time do you want to wait before checking the files?'))
elif len(arg) > 5:
wait = True
- wait_number = int(arg[6:])
+ waitTime = int(arg[6:])
elif arg.startswith('-start'):
if len(arg) == 6:
firstPageTitle = wikipedia.input(u'From witch page do you want to start?')
elif len(arg) > 6:
firstPageTitle = arg[7:]
+ firstPageTitle = firstPageTitle.replace("File:", '').replace("file:", "")
generator = wikipedia.getSite().allpages(start=firstPageTitle, namespace=6)
repeat = False
elif arg.startswith('-page'):
@@ -1594,12 +1600,13 @@
site = wikipedia.getSite()
# Block of text to translate the parameters set above.
+ image_old_namespace = u"%s:" % site.image_namespace()
image_namespace = u"File:"
# If the images to skip are 0, set the skip variable to False (the same for the wait time)
if skip_number == 0:
skip = False
- if wait_number == 0:
+ if waitTime == 0:
wait = False
# A little block-statement to ensure that the bot will not start with en-parameters
@@ -1644,9 +1651,8 @@
# Not the main, but the most important loop.
#parsed = False
if wait:
- printWithTimeZone(u'Skipping the images uploaded less than %s seconds ago..' % wait_number)
# Let's sleep...
- generator = mainClass.wait(wait_number, generator, normal, limit)
+ generator = mainClass.wait(waitTime, generator, normal, limit)
for image in generator:
# When you've a lot of image to skip before working use this workaround, otherwise
# let this commented, thanks. [ decoment also parsed = False if you want to use it
@@ -1659,8 +1665,8 @@
# If the generator returns something that is not an image, simply skip it.
if normal == False and regexGen == False:
if image_namespace.lower() not in image.title().lower() and \
- 'file:' not in image.title().lower():
- wikipedia.output(u'%s seems not an image, skip it...' % image.title())
+ image_old_namespace.lower() not in image.title().lower() and 'file:' not in image.title().lower():
+ wikipedia.output(u'%s seems not an file, skip it...' % image.title())
continue
if normal:
imageData = image
@@ -1675,8 +1681,11 @@
try:
imageName = image.title().split(image_namespace)[1] # Deleting the namespace (useless here)
except IndexError:# Namespace image not found, that's not an image! Let's skip...
- wikipedia.output(u"%s is not an image, skipping..." % image.title())
- continue
+ try:
+ imageName = image.title().split(image_old_namespace)[1]
+ except IndexError:
+ wikipedia.output(u"%s is not a file, skipping..." % image.title())
+ continue
mainClass.setParameters(imageName, timestamp, uploader) # Setting the image for the main class
# Skip block
if skip == True:
Patches item #2424422, was opened at 2008-12-13 13:34
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=2424422&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Rick Block (rick_block)
Assigned to: Nobody/Anonymous (nobody)
Summary: -content option for replace.py
Initial Comment:
I have a number of tools I run at en.wikipedia that download pages, manipulate the pages using tools like awk, and then upload new versions of the pages. I've implemented an option to replace.py (-content) to provide a filename containing the replacement content for a page. The svn.diff file is attached. The same option can be used to create a new page with content from a specified file as well.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603140&aid=2424422&group_…
Bugs item #2422802, was opened at 2008-12-12 22:31
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2422802&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: interwiki
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Julian Mendez (julianmendez)
Assigned to: Nobody/Anonymous (nobody)
Summary: not every page with w:fr:Template:Sigle is a disambiguation
Initial Comment:
Template:Sigle (in English, acronym) at fr.wiki may be used for common articles (non-disambiguation pages).
Some examples are http://fr.wikipedia.org/wiki/COBOL , and http://fr.wikipedia.org/wiki/BASIC .
Please, see the file 'families/wikipedia_family.py', where 'Sigle' is connected to disambiguation pages.
Pywikipedia [http] trunk/pywikipedia (r6144, Dec 12 2008, 14:27:52)
Python 2.4.4 (#1, Jan 10 2007, 01:25:01) [C]
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=2422802&group_…
Revision: 6143
Author: filnik
Date: 2008-12-12 14:27:42 +0000 (Fri, 12 Dec 2008)
Log Message:
-----------
Image -> File
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2008-12-12 13:20:16 UTC (rev 6142)
+++ trunk/pywikipedia/checkimages.py 2008-12-12 14:27:42 UTC (rev 6143)
@@ -32,7 +32,7 @@
-skip[:#] - The bot skip the first [:#] images (default: 0)
- -start[:#] - Use allpages() as generator (it starts already form Image:[:#])
+ -start[:#] - Use allpages() as generator (it starts already form File:[:#])
-cat[:#] - Use a category as generator
@@ -189,14 +189,14 @@
# Text that will be add if the bot find a unknown extension.
delete_immediately_notification = {
- 'ar' :u'الملف [[:Image:%s]] يبدو أن امتداده خاطيء, من فضلك تحقق. ~~~~',
- 'commons':u'The [[:Image:%s]] file seems to have a wrong extension, please check. ~~~~',
- 'en' :u'The [[:Image:%s]] file seems to have a wrong extension, please check. ~~~~',
+ 'ar' :u'الملف [[:File:%s]] يبدو أن امتداده خاطيء, من فضلك تحقق. ~~~~',
+ 'commons':u'The [[:File:%s]] file seems to have a wrong extension, please check. ~~~~',
+ 'en' :u'The [[:File:%s]] file seems to have a wrong extension, please check. ~~~~',
'hu' :u'A [[:Kép:%s]] fájlnak rossz a kiterjesztése, kérlek ellenőrízd. ~~~~',
'it' :u'{{subst:Progetto:Coordinamento/Immagini/Bot/Messaggi/Ext|%s|__botnick__}} --~~~~',
'ko' :u'[[:그림:%s]]의 파일 형식이 잘못되었습니다. 확인 바랍니다.--~~~~',
'ta' :u'[[:படிமம்:%s]] இனங்காணப்படாத கோப்பு நீட்சியை கொண்டுள்ளது தயவு செய்து ஒரு முறை சரி பார்க்கவும் ~~~~',
- 'zh' :u'您好,你上傳的[[:Image:%s]]無法被識別,請檢查您的檔案,謝謝。--~~~~',
+ 'zh' :u'您好,你上傳的[[:File:%s]]無法被識別,請檢查您的檔案,謝謝。--~~~~',
}
# Summary of the delate immediately. (f.e: Adding {{db-meta|The file has .%s as extension.}})
del_comm = {
@@ -228,17 +228,17 @@
# That's the text that the bot will add if it doesn't find the license.
# Note: every __botnick__ will be repleaced with your bot's nickname (feel free not to use if you don't need it)
nothing_notification = {
- 'commons':u"\n{{subst:User:Filnik/untagged|Image:%s}}\n\n''This message was '''added automatically by [[User:" + \
+ 'commons':u"\n{{subst:User:Filnik/untagged|File:%s}}\n\n''This message was '''added automatically by [[User:" + \
"__botnick__|__botnick__]]''', if you need some help about it, ask its master (~~~) or go to the [[Commons:Help desk]]''. --~~~~",
- 'ar' :u"{{subst:مصدر الصورة|Image:%s}} --~~~~",
+ 'ar' :u"{{subst:مصدر الصورة|File:%s}} --~~~~",
'de' :u'\n{{subst:Benutzer:ABF/D2|%s}} ~~~~ ',
- 'en' :u"{{subst:image source|Image:%s}} --~~~~",
+ 'en' :u"{{subst:image source|File:%s}} --~~~~",
'hu' :u"{{subst:adjforrást|Kép:%s}} \n Ezt az üzenetet ~~~ automatikusan helyezte el a vitalapodon, kérdéseddel fordulj a gazdájához, vagy a [[WP:KF|Kocsmafalhoz]]. --~~~~",
'it' :u"{{subst:Progetto:Coordinamento/Immagini/Bot/Messaggi/Senza licenza|%s|__botnick__}} --~~~~",
- 'ja' :u"\n{{subst:Image copyright|Image:%s}}--~~~~",
+ 'ja' :u"\n{{subst:Image copyright|File:%s}}--~~~~",
'ko' :u'\n{{subst:User:Kwjbot IV/untagged|%s}} --~~~~',
'ta' :u'\n{{subst:Di-no license-notice|படிமம்:%s}} ~~~~ ',
- 'zh' :u'\n{{subst:Uploadvionotice|Image:%s}} ~~~~ ',
+ 'zh' :u'\n{{subst:Uploadvionotice|File:%s}} ~~~~ ',
}
# This is a list of what bots used this script in your project.
@@ -294,16 +294,16 @@
timeselected = u' ~~~~~'
# The text added in the report
report_text = {
- 'commons':u"\n*[[:Image:%s]] " + timeselected,
+ 'commons':u"\n*[[:File:%s]] " + timeselected,
'ar':u"\n*[[:صورة:%s]] " + timeselected,
'de':u"\n*[[:Bild:%s]] " + timeselected,
- 'en':u"\n*[[:Image:%s]] " + timeselected,
+ 'en':u"\n*[[:File:%s]] " + timeselected,
'hu':u"\n*[[:Kép:%s]] " + timeselected,
'it':u"\n*[[:Immagine:%s]] " + timeselected,
'ja':u"\n*[[:Immagine:%s]] " + timeselected,
'ko':u"\n*[[:그림:%s]] " + timeselected,
'ta':u"\n*[[:படிமம்:%s]] " + timeselected,
- 'zh':u"\n*[[:Image:%s]] " + timeselected,
+ 'zh':u"\n*[[:File:%s]] " + timeselected,
}
# The summary of the report
comm10 = {
@@ -356,7 +356,7 @@
# Template added when the bot finds only an hidden template and nothing else.
# Note: every __botnick__ will be repleaced with your bot's nickname (feel free not to use if you don't need it)
HiddenTemplateNotification = {
- 'commons': u"""\n{{subst:User:Filnik/whitetemplate|Image:%s}}\n\n''This message was '''added automatically by [[User:__botnick__|__botnick__]]''', if you need some help about it, ask its master (~~~) or go to the [[Commons:Help desk]]''. --~~~~""",
+ 'commons': u"""\n{{subst:User:Filnik/whitetemplate|File:%s}}\n\n''This message was '''added automatically by [[User:__botnick__|__botnick__]]''', if you need some help about it, ask its master (~~~) or go to the [[Commons:Help desk]]''. --~~~~""",
'de' : None,
'en' : None,
'it' : u"{{subst:Progetto:Coordinamento/Immagini/Bot/Messaggi/Template_insufficiente|%s|__botnick__}} --~~~~",
@@ -381,7 +381,7 @@
}
# Message to put in the talk
duplicates_user_talk_text = {
- 'commons': u'{{subst:User:Filnik/duplicates|Image:%s|Image:%s}}', # FIXME: it doesn't exist
+ 'commons': u'{{subst:User:Filnik/duplicates|File:%s|File:%s}}', # FIXME: it doesn't exist
'en' : None,
'it' : u"{{subst:Progetto:Coordinamento/Immagini/Bot/Messaggi/Duplicati|%s|%s|__botnick__}} --~~~~",
}
@@ -579,8 +579,7 @@
self.sendemailActive = sendemailActive
self.skip_list = list() # Inizialize the skip list used below
self.duplicatesReport = duplicatesReport
- image_n = self.site.image_namespace()
- self.image_namespace = u"%s:" % image_n # Example: "Image:"
+ self.image_namespace = u"File:"
# Load the licenses only once, so do it once
self.list_licenses = self.load_licenses()
def setParameters(self, imageName, timestamp, uploader):
@@ -672,7 +671,7 @@
nick = reportPageObject.getLatestUploader()[0]
except wikipedia.NoPage:
wikipedia.output(u"Seems that %s hasn't the image at all, but there is something in the description..." % self.image_to_report)
- repme = u"\n*[[:Image:%s]] problems '''with the APIs'''"
+ repme = u"\n*[[:File:%s]] problems '''with the APIs'''"
# We have a problem! Report and exit!
self.report_image(self.image_to_report, self.rep_page, self.com, repme)
return False
@@ -808,7 +807,7 @@
max_usage = 0
for element in listGiven:
imageName = element[1]
- imagePage = wikipedia.ImagePage(self.site, u'Image:%s' % imageName)
+ imagePage = wikipedia.ImagePage(self.site, u'File:%s' % imageName)
imageUsage = [page for page in imagePage.usingPages()]
if len(imageUsage) > 0 and len(imageUsage) > max_usage:
max_usage = len(imageUsage)
@@ -853,16 +852,16 @@
""" Checking if the image is on commons """
wikipedia.output(u'Checking if %s is on commons...' % self.imageName)
commons_site = wikipedia.getSite('commons', 'commons')
- regexOnCommons = r"\n\*\[\[:Image:%s\]\] is also on '''Commons''': \[\[commons:Image:.*?\]\](?: \(same name\)|)$" % re.escape(self.imageName)
- imagePage = wikipedia.ImagePage(self.site, u'Image:%s' % self.imageName)
+ regexOnCommons = r"\n\*\[\[:File:%s\]\] is also on '''Commons''': \[\[commons:File:.*?\]\](?: \(same name\)|)$" % re.escape(self.imageName)
+ imagePage = wikipedia.ImagePage(self.site, u'File:%s' % self.imageName)
hash_found = imagePage.getHash()
if hash_found == None:
return False # Problems? Yes! Image deleted, no hash found. Skip the image.
else:
- commons_image_with_this_hash = commons_site.getImagesFromAnHash(hash_found)
+ commons_image_with_this_hash = commons_site.getFilesFromAnHash(hash_found)
if commons_image_with_this_hash != []:
wikipedia.output(u'%s is on commons!' % self.imageName)
- imagePage = wikipedia.ImagePage(self.site, u'Image:%s' % self.imageName)
+ imagePage = wikipedia.ImagePage(self.site, u'File:%s' % self.imageName)
on_commons_text = imagePage.getImagePageHtml()
if u"<div class='sharedUploadNotice'>" in on_commons_text:
wikipedia.output(u"But, the image doesn't exist on your project! Skip...")
@@ -875,9 +874,9 @@
else:
# the second usually is a url or something like that. Compare the two in equal way, both url.
if self.convert_to_url(self.imageName) == self.convert_to_url(commons_image_with_this_hash[0]):
- repme = u"\n*[[:Image:%s]] is also on '''Commons''': [[commons:Image:%s]] (same name)" % (self.imageName, commons_image_with_this_hash[0])
+ repme = u"\n*[[:File:%s]] is also on '''Commons''': [[commons:File:%s]] (same name)" % (self.imageName, commons_image_with_this_hash[0])
else:
- repme = u"\n*[[:Image:%s]] is also on '''Commons''': [[commons:Image:%s]]" % (self.imageName, commons_image_with_this_hash[0])
+ repme = u"\n*[[:File:%s]] is also on '''Commons''': [[commons:File:%s]]" % (self.imageName, commons_image_with_this_hash[0])
self.report_image(self.imageName, self.rep_page, self.com, repme, addings = False, regex = regexOnCommons)
# Problems? No, return True
return True
@@ -887,7 +886,7 @@
def checkImageDuplicated(self, duplicates_rollback):
""" Function to check the duplicated images. """
- # {{Dupe|Image:Blanche_Montel.jpg}}
+ # {{Dupe|File:Blanche_Montel.jpg}}
# Skip the stub images
#if 'stub' in self.imageName.lower() and self.project == 'wikipedia' and self.site.lang == 'it':
# return True # Skip the stub, ok
@@ -897,10 +896,10 @@
dupTalkText = wikipedia.translate(self.site, duplicates_user_talk_text)
dupComment_talk = wikipedia.translate(self.site, duplicates_comment_talk)
dupComment_image = wikipedia.translate(self.site, duplicates_comment_image)
- duplicateRegex = r'\n\*(?:\[\[:Image:%s\]\] has the following duplicates(?: \(\'\'\'forced mode\'\'\'\)|):|\*\[\[:Image:%s\]\])$' % (self.convert_to_url(self.imageName), self.convert_to_url(self.imageName))
- imagePage = wikipedia.ImagePage(self.site, u'Image:%s' % self.imageName)
+ duplicateRegex = r'\n\*(?:\[\[:File:%s\]\] has the following duplicates(?: \(\'\'\'forced mode\'\'\'\)|):|\*\[\[:File:%s\]\])$' % (self.convert_to_url(self.imageName), self.convert_to_url(self.imageName))
+ imagePage = wikipedia.ImagePage(self.site, u'File:%s' % self.imageName)
hash_found = imagePage.getHash()
- duplicates = self.site.getImagesFromAnHash(hash_found)
+ duplicates = self.site.getFilesFromAnHash(hash_found)
if duplicates == None:
return False # Error, image deleted, no hash found. Skip the image.
if len(duplicates) > 1:
@@ -912,8 +911,8 @@
time_image_list = list()
time_list = list()
for duplicate in duplicates:
- DupePage = wikipedia.ImagePage(self.site, u'Image:%s' % duplicate)
- if DupePage == self.image and self.timestamp != None:
+ DupePage = wikipedia.ImagePage(self.site, u'File:%s' % duplicate)
+ if DupePage.urlname() == self.image.urlname() and self.timestamp != None:
imagedata = self.timestamp
else:
imagedata = DupePage.getLatestUploader()[1]
@@ -924,14 +923,14 @@
time_list.append(data_seconds)
older_image = self.returnOlderTime(time_image_list, time_list)
# And if the images are more than two?
- Page_oder_image = wikipedia.ImagePage(self.site, u'Image:%s' % older_image)
+ Page_oder_image = wikipedia.ImagePage(self.site, u'File:%s' % older_image)
string = ''
images_to_tag_list = []
for duplicate in duplicates:
if wikipedia.ImagePage(self.site, u'%s:%s' % (self.image_namespace, duplicate)) == \
wikipedia.ImagePage(self.site, u'%s:%s' % (self.image_namespace, older_image)):
continue # the older image, not report also this as duplicate
- DupePage = wikipedia.ImagePage(self.site, u'Image:%s' % duplicate)
+ DupePage = wikipedia.ImagePage(self.site, u'File:%s' % duplicate)
try:
DupPageText = DupePage.get()
older_page_text = Page_oder_image.get()
@@ -958,7 +957,7 @@
# Two iteration: report the "problem" to the user only once (the last)
if len(images_to_tag_list) > 1:
for image_to_tag in images_to_tag_list[:-1]:
- already_reported_in_past = self.countEdits(u'Image:%s' % image_to_tag, self.botolist)
+ already_reported_in_past = self.countEdits(u'File:%s' % image_to_tag, self.botolist)
# if you want only one edit, the edit found should be more than 0 -> num - 1
if already_reported_in_past > duplicates_rollback - 1:
only_report = True
@@ -968,7 +967,7 @@
self.report(text_for_the_report, image_to_tag,
commImage = dupComment_image, unver = True)
if len(images_to_tag_list) != 0 and not only_report:
- already_reported_in_past = self.countEdits(u'Image:%s' % images_to_tag_list[-1], self.botolist)
+ already_reported_in_past = self.countEdits(u'File:%s' % images_to_tag_list[-1], self.botolist)
image_to_resub = images_to_tag_list[-1]
from_regex = r'\n\*\[\[:%s\]\]' % re.escape(self.image_namespace + image_to_resub)
# Delete the image in the list where we're write on
@@ -982,13 +981,13 @@
commImage = dupComment_image, unver = True)
if self.duplicatesReport or only_report:
if only_report:
- repme = u"\n*[[:Image:%s]] has the following duplicates ('''forced mode'''):" % self.convert_to_url(self.imageName)
+ repme = u"\n*[[:File:%s]] has the following duplicates ('''forced mode'''):" % self.image.urlname()
else:
- repme = u"\n*[[:Image:%s]] has the following duplicates:" % self.convert_to_url(self.imageName)
+ repme = u"\n*[[:File:%s]] has the following duplicates:" % self.convert_to_url(self.imageName)
for duplicate in duplicates:
if self.convert_to_url(duplicate) == self.convert_to_url(self.imageName):
continue # the image itself, not report also this as duplicate
- repme += u"\n**[[:Image:%s]]" % self.convert_to_url(duplicate)
+ repme += u"\n**[[:File:%s]]" % self.convert_to_url(duplicate)
result = self.report_image(self.imageName, self.rep_page, self.com, repme, addings = False, regex = duplicateRegex)
if not result:
return True # If Errors, exit (but continue the check)
@@ -1185,9 +1184,9 @@
if self.allLicenses != list():
self.license_found = self.allLicenses[0].title()
if not self.seems_ok and self.license_found != None:
- rep_text_license_fake = u"\n*[[:Image:%s]] seems to have " % self.imageName + \
+ rep_text_license_fake = u"\n*[[:File:%s]] seems to have " % self.imageName + \
"a ''fake license'', license detected: <nowiki>%s</nowiki>" % self.license_found
- regexFakeLicense = r"\* ?\[\[:Image:%s\]\] seems to have " % (re.escape(self.imageName)) + \
+ regexFakeLicense = r"\* ?\[\[:File:%s\]\] seems to have " % (re.escape(self.imageName)) + \
"a ''fake license'', license detected: <nowiki>%s</nowiki>$" % (re.escape(self.license_found))
printWithTimeZone(u"%s seems to have a fake license: %s, reporting..." % (self.imageName, self.license_found))
self.report_image(self.imageName, rep_text = rep_text_license_fake,
@@ -1221,9 +1220,9 @@
# Print a starting message only if no images has been skipped
if self.skip_list == []:
if skip_number == 1:
- wikipedia.output(u'Skipping the first image:\n')
+ wikipedia.output(u'Skipping the first file:\n')
else:
- wikipedia.output(u'Skipping the first %s images:\n' % skip_number)
+ wikipedia.output(u'Skipping the first %s files:\n' % skip_number)
# If we still have pages to skip:
if len(self.skip_list) < skip_number:
wikipedia.output(u'Skipping %s...' % self.imageName)
@@ -1595,8 +1594,7 @@
site = wikipedia.getSite()
# Block of text to translate the parameters set above.
- image_n = site.image_namespace()
- image_namespace = u"%s:" % image_n # Example: "User_talk:"
+ image_namespace = u"File:"
# If the images to skip are 0, set the skip variable to False (the same for the wait time)
if skip_number == 0:
@@ -1661,7 +1659,7 @@
# If the generator returns something that is not an image, simply skip it.
if normal == False and regexGen == False:
if image_namespace.lower() not in image.title().lower() and \
- 'image:' not in image.title().lower():
+ 'file:' not in image.title().lower():
wikipedia.output(u'%s seems not an image, skip it...' % image.title())
continue
if normal: