I use a combination of getCategoryLinks() and then replaceCategoryLinks()
it updates them in place, or adds them where needed.
On Thu, Jan 4, 2024 at 2:58 AM <info(a)gno.de> wrote:
Hi,
to add a category to several pages, category script can be used. For
implementing a function or method, its treat method can be used as templet:
https://doc.wikimedia.org/pywikibot/master/_modules/scripts/category.html#C…
You can also use textlib for manipulating templates.
Best
xqt
Von meinem iPhone gesendet
Am 03.01.2024 um 21:02 schrieb Bináris <wikiposta(a)gmail.com>om>:
Thank you! At the end,I wrote to the end. We must care if there is already
a \n ath end or not.
Ethan N. <enag2000(a)gmail.com> ezt írta (időpont: 2024. jan. 3., Sze,
18:47):
Bináris,
A nice function for this does not currently exist for Page class. See
https://phabricator.wikimedia.org/T325420.
I am working on this one so it is in progress. Hopefully this weekend I
will finish the initial version of the changes and start the review
process. There are several workarounds, one of which is adding to end of
text, which you mentioned already. One other workaround is to use
textlib.replaceCategoryLinks(). See
https://doc.wikimedia.org/pywikibot/master/api_ref/textlib.html#textlib.rep…
.
Thanks,
Ethan
On Tue, Jan 2, 2024 at 11:45 PM Bináris <wikiposta(a)gmail.com> wrote:
At
https://doc.wikimedia.org/pywikibot/master/api_ref/pywikibot.page.html
I only find change_category which requires the old cat to be removed
present.
But how do I just add a new one w/o changing?
OK, I can add it to the end of text, but that is not nice.
--
Bináris
_______________________________________________
pywikibot mailing list -- pywikibot(a)lists.wikimedia.org
Public archives at
https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/m…
To unsubscribe send an email to pywikibot-leave(a)lists.wikimedia.org
_______________________________________________
pywikibot mailing list -- pywikibot(a)lists.wikimedia.org
Public archives at
https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/m…
To unsubscribe send an email to pywikibot-leave(a)lists.wikimedia.org
--
Bináris
_______________________________________________
pywikibot mailing list -- pywikibot(a)lists.wikimedia.org
Public archives at
https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/m…
To unsubscribe send an email to pywikibot-leave(a)lists.wikimedia.org
_______________________________________________
pywikibot mailing list -- pywikibot(a)lists.wikimedia.org
Public archives at
https://lists.wikimedia.org/hyperkitty/list/pywikibot@lists.wikimedia.org/m…
To unsubscribe send an email to pywikibot-leave(a)lists.wikimedia.org