Manual talk:Pywikibot/2024
Add topicThis page used the Structured Discussions extension to give structured discussions. It has since been converted to wikitext, so the content and history here are only an approximation of what was actually displayed at the time these comments were made. |
![]() Archives
|
---|
Please use one of the communication channels listed on Manual:Pywikibot/Communication rather than using this discussion board. There is very little traffic here, so it may take a while before you get a response.
pywikibot doesn't see scripts translations
[edit]The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.
I installed pywikibot as package, downloaded `scripts` and `scripts/i18n`. Added `user_script_paths = ['scripts']` to `user-config.py`. When I run any script I got translation error. Pywikibot search translation in `pywikibot.scripts.i18n` only.
How to use standard scripts with package installed `pywikibot`? Dimka665 (talk) 10:27, 4 October 2024 (UTC)
- See phab:T376471 for further details. @xqt 16:20, 4 October 2024 (UTC)
Replacing templates
[edit]Hi @Xqt - thanks for all the work you've done on pywikibot, I've used template.py
for simple replacements via https://en.wiktionary.org/wiki/User:ColumbaBushBot but now I wanted to do something more complicated
- detect if
{{aii-verb}}
exists - extract its first argument
- and replace the
aii-conj-verb
template (ex.{{aii-conj-verb/G]}}
,{{aii-conj-verb/C]}}
, etc...) with{{aii-conj|<first argument from step 2>}}
An example of this would be this edit https://en.wiktionary.org/w/index.php?title=%DC%A5%DC%A2%DC%90&diff=prev&oldid=82304028
Can you recommend how I can use existing scripts to accomplish this, or perhaps even provide a code snippet to modify an existing script?
Thanks so much, your help is greatly appreciated ColumbaBush (talk) 16:47, 10 October 2024 (UTC)
Add Sitelinks to Wikipedia with badge 'intentional sitelink to redirect'
[edit]Hi, i am trying to add a Sitelink to a Wikidata Entry, pointing to a site in a wikipedia project that is a redirect. When i add the page directly, the redirect gets resolved an the sitelink gets added as the page behind the redirect. I assume i have to somehow set the badge 'intentional sitelink to redirect'. I tried searching for a guide or documentation on that, but could not find it. Can someone point me to a page where this is described, or does someone know, if this even is a feature that is supported? Thanks in Advance Tidoni (talk) 06:52, 18 October 2024 (UTC)
- It should be possible using SiteLink:
from pywikibot import ItemPage, SiteLink site = ... repo = pywikibot.Site('wikidata') item = ItemPage(repo, 'Q4115189') link = SiteLink(title, site, [ItemPage(repo, 'Q70894304')]) item.setSitelink(link)
- or that like. Matěj Suchánek (talk) 16:15, 18 October 2024 (UTC)
Category:NG:Dev.Team_games
[edit]Hi. I found that
site = pywikibot.Site("en") page = pywikibot.Page(site, "Category:NG:Dev.Team_games") print(page.text)
works well, but
site = pywikibot.Site("en") page = pywikibot.Page(site, "NG:Dev.Team_games", 14) print(page.text)
raises an error:
NoUsernameError: Failed OAuth authentication for wikipedia:ng: The authorization headers in your request are for a user that does not exist here
I guess pywikibot treated the title as a interwiki. So how to make it parses namespace id (i.e. 14) first? Thanks.
(version 9.6.0) For Each element In group ... Next (talk) 17:33, 7 December 2024 (UTC)
- Looks like the issue of phab:T67262. @xqt 22:53, 7 December 2024 (UTC)