Xqt has uploaded a new change for review.

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

Change subject: [FEAT] use page_from_repository() method in several scripts
......................................................................

[FEAT] use page_from_repository() method in several scripts

Change-Id: I0e995bef9a1bc376057d68464c4b3b1d52320177
---
M scripts/archive/featured.py
M scripts/checkimages.py
M scripts/fixing_redirects.py
3 files changed, 12 insertions(+), 35 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/45/281945/1

diff --git a/scripts/archive/featured.py b/scripts/archive/featured.py
index a6a661f..5ae8332 100755
--- a/scripts/archive/featured.py
+++ b/scripts/archive/featured.py
@@ -56,8 +56,8 @@
 #
 # (C) Maxim Razin, 2005
 # (C) Leonardo Gregianin, 2005-2008
-# (C) xqt, 2009-2014
-# (C) Pywikibot team, 2005-2015
+# (C) xqt, 2009-2016
+# (C) Pywikibot team, 2005-2016
 #
 # Distributed under the terms of the MIT license.
 #
@@ -99,12 +99,9 @@
 
 
 def DATA(site, name, hide):
-    dp = pywikibot.ItemPage(site.data_repository(), name)
-    try:
-        title = dp.getSitelink(site)
-    except pywikibot.NoPage:
+    cat = site.page_from_repository(name)
+    if cat is None:
         return
-    cat = pywikibot.Category(site, title)
     if isinstance(hide, dict):
         hide = hide.get(site.code)
     for article in cat.articles(endsort=hide):
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 02e9a0b..69bb8ab 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -462,20 +462,7 @@
 
 # Category with the licenses and / or with subcategories with the other
 # licenses.
-category_with_licenses = {
-    'commons': u'Category:License tags',
-    'ar': u'تصنيف:قوالب حقوق الصور',
-    'de': u'Kategorie:Vorlage:Lizenz für Bilder',
-    'en': u'Category:Wikipedia image copyright templates',
-    'fa': u'رده:الگو:حق تکثیر پرونده',
-    'ga': u'Catagóir:Clibeanna cóipchirt d\'íomhánna',
-    'it': u'Categoria:Template Licenze copyright',
-    'ja': u'Category:画像の著作権表示テンプレート',
-    'ko': u'분류:위키백과 그림 저작권 틀',
-    'ta': u'Category:காப்புரிமை வார்ப்புருக்கள்',
-    'ur': u'زمرہ:ویکیپیڈیا سانچہ جات حقوق تصاویر',
-    'zh': u'Category:版權申告模板',
-}
+category_with_licenses = 'Q4481876'
 
 # Page where is stored the message to send as email to the users
 emailPageWithText = {
@@ -1154,13 +1141,12 @@
 
     def load_licenses(self):
         """Load the list of the licenses."""
-        catName = i18n.translate(self.site, category_with_licenses)
-        if not catName:
+        cat = self.site.page_from_repository(category_with_licenses)
+        if not cat:
             raise pywikibot.Error(
-                u'No licenses allowed provided, add that option to the code to 
'
-                u'make the script working correctly')
+                'No licenses allowed provided. Add that category to wikibase '
+                'make the script working correctly')
         pywikibot.output(u'\nLoading the allowed licenses...\n')
-        cat = pywikibot.Category(self.site, catName)
         list_licenses = list(cat.articles())
         if self.site.code == 'commons':
             no_licenses_to_skip = pywikibot.Category(self.site,
diff --git a/scripts/fixing_redirects.py b/scripts/fixing_redirects.py
index fe02548..45f77af 100755
--- a/scripts/fixing_redirects.py
+++ b/scripts/fixing_redirects.py
@@ -198,15 +198,9 @@
         return
 
     if featured:
-        repo = mysite.data_repository()
-        if repo:
-            dp = pywikibot.ItemPage(repo, featured_articles)
-            try:
-                ref = pywikibot.Category(mysite, dp.getSitelink(mysite))
-            except pywikibot.NoPage:
-                pass
-            else:
-                gen = ref.articles(namespaces=0, content=True)
+        ref = mysite.page_from_repository(featured_articles)
+        if ref is not None:
+            gen = ref.articles(namespaces=0, content=True)
         if not gen:
             suggest_help(
                 unknown_parameters=['-featured'],

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e995bef9a1bc376057d68464c4b3b1d52320177
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <[email protected]>

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

Reply via email to