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

Change subject: code cleanups
......................................................................


code cleanups

- rename a to source to indicate it's usage
- use Page.text instead of Page.get()
- use line separator from config

Change-Id: Ibfd7d06a38d880b2ced1f72ef4f2bd9f7b0c5d0d
---
M scripts/featured.py
1 file changed, 14 insertions(+), 13 deletions(-)

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



diff --git a/scripts/featured.py b/scripts/featured.py
index 692062d..39a6a2e 100644
--- a/scripts/featured.py
+++ b/scripts/featured.py
@@ -67,6 +67,7 @@
 import pywikibot
 from pywikibot import i18n
 from pywikibot.pagegenerators import PreloadingGenerator
+from pywikibot.config2 import LS  # line separator
 
 
 def CAT(site, name, hide):
@@ -525,20 +526,20 @@
         re_Link_add = compile_link(fromsite, add_tl)
         re_Link_remove = compile_link(fromsite, remove_tl)
         interactive = self.getOption('interactive')
-        for a in gen:
-            if a.isRedirectPage():
-                a = a.getRedirectTarget()
+        for source in gen:
+            if source.isRedirectPage():
+                source = source.getRedirectTarget()
 
-            if not a.exists():
+            if not source.exists():
                 pywikibot.output(u"source page doesn't exist: %s"
-                                 % a.title())
+                                 % source.title())
                 continue
 
-            atrans = self.findTranslated(a, tosite)
+            atrans = self.findTranslated(source, tosite)
             if not atrans:
                 continue
 
-            text = atrans.get()
+            text = atrans.text
             m1 = add_tl and re_Link_add.search(text)
             m2 = remove_tl and re_Link_remove.search(text)
             changed = False
@@ -550,7 +551,7 @@
                     if (not interactive or
                         pywikibot.input(
                             u'Connecting %s -> %s. Proceed? [Y/N]'
-                            % (a.title(), atrans.title())) in ['Y', 'y']):
+                            % (source.title(), atrans.title())) in ['Y', 'y']):
                         if self.getOption('side'):
                             # Placing {{Link FA|xx}} right next to
                             # corresponding interwiki
@@ -561,8 +562,8 @@
                             # Moving {{Link FA|xx}} to top of interwikis
                             iw = pywikibot.getLanguageLinks(text, self.site)
                             text = pywikibot.removeLanguageLinks(text, 
self.site)
-                            text += u"\r\n{{%s|%s}}\r\n" % (add_tl[0],
-                                                            fromsite.code)
+                            text += u"%s{{%s|%s}}%s" % (LS, add_tl[0],
+                                                        fromsite.code, LS)
                             text = pywikibot.replaceLanguageLinks(text,
                                                                   iw, 
self.site)
                         changed = True
@@ -572,15 +573,15 @@
                         not interactive or
                         pywikibot.input(
                             u'Connecting %s -> %s. Proceed? [Y/N]'
-                            % (a.title(), atrans.title())) in ['Y', 'y']):
+                            % (source.title(), atrans.title())) in ['Y', 'y']):
                         text = re.sub(re_Link_remove, '', text)
                         changed = True
                 elif task == 'former':
                     pywikibot.output(u"(already removed)")
-            cc[a.title()] = atrans.title()
+            cc[source.title()] = atrans.title()
             if changed:
                 comment = i18n.twtranslate(self.site, 'featured-' + task,
-                                           {'page': unicode(a)})
+                                           {'page': unicode(source)})
                 try:
                     atrans.put(text, comment)
                 except pywikibot.LockedPage:

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibfd7d06a38d880b2ced1f72ef4f2bd9f7b0c5d0d
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to