OdysseasKr has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/316071

Change subject: Move self.site setting to Bot constructor
......................................................................

Move self.site setting to Bot constructor

The setting of self.site should be done in the constructor of Bot
class

Bug: T146580
Change-Id: Ia81bfe8a35997e829584cd931b0f0e2b489e1207
---
M scripts/image.py
1 file changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/71/316071/1

diff --git a/scripts/image.py b/scripts/image.py
index ff8517c..55af935 100755
--- a/scripts/image.py
+++ b/scripts/image.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+       #!/usr/bin/python
 # -*- coding: utf-8 -*-
 """
 This script can be used to change one image to another or remove an image.
@@ -58,7 +58,7 @@
 
     """This bot will replace or remove all occurrences of an old image."""
 
-    def __init__(self, generator, site, old_image, new_image=None, **kwargs):
+    def __init__(self, generator, old_image, new_image=None, **kwargs):
         """
         Constructor.
 
@@ -77,7 +77,6 @@
 
         Bot.__init__(self, generator=generator, **kwargs)
 
-       self.site = site
         self.old_image = old_image
         self.new_image = new_image
         param = {
@@ -121,6 +120,7 @@
 
         super(ImageRobot, self).__init__(self.generator, replacements,
                                          always=self.getOption('always'),
+                                         site=self.site,
                                          summary=summary)
 
 
@@ -157,8 +157,8 @@
         old_imagepage = pywikibot.FilePage(site, old_image)
         gen = pagegenerators.FileLinksGenerator(old_imagepage)
         preloadingGen = pagegenerators.PreloadingGenerator(gen)
-        bot = ImageRobot(preloadingGen, old_image, new_image, **options)
-       bot.site = pywikibot.Site()
+        bot = ImageRobot(preloadingGen, old_image, new_image,
+            site=site, **options)
         bot.run()
         return True
     else:

-- 
To view, visit https://gerrit.wikimedia.org/r/316071
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia81bfe8a35997e829584cd931b0f0e2b489e1207
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: OdysseasKr <odysseask...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to