Manual:Pywikibot/listpages.py

Print a list of pages, as defined by page generator parameters.

Optionally, it also prints page content to STDOUT or save it to a file in the current directory.

These parameters are supported to specify which pages titles to print:

-format Defines the output format.

Can be a custom string according to python string.format notation or        can be selected by a number from following list (1 is default format): 1 - u'{num:4d} {page.title}' --> 10 PageTitle

2 - u'{num:4d} {page.title}' --> 10 PageTitle

3 - u'{page.title}' --> PageTitle

4 - u'{page.title}' --> PageTitle

5 - u'{num:4d} \03{page.loc_title:<40}\03' --> 10 PageTitle (colorised in lightred)

6 - u'{num:4d} {page.loc_title:<40} {page.can_title:<40}' --> 10 localised_Namespace:PageTitle canonical_Namespace:PageTitle

7 - u'{num:4d} {page.loc_title:<40} {page.trs_title:<40}' --> 10 localised_Namespace:PageTitle outputlang_Namespace:PageTitle (*) requires "outputlang:lang" set.

num is the sequential number of the listed page.

-outputlang  Language for translation of namespaces.

-notitle Page title is not printed.

-get    Page content is printed.

-save   Save Page content to a file named as page.title(as_filename=True). Directory can be set with -dir:dir_name If no dir is specified, current direcory will be used.

-encode File encoding can be specified with '-encode:name' (name must be a         valid python encoding: utf-8, etc.). If not specified, it defaults to config.textfile_encoding.

Custom format can be applied to the following items extrapolated from a   page object:

site: obtained from page._link._site.

title: obtained from page._link._title.

loc_title: obtained from page._link.canonical_title.

can_title: obtained from page._link.ns_title. based either the canonical namespace name or on the namespace name in the language specified by the -trans param; a default value '******' will be used if no ns is found.

onsite: obtained from pywikibot.Site(outputlang, self.site.family).

trs_title: obtained from page._link.ns_title(onsite=onsite). If selected format requires trs_title, outputlang must be set.