Xqt has uploaded a new change for review.

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

Change subject: [IMPR] use wikistats lib to update languages_by_size
......................................................................

[IMPR] use wikistats lib to update languages_by_size

Change-Id: Iad218316ccd439c38106a1def29c2284c68356f1
---
M scripts/maintenance/wikimedia_sites.py
1 file changed, 9 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/69/270269/1

diff --git a/scripts/maintenance/wikimedia_sites.py 
b/scripts/maintenance/wikimedia_sites.py
index 8f0fcc6..fa096ba 100755
--- a/scripts/maintenance/wikimedia_sites.py
+++ b/scripts/maintenance/wikimedia_sites.py
@@ -2,8 +2,8 @@
 # -*- coding: utf-8  -*-
 """Script that updates the language lists in Wikimedia family files."""
 #
-# (C) xqt, 2009-2014
-# (C) Pywikibot team, 2008-2014
+# (C) xqt, 2009-2016
+# (C) Pywikibot team, 2008-2016
 #
 # Distributed under the terms of the MIT license.
 #
@@ -16,10 +16,9 @@
 import re
 import sys
 
-from xml.etree import cElementTree
-
 import pywikibot
 
+from pywikibot.data import wikistats
 from pywikibot.family import Family
 
 if sys.version_info[0] > 2:
@@ -51,16 +50,12 @@
         original = Family.load(family).languages_by_size
         obsolete = Family.load(family).obsolete
 
-        feed = urlopen(URL % familiesDict[family])
-        tree = cElementTree.parse(feed)
-
         new = []
-        for field in tree.findall('row/field'):
-            if field.get('name') == 'prefix':
-                code = field.text
-                if not (code in obsolete or code in exceptions):
-                    new.append(code)
-                continue
+        ws = wikistats.WikiStats()
+        table = ws.languages_by_size(family)
+        for code in table:
+            if not (code in obsolete or code in exceptions):
+                new.append(code)
 
         # put the missing languages to the right place
         missing = original != new and set(original) - set(new)
@@ -104,7 +99,7 @@
 
 if __name__ == '__main__':
     fam = []
-    for arg in pywikibot.handleArgs():
+    for arg in pywikibot.handle_args():
         if arg in familiesDict.keys() and arg not in fam:
             fam.append(arg)
     update_family(fam)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad218316ccd439c38106a1def29c2284c68356f1
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>

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

Reply via email to