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

Change subject: plugin: s/clear_entity_label/set_entity_label/
......................................................................


plugin: s/clear_entity_label/set_entity_label/

Clearing an entity label is setting it with an empty string.

Change-Id: I36aeacb17965e2ac6b393482e13439903358a19f
Signed-off-by: Loic Dachary <l...@dachary.org>
---
M FLOSSbot/plugin.py
1 file changed, 8 insertions(+), 3 deletions(-)

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



diff --git a/FLOSSbot/plugin.py b/FLOSSbot/plugin.py
index 7c6dcc1..0be598c 100644
--- a/FLOSSbot/plugin.py
+++ b/FLOSSbot/plugin.py
@@ -172,15 +172,18 @@
         self.bot.site.editEntity({'new': type}, entity)
 
     def clear_entity_label(self, id):
+        self.set_entity_label(id, '')
+
+    def set_entity_label(self, id, label):
         data = {
             "labels": {
                 "en": {
                     "language": "en",
-                    "value": "",
+                    "value": label,
                 }
             }
         }
-        log.debug("clear " + id + " label")
+        log.debug("set " + id + " label to '" + label + "'")
         self.bot.site.editEntity({'id': id}, data)
         while True:
             if id.startswith('P'):
@@ -188,7 +191,9 @@
             else:
                 entity = pywikibot.ItemPage(self.bot.site, id, 0)
             entity.get(force=True)
-            if entity.labels.get('en') is None:
+            if label == '' and entity.labels.get('en') is None:
+                break
+            if label != '' and label == entity.labels.get('en'):
                 break
         self.reset_cache()
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I36aeacb17965e2ac6b393482e13439903358a19f
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/bots/FLOSSbot
Gerrit-Branch: master
Gerrit-Owner: Dachary <l...@dachary.org>
Gerrit-Reviewer: Dachary <l...@dachary.org>
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