Author: akkakk_bugzilla
Description:
editLabels and editDescriptions remove labels/descriptions when they are set to "" (empty string). editAliases should do the same when aliases are set to [] (empty list).
Version: core-(2.0)
Severity: normal
Author: akkakk_bugzilla
Description:
editLabels and editDescriptions remove labels/descriptions when they are set to "" (empty string). editAliases should do the same when aliases are set to [] (empty list).
Version: core-(2.0)
Severity: normal
akkakk_bugzilla wrote:
code to (not) reproduce:
#!/usr/bin/python
import pywikibot
site = pywikibot.Site("wikidata", "wikidata")
repo = site.data_repository()
q = "Q292753"
item_obj = pywikibot.ItemPage(repo, q)
content = item_obj.get()
aliases = content['aliases']
aliases['als'] = []
item_obj.editAliases(summary=u"remove redundant aliases", aliases=aliases)
#Q292753 did not change
This is how the wbeditentity API works. wbsetaliases accepts a 'remove' argument that could fit your needs.
https://gerrit.wikimedia.org/r/125575/ automatically fills the aliases list with empty strings to reset them:
item_obj = pywikibot.ItemPage(repo, q)
item_obj.get()
item_obj.aliases['als'] = []
item_obj.editEntity(summary=u"remove redundant aliases")
A similar technique could be implemented in editAliases(), but that would be a breaking change. Or we could provide a 'remove' argument in the function itself.
akkakk_bugzilla wrote:
works with aliases set to [""] instead of just [].
i still think it's confusing, but it works.