Manual talk:Pywikibot/pagegenerators.py

From mediawiki.org
Latest comment: 24 days ago by Varlin in topic Exclude redlinks ?

Suppressing line numbers[edit]

When I run pagegenerators.py, I am now presented with a list that has line numbers. This means that I must remove the line numbers before I can use the generated list. I've been looking for a couple of days now, and I can't seem to find a way to turn line numbering off. Does anyone know how to suppress line numbers in the output of this script? CzechOut (talk) 14:26, 17 September 2012 (UTC)Reply[reply]

This isn't much help in pywikipediabot itself, but in a script I use, I strip out the numbers like:
python pagegenerators.py -new:$NPL|sed 's|[0-9][0-9][0-9]: |\* \[\[|'| sed 's|[0-9][0-9]: |\* \[\[|' | sed 's|[0-9]: |\* \[\[|' | sed 's:$:]]:' > newpages.txt
That removes the numbers and puts * [[ at the beginning and ]] at the end, so I can feed it into category.py. Inclusivedisjunction (talk) 20:57, 26 September 2012 (UTC)Reply[reply]
This problem only exists in compat. In core, Manual:Pywikibot/listpages.py allows the caller to specify the row format, either using one of the five presets, or a completely custom format. John Vandenberg (talk) 22:26, 7 March 2016 (UTC)Reply[reply]

Reusable translations of page generator options[edit]

It would be nice if we can have a page like Manual:Pywikibot/Global Options for the page generator options, so it can be transcluded onto script pages like Manual:Pywikibot/imageuncat.py.

One approach is to use transclusion of this page, with <includeonly> around the Parameters section.

However, I have looked at all of the translations of this page, and none of them have started translating the descriptions of the parameters, so no work will be lost if that part of the page is moved to a new translatable page. John Vandenberg (talk) 22:23, 7 March 2016 (UTC)Reply[reply]

Done --Dvorapa (talk) 15:06, 17 June 2018 (UTC)Reply[reply]

Exclude redlinks ?[edit]

Hi, is there a way to exclude red links from the results of Page generator ? Because my script returns a pywikibot.exceptions.NoPageError if there is one single red link on a page. I wish it would just ignore it. Varlin (talk) 20:57, 11 January 2023 (UTC)Reply[reply]