Categories scripts#

category_redirect script#

This bot will move pages out of redirected categories

The bot will look for categories that are marked with a category redirect template, take the first parameter of the template as the target of the redirect, and move all pages and subcategories of the category there. It also changes hard redirects into soft redirects, and fixes double redirects. A log is written under <userpage>/category_redirect_log. A log is written under <userpage>/category_edit_requests if a page cannot be moved to be done manually. Only category pages that haven’t been edited for a certain cooldown period (default 7 days) are taken into account.

The following parameters are supported:

-always

If used, the bot won’t ask if it should add the specified text

-delay:#

Set an amount of days. If the category is edited more recently than given days, ignore it. Default is 7.

-tiny

Only loops over Category:Non-empty_category_redirects and moves all images, pages and categories in redirect categories to the target category.

-category:<cat>

Category to be used with this script. If not given either wikibase entries Q4616723 or Q8099903 are used.

Usage:

python pwb.py category_redirect [options]

Note

This script is a ConfigParserBot. All options can be set within a settings file which is scripts.ini by default.

category_graph script#

Visualizes category hierarchy

Generates graphical representation in formats dot, svg and html5 of category hierarchy.

Usage:

pwb.py category_graph [-style STYLE] [-depth DEPTH] [-from FROM] [-to TO]

actions:

-from [FROM]

Category name to scan, default is main category, “?” to ask.

optional arguments:

-to TO

base file name to save, “?” to ask

-style STYLE

graphviz style definitions in dot format (see below)

-depth DEPTH

maximal hierarchy depth. 2 by default

-downsize K

font size divider for subcategories. 4 by default Use 1 for the same font size

See also

https://graphviz.org/doc/info/attrs.html for graphviz style definitions.

Example

Visualizes main category:

pwb.py -v category_graph -from

Extended example with style settings:

pwb.py category_graph -from Life -downsize 1.5 -style ‘graph[rankdir=BT ranksep=0.5] node[shape=circle style=filled fillcolor=green] edge[style=dashed penwidth=3]’

Added in version 8.0.

commonscat script#

With this tool you can add the template {{commonscat}} to categories

The tool works by following the interwiki links. If the template is present on another language page, the bot will use it.

Warning

You could probably use it at articles as well, but this isn’t tested.

The following parameters are supported:

-checkcurrent

Work on all category pages that use the primary commonscat template.

This script is a ConfigParserBot. The following options can be set within a settings file which is scripts.ini by default:

-always

Don’t prompt you for each replacement. Warning message has not to be confirmed.

Attention

Use this with care!

-summary:XYZ

Set the action summary message for the edit to XYZ, otherwise it uses messages from add_text.py as default.

This bot uses pagegenerators to get a list of pages. The following options are supported:

This script supports use of pagegenerators arguments.

For example to go through all categories:

python pwb.py commonscat -start:Category:!