Wikidata:Requests for permissions/Bot/MDanielsBot
From Wikidata
Jump to navigation
Jump to search
- The following discussion is closed. Please do not modify it. Subsequent comments should be made in a new section. A summary of the conclusions reached follows.
Approved--Ymblanter (talk) 19:00, 29 May 2023 (UTC)[reply]
MDanielsBot (talk • contribs • new items • new lexemes • SUL • Block log • User rights log • User rights • xtools)
Operator: Mdaniels5757 (talk • contribs • logs)
Task/s: Per request, replace "kategorija Wikimedije", "razločitvena stran Wikimedije", "seznam Wikimedije" with "kategorija Wikimedie", "razločitvena stran Wikimedie", and "seznam Wikimedie" in sl-language descriptions.
Code:import pywikibot
toReplace = "kategorija Wikimedije" # Then "razločitvena stran Wikimedije", then "seznam Wikimedije"
toReplaceWith = 'kategorija Wikimedie' # Then "razločitvena stran Wikimedie" , then "seznam Wikimedie"
editSummary = "BOT: testing per [[Wikidata:Bot requests#Request to replace 'kategorija Wikimedije' with 'kategorija Wikimedie' for sl (2023-02-26)|request]]"
site = pywikibot.Site("wikidata", "wikidata")
gen = pywikibot.pagegenerators.WikibaseItemGenerator(pywikibot.pagegenerators.SearchPageGenerator(toReplace, site=site, namespaces=0))
for item in gen:
if (('sl' in item.get()['descriptions'])):
if (item.get()['descriptions']['sl'] == toReplace):
item.editDescriptions({'sl': toReplaceWith}, summary=editSummary)
Function details: That's all! An example edit on my main account: Special:Diff/1901153761. Ping: TadejM. —Mdaniels5757 (talk • contribs) 19:51, 22 May 2023 (UTC)[reply]
- The replacement strings and the example are correct. Thank you. --TadejM (talk) 19:53, 22 May 2023 (UTC)[reply]
- Seems fine. BrokenSegue (talk) 21:23, 22 May 2023 (UTC)[reply]
- Test run complete, see [1]. Looks good to me. —Mdaniels5757 (talk • contribs) 16:36, 23 May 2023 (UTC)[reply]