jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1093371?usp=email )

Change subject: [IMPR] use search_entities method in get_item_list function
......................................................................

[IMPR] use search_entities method in get_item_list function

Change-Id: I7d033572a0595b73bd8f0f5892a939a2c13e46e9
---
M scripts/create_isbn_edition.py
1 file changed, 2 insertions(+), 22 deletions(-)

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




diff --git a/scripts/create_isbn_edition.py b/scripts/create_isbn_edition.py
index d803761..c566fbc 100755
--- a/scripts/create_isbn_edition.py
+++ b/scripts/create_isbn_edition.py
@@ -781,32 +781,12 @@
     :param instance_id: Instance ID
     :return: Set of items
     """
-    pywikibot.debug(f'Search label: {item_name.encode("utf-8")}')
-    # TODO: try to use search_entities instead?
-    params = {
-        'action': 'wbsearchentities',
-        'format': 'json',
-        'type': 'item',
-        # All languages are searched, but labels are in native language
-        'strictlanguage': False,
-        'language': mainlang,
-        'uselang': mainlang,  # (primary) Search language
-        'search': item_name,  # Get item list from label
-        'limit': 20,  # Should be reasonable value
-    }
-    request = api.Request(site=repo, parameters=params)
-    result = request.submit()
-    pywikibot.debug(result)
-
-    if 'search' not in result:
-        return set()
-
     # Ignore accents and case
     item_name_canon = unidecode(item_name).casefold()

     item_list = set()
-    # Loop though items
-    for res in result['search']:
+    # Loop though items, total should be reasonable value
+    for res in repo.search_entities(item_name, mainlang, total=20):
         item = get_item_page(res['id'])

         # Matching instance

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1093371?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I7d033572a0595b73bd8f0f5892a939a2c13e46e9
Gerrit-Change-Number: 1093371
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Geertivp <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to