Page MenuHomePhabricator

Change subst option in template.py
Closed, ResolvedPublicFeature

Description

Hello,

When a template use "Noinclude" tags, the "subst" done with "template.py -assubst" or "template.py -subst" give a bad result. See this example

https://fr.wikipedia.org/w/index.php?title=Mod%C3%A8le:Batailles_de_la_guerre_de_Cor%C3%A9e&diff=157094192&oldid=150555671

Is it possible to change the "subst" by "safesubst" ?

With this change the subst won't be applied but the result will be still correct.

Event Timeline

Dvorapa renamed this task from Change subst method on replace.py to Change subst method on template.py.Apr 18 2019, 9:28 AM

We either could have a -safesubst option for this or a -subst:safe which is -subst with "safe" value. I prefer the last one, this enables to add a recursive subst method-like -subst:recursive: https://en.wikipedia.org/wiki/Help:Substitution#Recursive_substitution

(BTW there is a workaround of using replace.py like this: pwb.py replace "<noinclude" "<noinclud{{subst:#if: always | e }}" "\{\{[Oo]ldtemplate" "{{subst:newtemplate" - substituting noinclude or its part as well, but it is not convenient)

Xqt triaged this task as Low priority.Apr 18 2019, 2:51 PM
Xqt changed the subtype of this task from "Task" to "Feature Request".

Hi,
Will start working on this.
Thanks

Mh-3110 renamed this task from Change subst method on template.py to Change subst option in template.py.Jun 24 2019, 9:58 PM

Hi @Hercule ,
I can reproduce the issue. However, I've tried to replace "subst" with "safesubst" with the "<includeonly>" tags applied but the result seems not correct.
See attached:

Capture d’écran 2019-06-29 à 10.13.23.png (660×2 px, 248 KB)

Capture d’écran 2019-06-29 à 10.07.56.png (630×2 px, 346 KB)

Could you please give me an example of the correct expected result with the "<includeonly>" tags applied?

Thanks

For me, safesubst/subst in template.py works weird.

@Dvorapa , yeah it's weird. None of those options works good.

@Xqt you talked about this option "-subst:safe"" which is "-subst with "safe" I didn't see such a modifier on Wikipedia.
Any documentation would help me.

Thank you

Hi,
I will unassigned myself from this task for now. Will come back to it if i have any correct solution for this issue.
Thanks

Change 591393 had a related patch set uploaded (by Urbanecm; owner: Urbanecm):
[pywikibot/core@master] template.py: Allow users to use safesubst

https://gerrit.wikimedia.org/r/591393

Change 591393 merged by jenkins-bot:
[pywikibot/core@master] template.py: Allow users to use safesubst

https://gerrit.wikimedia.org/r/591393