jenkins-bot has submitted this change and it was merged.

Change subject: Minor code improvements:
......................................................................


Minor code improvements:

- use brackets for print statements for py3 compatibility
- use range instead of xrange for py3 compatibility
- None comparison should be done with "is" or "is not"
- use core-like Page.text and Page.save() instead of Page.get()
  and Page.put()

Change-Id: I5121135024c8fc89dc50a4e969adef5d861c5e6f
---
M scripts/casechecker.py
1 file changed, 12 insertions(+), 12 deletions(-)

Approvals:
  Ladsgroup: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/casechecker.py b/scripts/casechecker.py
index afaf2a2..b0d6043 100644
--- a/scripts/casechecker.py
+++ b/scripts/casechecker.py
@@ -69,11 +69,11 @@
             pass
 
     if color == FOREGROUND_BLUE:
-        print '(b:',
+        print('(b:'),
     if color == FOREGROUND_GREEN:
-        print '(g:',
+        print('(g:'),
     if color == FOREGROUND_RED:
-        print '(r:',
+        print('(r:'),
 
 # end of console code
 
@@ -329,20 +329,20 @@
 
             if not self.doFailed:
                 for namespace in self.namespaces:
-                    self.currentTitle = None
+                    self.currentTitle is None
                     self.queryParams['gapnamespace'] = namespace
                     self.queryParams['gapfrom'] = self.apfrom
                     for data in self.RunQuery(self.queryParams):
                         self.ProcessDataBlock(data)
             else:
-                self.currentTitle = None
+                self.currentTitle is None
                 batchSize = 10
-                for batchStart in xrange(0, len(self.titleList), batchSize):
+                for batchStart in range(0, len(self.titleList), batchSize):
                     self.queryParams['titles'] = self.titleList[
                         batchStart:batchStart + batchSize]
                     for data in self.RunQuery(self.queryParams):
                         self.ProcessDataBlock(data)
-            print "*" * 29, "Done"
+            print("*" * 29 + " Done")
         except:
             pywikibot.output(u'Exception at Title = %s, Next = %s'
                              % (self.currentTitle, self.apfrom))
@@ -400,7 +400,7 @@
                                         follow_redirects=False):
                                     if p.namespace() == 2:
                                         continue
-                                    oldText = p.get(get_redirect=True)
+                                    oldText = p.text
                                     newText = self.ReplaceLink(oldText, title,
                                                                newTitle)
                                     if not self.PutNewPage(
@@ -758,14 +758,14 @@
     def PutNewPage(self, pageObj, pageTxt, msg):
         title = pageObj.title(asLink=True, textlink=True)
         coloredMsg = u', '.join([self.ColorCodeWord(m) for m in msg])
-        if pageObj.get(get_redirect=True) == pageTxt:
+        if pageObj.text == pageTxt:
             self.WikiLog(u"* Error: Text replacement failed in %s (%s)"
                          % (self.MakeLink(title, False), coloredMsg))
         else:
             pywikibot.output(u'Case Replacements: %s' % u', '.join(msg))
+            pageObj.text = pageTxt
             try:
-                pageObj.put(
-                    pageTxt,
+                pageObj.save(
                     u'%s: %s'
                     % (i18n.twtranslate(
                         self.site,
@@ -774,7 +774,7 @@
                 return True
             except KeyboardInterrupt:
                 raise
-            except:
+            except (pywikibot.LockedPage, pywikibot.PageNotSaved):
                 self.WikiLog(u"* Error: Could not save updated page %s (%s)"
                              % (self.MakeLink(title, False), coloredMsg))
         return False

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5121135024c8fc89dc50a4e969adef5d861c5e6f
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Ricordisamoa <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to