Utility scripts#

cache script#

This script runs commands on each entry in the API caches

Syntax:

python pwb.py cache [-password] [-delete] [-c "..."] [-o "..."] [dir ...]

If no directory are specified, it will detect the API caches.

If no command is specified, it will print the filename of all entries. If only -delete is specified, it will delete all entries.

The following parameters are supported:

-delete           Delete each command filtered. If that option is set the
                  default output will be nothing.

-c                Filter command in python syntax. It must evaluate to True to
                  output anything.

-o                Output command which is output when the filter evaluated to
                  True. If it returns None it won't output anything.

Examples

Print the filename of any entry with ‘wikidata’ in the key:

-c "wikidata" in entry._uniquedescriptionstr()

Customised output if the site code is ‘ar’:

-c entry.site.code == "ar"
-o uniquedesc(entry)

Or the state of the login:

-c entry.site._loginstatus == LoginStatus.NOT_ATTEMPTED
-o uniquedesc(entry)

If the function only uses one parameter for the entry it can be omitted:

-c has_password
-o uniquedesc

Available filter commands:

has_password(entry)
is_logout(entry)
empty_response(entry)
not_accessed(entry)
incorrect_hash(entry)
older_than_one_day(entry)
recent(entry)

There are helper functions which can be part of a command:

older_than(entry, interval)
newer_than(entry, interval)

Available output commands:

uniquedesc(entry)

colors script#

Utility to show pywikibot colors

sorting_order script#

Script that updates interwiki sorting order in family.py file

wikimedia_sites script#

Script that updates the language lists in Wikimedia family files

Usage:

python pwb.py wikimedia_sites [ {<family>} ]