From: masti <mastigm@gmail.com>
To: pywikipedia-l@lists.wikimedia.org
Cc: 
Date: Sat, 06 Oct 2012 23:25:11 +0200
Subject: Re: [Pywikipedia-l] add_text.py feature that is sometimes a bug with stub templates
On 10/04/2012 09:12 PM, Max Klein wrote:
Hello I see that Filnik has written add_text.py for pywikipedia bot. My
bot [[en:user:VIAFbot]] calls this. It's an extremely useful function,
but there is a problem. add_text.py puts all the templates that are
below  the categories above the categories when I call it [see
http://en.wikipedia.org/w/index.php?title=David_K._Shipler&diff=next&oldid=455476445
<http://en.wikipedia.org/w/index.php?title=David_K._Shipler&diff=next&oldid=455476445>].
On English Wikipedia that's a problem because the
[[en:Wikipedia:Manual_of_Style/Layout#Order_of_sections|English manual
of style]] says that stub templates go below categories.
Can you think of a way to patch this?
Thanks,
Max

there is -noreorder parameter to prevent this.
Have you tried it?

masti

Hi Masti,

I did see that you can use -noreorder. The problem with no reorder is that then you are just inserting at the very last line of the page. But I finally understood what add_text does
The thing that is misleading  is that it doesn't "insert above category and language links but below the rest of the text" like it says. It's true that add_text has that effect when pages follow the order of
1. content
2. templates
3. categories
4. language links

but in English Wikipedia there are sometimes things stored inbetween categories and language links ( I agree that the practice of doing that is bad).

In fact what add_text does is remove the categories and language links, insert text at the end, and then paste back on categories and language links. That means that if there are other things inbetween categories and language links then they will jump up in order.

I refactored my code to stop using add_text and am running using a modified version of replaceExcept to insert text via big switch statement searching for the first category, or first {{persondata}}.

Thanks,
Max