Hello,
I've been asked if I could assist with some template replacements on a project [0]. While I guess I could just use template.py to do it, the script seems not to support doing multiple replacements at once, and doing it one-by-one would be very tedious and not very efficient either.
Is there any way to do it with the existing Pywikibot suite? I was thinking this might be done via replace.py and user-fixes.py or fixes.py, but I'm not sure if it'll respect template parameters or it'll strip them (e.g. just replace the template name leaving brakets and parameters untouched i.e. {{template|1=parameter}}).
Could someone please guide me?
Thank you in advance.
Best regards, M.
[0]: https://meta.wikimedia.org?oldid=21550692 (in Spanish).
MarcoAurelio strigiwm@gmail.com ezt írta (időpont: 2021. jún. 7., H, 16:18):
(e.g. just replace the template name leaving brakets and parameters untouched i.e. {{template|1=parameter}}).
This is the easiest case if only the template names change and there are no nested templates. That's what replace.py is for.
A fix r'{{oldtemplate(|.*?)}}', r'{{newtemplate\1}}' should do the work. A less elegant trick, if your problem is, that template.py should be run several times: put the commands in a batch file / bash script.
Hello Bináris,
Thanks for your reply.
Yes, I thought first about the bash/shell file with a bunch of template.py commands but like you said, it's not very elegant as I understand it would require several edits per page (one for each template that requires a replacement).
I'll try the replace.py way configuring a series of user-fixes for said project.
Best regards, M.
El lun, 7 jun 2021 a las 16:34, Bináris (wikiposta@gmail.com) escribió:
MarcoAurelio strigiwm@gmail.com ezt írta (időpont: 2021. jún. 7., H, 16:18):
(e.g. just replace the template name leaving brakets and parameters untouched i.e. {{template|1=parameter}}).
This is the easiest case if only the template names change and there are no nested templates. That's what replace.py is for.
A fix r'{{oldtemplate(|.*?)}}', r'{{newtemplate\1}}' should do the work. A less elegant trick, if your problem is, that template.py should be run several times: put the commands in a batch file / bash script.
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
You also can give pairs of templates with template.py I think
Best xqt
Am 07.06.2021 um 17:34 schrieb MarcoAurelio strigiwm@gmail.com:
Hello Bináris,
Thanks for your reply.
Yes, I thought first about the bash/shell file with a bunch of template.py commands but like you said, it's not very elegant as I understand it would require several edits per page (one for each template that requires a replacement).
I'll try the replace.py way configuring a series of user-fixes for said project.
Best regards, M.
El lun, 7 jun 2021 a las 16:34, Bináris (wikiposta@gmail.com) escribió:
MarcoAurelio strigiwm@gmail.com ezt írta (időpont: 2021. jún. 7., H, 16:18):
(e.g. just replace the template name leaving brakets and parameters untouched i.e. {{template|1=parameter}}).
This is the easiest case if only the template names change and there are no nested templates. That's what replace.py is for.
A fix r'{{oldtemplate(|.*?)}}', r'{{newtemplate\1}}' should do the work. A less elegant trick, if your problem is, that template.py should be run several times: put the commands in a batch file / bash script.
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org
Hi,
El lun, 7 jun 2021 a las 17:43, info@gno.de escribió:
You also can give pairs of templates with template.py I think
Best xqt
Tested that and indeed passing pairs of templates is supported (I thought only one pair was) and remplaces them all in just one edit.
Thanks!
Best regards, M.
Perhaps the doc need a hint for it?
Best Xqt
Am 10.06.2021 um 12:17 schrieb MarcoAurelio strigiwm@gmail.com:
Hi,
El lun, 7 jun 2021 a las 17:43, info@gno.de escribió:
You also can give pairs of templates with template.py I think
Best xqt
Tested that and indeed passing pairs of templates is supported (I thought only one pair was) and remplaces them all in just one edit.
Thanks!
Best regards, M. _______________________________________________ pywikibot mailing list -- pywikibot@lists.wikimedia.org To unsubscribe send an email to pywikibot-leave@lists.wikimedia.org