Xqt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405533 )

Change subject: Remove filterParents implementation from imagerecat.py
......................................................................

Remove filterParents implementation from imagerecat.py

toolserver filter isn't available anymore.
Prevent unsucessful web call.

Bug: T78462
Change-Id: I41e080bf0eb9facd45b25485509fc5628b038503
---
M scripts/imagerecat.py
1 file changed, 10 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/33/405533/1

diff --git a/scripts/imagerecat.py b/scripts/imagerecat.py
index 225b0bc..ea4c5d2 100755
--- a/scripts/imagerecat.py
+++ b/scripts/imagerecat.py
@@ -27,7 +27,7 @@
 """
 #
 # (C) Multichill, 2008-2011
-# (C) Pywikibot team, 2008-2017
+# (C) Pywikibot team, 2008-2018
 #
 # Distributed under the terms of the MIT license.
 #
@@ -43,6 +43,7 @@
 
 from pywikibot import pagegenerators, textlib
 from pywikibot.comms.http import fetch
+from pywikibot.tools import deprecated
 
 if sys.version_info[0] > 2:
     from urllib.parse import urlencode
@@ -293,12 +294,10 @@
 
 def applyAllFilters(categories):
     """Apply all filters on categories."""
-    result = []
     result = filterDisambiguation(categories)
     result = followRedirects(result)
     result = filterBlacklist(result)
     result = filterCountries(result)
-    result = filterParents(result)
     return result
 
 
@@ -370,29 +369,16 @@
     return list(set(result))
 
 
+@deprecated
 def filterParents(categories):
-    """Remove all parent categories from the set to prevent 
overcategorization."""
-    result = []
-    toFilter = u''
-    for cat in categories:
-        cat = cat.replace('_', ' ')
-        toFilter = toFilter + "[[Category:" + cat + "]]\n"
-    parameters = urlencode({'source': toFilter.encode('utf-8'),
-                            'bot': '1'})
-    filterCategoriesRe = re.compile(r'\[\[Category:([^\]]*)\]\]')
-    try:
-        filterCategoriesPage = fetch(
-            "https://toolserver.org/~multichill/filtercats.php?%s"; % 
parameters)
-        result = filterCategoriesRe.findall(
-            filterCategoriesPage.content)
-    except IOError:
-        # Something is wrong, forget about this filter, and return the input
-        return categories
+    """
+    Remove all parent categories from the set to prevent overcategorization.
 
-    if not result:
-        # Is empty, dont want to remove all categories
-        return categories
-    return result
+    DEPRECATED: Toolserver script isn't available anymore (T78462).
+    This method is kept for compatibility and may be restored sometime by a new
+    implementation.
+    """
+    return categories
 
 
 def saveImagePage(imagepage, newcats, usage, galleries, onlyFilter):

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I41e080bf0eb9facd45b25485509fc5628b038503
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