http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10981
Revision: 10981
Author: xqt
Date: 2013-01-25 10:48:44 +0000 (Fri, 25 Jan 2013)
Log Message:
-----------
bugfix for r10980: use pagegenerators for retrieving the page and leave behind the other parts returnes by site method
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2013-01-25 10:18:41 UTC (rev 10980)
+++ trunk/pywikipedia/checkimages.py 2013-01-25 10:48:44 UTC (rev 10981)
@@ -607,15 +607,15 @@
# Load the licenses only once, so do it once
self.list_licenses = self.load_licenses()
- def setParameters(self, imageName, timestamp, uploader):
+ def setParameters(self, imageName):
""" Function to set parameters, now only image but maybe it can be used
for others in "future"
"""
self.imageName = imageName
self.image = pywikibot.ImagePage(self.site, self.imageName)
- self.timestamp = timestamp
- self.uploader = uploader
+ self.timestamp = None
+ self.uploader = None
def report(self, newtext, image_to_report, notification=None, head=None,
notification2=None, unver=True, commTalk=None, commImage=None):
@@ -1756,6 +1756,7 @@
duplicatesReport = False # Use the duplicate-report option
sendemailActive = False # Use the send-email
logFullError = True # Raise an error when the log is full
+ generator = None
# Here below there are the parameters.
for arg in pywikibot.handleArgs():
@@ -1865,10 +1866,7 @@
elif len(arg) > 9:
projectUntagged = str(arg[10:])
- # Understand if the generator it's the default or not.
- try:
- generator
- except NameError:
+ if not generator:
normal = True
# Define the site.
@@ -1905,7 +1903,7 @@
normal = False # Ensure that normal is False
# Normal True? Take the default generator
if normal:
- generator = site.newimages(number = limit)
+ generator = pg.NewimagesPageGenerator(number=limit, site=site)
# if urlUsed and regexGen, get the source for the generator
if urlUsed and regexGen:
textRegex = site.getUrl(regexPageUrl, no_hostname=True)
@@ -1930,30 +1928,8 @@
generator = Bot.wait(waitTime, generator, normal, limit)
generator = pg.NamespaceFilterPageGenerator(generator, 6, site)
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
- #
- #if image.title() != u'File:Nytlogo379x64.gif' and not parsed:
- # pywikibot.output(u"%s already parsed." % image.title())
- # continue
- #else:
- # parsed = True
- if normal:
- imageData = image
- image = imageData[0]
- #20100511133318L --- 15:33, 11 mag 2010 e 18 sec
- #b = str(imageData[1]) # use b as variable to make smaller the timestamp-formula used below..
- # fixing the timestamp to the format that we normally use..
- timestamp = imageData[1]#"%s-%s-%sT%s:%s:%sZ" % (b[0:4], b[4:6], b[6:8], b[8:10], b[10:12], b[12:14])
- uploader = imageData[2]
- comment = imageData[3] # useless, in reality..
- else:
- timestamp = None
- uploader = None
- comment = None # useless, also this, let it here for further developments
# Setting the image for the main class
- Bot.setParameters(image.title(withNamespace=False),
- timestamp, uploader)
+ Bot.setParameters(image.title(withNamespace=False))
# Skip block
if skip:
skip = Bot.skipImages(skip_number, limit)
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10980
Revision: 10980
Author: xqt
Date: 2013-01-25 10:18:41 +0000 (Fri, 25 Jan 2013)
Log Message:
-----------
some code improvements
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2013-01-24 14:51:11 UTC (rev 10979)
+++ trunk/pywikipedia/checkimages.py 2013-01-25 10:18:41 UTC (rev 10980)
@@ -1874,10 +1874,6 @@
# Define the site.
site = pywikibot.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
@@ -1932,6 +1928,7 @@
if wait:
# Let's sleep...
generator = Bot.wait(waitTime, generator, normal, limit)
+ generator = pg.NamespaceFilterPageGenerator(generator, 6, site)
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
@@ -1941,14 +1938,6 @@
# continue
#else:
# parsed = True
- # If the generator returns something that is not an image, simply skip it.
- if not (normal or regexGen):
- if image_namespace.lower() not in image.title().lower() and \
- image_old_namespace.lower() not in image.title().lower() \
- and 'file:' not in image.title().lower():
- pywikibot.output(u'%s seems not an file, skip it...'
- % image.title())
- continue
if normal:
imageData = image
image = imageData[0]
@@ -1962,16 +1951,9 @@
timestamp = None
uploader = None
comment = None # useless, also this, let it here for further developments
- 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...
- try:
- imageName = image.title().split(image_old_namespace)[1]
- except IndexError:
- pywikibot.output(u"%s is not a file, skipping..."
- % image.title())
- continue
- Bot.setParameters(imageName, timestamp, uploader) # Setting the image for the main class
+ # Setting the image for the main class
+ Bot.setParameters(image.title(withNamespace=False),
+ timestamp, uploader)
# Skip block
if skip:
skip = Bot.skipImages(skip_number, limit)
@@ -1985,8 +1967,7 @@
if duplicatesActive:
if not Bot.checkImageDuplicated(duplicates_rollback):
continue
- resultCheck = Bot.checkStep()
- if resultCheck:
+ if Bot.checkStep():
continue
# A little block to perform the repeat or to break.
if repeat:
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10979
Revision: 10979
Author: xqt
Date: 2013-01-24 14:51:11 +0000 (Thu, 24 Jan 2013)
Log Message:
-----------
syntax bugfix
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2013-01-24 12:17:00 UTC (rev 10978)
+++ trunk/pywikipedia/checkimages.py 2013-01-24 14:51:11 UTC (rev 10979)
@@ -1983,7 +1983,7 @@
continue
# Check if there are duplicates of the image on the project selected
if duplicatesActive:
- if not Bot.checkImageDuplicated(duplicates_rollback)
+ if not Bot.checkImageDuplicated(duplicates_rollback):
continue
resultCheck = Bot.checkStep()
if resultCheck:
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10976
Revision: 10976
Author: multichill
Date: 2013-01-23 21:32:04 +0000 (Wed, 23 Jan 2013)
Log Message:
-----------
def delete now adds a {{speedydelete|1=<reason>|2=bot}} instead of {{delete|bot=yes}}
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2013-01-23 20:54:31 UTC (rev 10975)
+++ trunk/pywikipedia/wikipedia.py 2013-01-23 21:32:04 UTC (rev 10976)
@@ -3465,7 +3465,8 @@
output(u'Cannot delete page %s - marking the page for deletion instead:' % self.title(asLink=True))
# Note: Parameters to {{delete}}, and their meanings, vary from one Wikipedia to another.
# If you want or need to use them, you must be careful not to break others. Else don't.
- self.put(u'{{delete|bot=yes}}\n%s --~~~~\n----\n\n%s' % (reason, text), comment = reason)
+ # FIXME: Make some sort of configuration setting to keep track of the templates in different wiki's
+ self.put(u'{{speedydelete|1=%s --~~~~|bot=yes}}\n\n%s' % (reason, text), comment = reason)
return
else:
raise
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10975
Revision: 10975
Author: drtrigon
Date: 2013-01-23 20:54:31 +0000 (Wed, 23 Jan 2013)
Log Message:
-----------
bug fix; make version.py working with unconfigured repo also (fresh checkout)
Modified Paths:
--------------
trunk/pywikipedia/pywikibot/__init__.py
Modified: trunk/pywikipedia/pywikibot/__init__.py
===================================================================
--- trunk/pywikipedia/pywikibot/__init__.py 2013-01-23 16:32:00 UTC (rev 10974)
+++ trunk/pywikipedia/pywikibot/__init__.py 2013-01-23 20:54:31 UTC (rev 10975)
@@ -1,4 +1,8 @@
# wikipedia.py will monkey-patch this module to look completely
# alike wikipedia itself...
-import wikipedia
+try:
+ import wikipedia
+except Exception, e:
+ print e
+ print u'Serious import error; pywikibot not available - was it configured?'
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10972
Revision: 10972
Author: xqt
Date: 2013-01-23 15:18:09 +0000 (Wed, 23 Jan 2013)
Log Message:
-----------
some minor edits
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2013-01-23 14:29:39 UTC (rev 10971)
+++ trunk/pywikipedia/checkimages.py 2013-01-23 15:18:09 UTC (rev 10972)
@@ -929,7 +929,7 @@
return False # Image deleted, no hash found. Skip the image.
else:
commons_image_with_this_hash = commons_site.getFilesFromAnHash(hash_found)
- if commons_image_with_this_hash != [] and \
+ if commons_image_with_this_hash and \
commons_image_with_this_hash != 'None':
servTMP = pywikibot.translate(self.site, serviceTemplates,
fallback=False)
@@ -953,7 +953,7 @@
return False
elif re.findall(r'\bstemma\b',
- self.imageName.lower()) != [] and \
+ self.imageName.lower()) and \
self.site.lang == 'it':
pywikibot.output(
u'%s has "stemma" inside, means that it\'s ok.'
@@ -1456,7 +1456,7 @@
return (self.license_found, self.whiteTemplatesFound)
def load(self, raw):
- """ Load a list of object from a string using regex. """
+ """ Load a list of objects from a string using regex. """
list_loaded = []
pos = 0
# I search with a regex how many user have not the talk page
@@ -1629,7 +1629,8 @@
def checkStep(self):
# nothing = Defining an empty image description
- nothing = ['', ' ', ' ', ' ', '\n', '\n ', '\n ', '\n\n', '\n \n', ' \n', ' \n ', ' \n \n']
+ nothing = ['', ' ', ' ', ' ', '\n', '\n ', '\n ', '\n\n', '\n \n',
+ ' \n', ' \n ', ' \n \n']
# something = Minimal requirements for an image description.
# If this fits, no tagging will take place (if there aren't other issues)
# MIT license is ok on italian wikipedia, let also this here
@@ -1978,13 +1979,11 @@
continue
# Check on commons if there's already an image with the same name
if commonsActive and site.family.name != "commons":
- response = Bot.checkImageOnCommons()
- if not response:
+ if not Bot.checkImageOnCommons():
continue
# Check if there are duplicates of the image on the project selected
if duplicatesActive:
- response2 = Bot.checkImageDuplicated(duplicates_rollback)
- if not response2:
+ if not Bot.checkImageDuplicated(duplicates_rollback)
continue
resultCheck = Bot.checkStep()
if resultCheck: