Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1083432?usp=email )
Change subject: [doc] solve some sphinx warnings ......................................................................
[doc] solve some sphinx warnings
Change-Id: Ic51f0fda375995456759f1a332347b44f133105e --- M docs/conf.py M scripts/checkimages.py M scripts/coordinate_import.py M scripts/image.py M scripts/imagetransfer.py M scripts/interwiki.py M scripts/interwikidata.py M scripts/listpages.py M scripts/movepages.py M scripts/pagefromfile.py M scripts/replicate_wiki.py M scripts/template.py M scripts/touch.py M scripts/unusedfiles.py M scripts/upload.py M scripts/watchlist.py M scripts/welcome.py 17 files changed, 674 insertions(+), 604 deletions(-)
Approvals: Xqt: Verified; Looks good to me, approved
diff --git a/docs/conf.py b/docs/conf.py index e36ab8f..6f2432e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -565,7 +565,7 @@ if match: opt, sp, desc = match.groups() desc = re.sub(r'[(float|int|str)]', r'*(\1)*', desc) - if ':' in opt or ' ' in opt: + if ':' in opt or ' ' in opt and ', ' not in opt: length = len(opt + sp) lines[index] = f':kbd:`{opt}`' else: diff --git a/scripts/checkimages.py b/scripts/checkimages.py index 5c7077e..6dd9bed 100755 --- a/scripts/checkimages.py +++ b/scripts/checkimages.py @@ -4,68 +4,72 @@ This script checks if a file description is present and if there are other problems in the image's description.
-This script will have to be configured for each language. Please submit -translations as addition to the Pywikibot framework. +This script will have to be configured for each site. Please submit +localisations as addition to the Pywikibot framework.
Everything that needs customisation is indicated by comments.
This script understands the following command-line arguments:
--limit The number of images to check (default: 80) +-limit [int] The number of images to check (default: 80)
--commons The bot will check if an image on Commons has the same name - and if true it reports the image. +-commons The bot will check if an image on Commons has the + same name and if true it reports the image.
--duplicates[:#] Checking if the image has duplicates (if arg, set how many - rollback wait before reporting the image in the report - instead of tag the image) default: 1 rollback. +-duplicates[:#] Checking if the image has duplicates (if arg, set how + many rollback wait before reporting the image in the + report instead of tag the image) default: 1 rollback.
--duplicatesreport Report the duplicates in a log *AND* put the template in - the images. +-duplicatesreport Report the duplicates in a log *AND* put the template + in the images.
--maxusernotify Maximum notifications added to a user talk page in a single - check, to avoid email spamming. +-maxusernotify Maximum notifications added to a user talk page in a + single check, to avoid email spamming.
--sendemail Send an email after tagging. +-sendemail Send an email after tagging.
--break To break the bot after the first check (default: recursive) +-break To break the bot after the first check (default: + recursive)
--sleep[:#] Time in seconds between repeat runs (default: 30) +-sleep[:#] Time in seconds between repeat runs (default: 30)
--wait[:#] Wait x second before check the images (default: 0) +-wait[:#] Wait x second before check the images (default: 0)
--skip[:#] The bot skip the first [:#] images (default: 0) +-skip[:#] The bot skip the first [:#] images (default: 0)
--start[:#] Use allimages() as generator - (it starts already from File:[:#]) +-start[:#] Use allimages() as generator (it starts already from + File:[:#])
--cat[:#] Use a category as generator +-cat[:#] Use a category as generator
--regex[:#] Use regex, must be used with -url or -page +-regex[:#] Use regex, must be used with ``-url`` or ``-page``
--page[:#] Define the name of the wikipage where are the images +-page[:#] Define the name of the wikipage where are the images
--url[:#] Define the url where are the images +-url[:#] Define the url where are the images
--nologerror If given, this option will disable the error that is risen - when the log is full. +-nologerror If given, this option will disable the error that is + risen when the log is full.
-Instructions for the real-time settings. -For every new block you have to add: +**Instructions for the real-time settings**
- <------- -------> +For every new block you have to add::
-In this way the bot can understand where the block starts in order to take the -right parameter. + <------- ------->
-* Name= Set the name of the block -* Find= search this text in the image's description -* Findonly= search for exactly this text in the image's description -* Summary= That's the summary that the bot will use when it will notify the - problem. -* Head= That's the incipit that the bot will use for the message. -* Text= This is the template that the bot will use when it will report the - image's problem. +In this way the bot can understand where the block starts in order to +take the right parameter: + +.. code:: text + + Name= Set the name of the block + Find= search this text in the image's description + Findonly= search for exactly this text in the image's description + Summary= That's the summary that the bot will use when it will + notify the problem. + Head= That's the incipit that the bot will use for the message. + Text= This is the template that the bot will use when it will + report the image's problem.
.. versionchanged:: 8.4 Welcome messages are imported from :mod:`scripts.welcome` script. diff --git a/scripts/coordinate_import.py b/scripts/coordinate_import.py index 25813ed..c802a70 100755 --- a/scripts/coordinate_import.py +++ b/scripts/coordinate_import.py @@ -1,14 +1,13 @@ #!/usr/bin/env python3 -r""" -Coordinate importing script. +r"""Coordinate importing script.
Usage:
python pwb.py coordinate_import -site:wikipedia:en \ --cat:Category:Coordinates_not_on_Wikidata + -cat:Category:Coordinates_not_on_Wikidata
-This will work on all pages in the category "coordinates not on Wikidata" and -will import the coordinates on these pages to Wikidata. +This will work on all pages in the category "coordinates not on Wikidata" +and will import the coordinates on these pages to Wikidata.
The data from the "GeoData" extension (https://www.mediawiki.org/wiki/Extension:GeoData) @@ -18,7 +17,7 @@ You can use any typical pagegenerator to provide with a list of pages:
python pwb.py coordinate_import -lang:it -family:wikipedia -namespace:0 \ --transcludes:Infobox_stazione_ferroviaria + -transcludes:Infobox_stazione_ferroviaria
You can also run over a set of items on the repo without coordinates and try to import them from any connected page. To do this, you have to @@ -27,19 +26,18 @@ Example:
python pwb.py coordinate_import -site:wikidata:wikidata -namespace:0 \ --querypage:Deadendpages + -querypage:Deadendpages
The following command line parameters are supported:
--always If used, the bot won't ask if it should add the specified - text +-always If used, the bot won't ask if it should add the specified text.
--create Create items for pages without one. +-create Create items for pages without one.
-.. note:: This script is a - :py:obj:`ConfigParserBot <bot.ConfigParserBot>`. All options - can be set within a settings file which is scripts.ini by default. +.. note:: This script is a :class:`ConfigParserBot <bot.ConfigParserBot>`. + All options can be set within a settings file which is scripts.ini by + default.
¶ms; """ diff --git a/scripts/image.py b/scripts/image.py index a8a5632..3bd14f6 100755 --- a/scripts/image.py +++ b/scripts/image.py @@ -1,37 +1,39 @@ #!/usr/bin/env python3 -""" -This script can be used to change one image to another or remove an image. +"""This script can be used to change one image to another or remove an image.
Syntax:
python pwb.py image image_name [new_image_name]
-If only one command-line parameter is provided then that image will be removed; -if two are provided, then the first image will be replaced by the second one on -all pages. +If only one command-line parameter is provided then that image will be +removed; if two are provided, then the first image will be replaced by +the second one on all pages.
Command line options:
-summary: Provide a custom edit summary. If the summary includes spaces, surround it with single quotes, such as: - -summary:'My edit summary' + ``-summary:'My edit summary'`` + -always Don't prompt to make changes, just do them. --loose Do loose replacements. This will replace all occurrences of the name - of the image (and not just explicit image syntax). This should work - to catch all instances of the image, including where it is used as a - template parameter or in image galleries. However, it can also make - more mistakes. This only works with image replacement, not image - removal. + +-loose Do loose replacements. This will replace all occurrences of + the name of the image (and not just explicit image syntax). + This should work to catch all instances of the image, + including where it is used as a template parameter or in + image galleries. However, it can also make more mistakes. + This only works with image replacement, not image removal.
Examples --------
-The image "FlagrantCopyvio.jpg" is about to be deleted, so let's first remove -it from everything that displays it: +The image "FlagrantCopyvio.jpg" is about to be deleted, so let's first +remove it from everything that displays it:
python pwb.py image FlagrantCopyvio.jpg
-The image "Flag.svg" has been uploaded, making the old "Flag.jpg" obsolete: +The image "Flag.svg" has been uploaded, making the old "Flag.jpg" +obsolete:
python pwb.py image Flag.jpg Flag.svg
diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py index c990df2..829e766 100755 --- a/scripts/imagetransfer.py +++ b/scripts/imagetransfer.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -""" -Script to copy images to Wikimedia Commons, or to another wiki. +"""Script to copy images to Wikimedia Commons, or to another wiki.
Syntax:
@@ -8,31 +7,38 @@
The following parameters are supported:
- -interwiki Look for images in pages found through interwiki links. +-interwiki Look for images in pages found through interwiki + links.
- -keepname Keep the filename and do not verify description while - replacing +-keepname Keep the filename and do not verify description while + replacing.
- -tolang:x Copy the image to the wiki in code x +-tolang:x [str] Copy the image to the wiki in code x.
- -tofamily:y Copy the image to a wiki in the family y +-tofamily:y [str] Copy the image to a wiki in the family y.
- -tosite:s Copy the image to the given site like wikipedia:test +-tosite:s [str] Copy the image to the given site like + wikipedia:test.
- -force_if_shared Upload the file to the target, even if it exists on that - wiki's shared repo +-force_if_shared Upload the file to the target, even if it exists on + that wiki's shared repo
- -asynchronous Upload to stash. +-asynchronous Upload to stash.
- -chunk_size:n Upload in chunks of n bytes. +-chunk_size:n [int] Upload in chunks of n bytes.
- -file:z Upload many files from textfile: [[Image:x]] - [[Image:y]] +-file:z [str] Upload many files from textfile z + like:
-If pagename is an image description page, offers to copy the image to the -target site. If it is a normal page, it will offer to copy any of the images -used on that page, or if the -interwiki argument is used, any of the images -used on a page reachable via interwiki links. + .. code:: wikitext + + [[Image:x]] + [[Image:y]] + +If pagename is an image description page, offers to copy the image to +the target site. If it is a normal page, it will offer to copy any of +the images used on that page, or if the -interwiki argument is used, any +of the images used on a page reachable via interwiki links.
¶ms; """ diff --git a/scripts/interwiki.py b/scripts/interwiki.py index d303363..de206ac 100755 --- a/scripts/interwiki.py +++ b/scripts/interwiki.py @@ -1,324 +1,348 @@ #!/usr/bin/env python3 """Script to check language links for general pages.
-Uses existing translations of a page, plus hints from the command line, to -download the equivalent pages from other languages. All of such pages are -downloaded as well and checked for interwiki links recursively until there are -no more links that are encountered. A rationalization process then selects the -right interwiki links, and if this is unambiguous, the interwiki links in the -original page will be automatically updated and the modified page uploaded. +Uses existing translations of a page, plus hints from the command line, +to download the equivalent pages from other languages. All of such pages +are downloaded as well and checked for interwiki links recursively until +there are no more links that are encountered. A rationalization process +then selects the right interwiki links, and if this is unambiguous, the +interwiki links in the original page will be automatically updated and +the modified page uploaded.
-These command-line arguments can be used to specify which pages to work on: +.. hint:: This script should not be used for wiki farms having a data + repository like Wikidata for Wikimedia cluster. Possibly use the + :mod:``scripts.interwikidata`` script for similar purpose in such + environments.
- -days: Like -years, but runs through all date pages. Stops at - Dec 31. If the argument is given in the form -days:X, - it will start at month no. X through Dec 31. If the - argument is simply given as -days, it will run from - Jan 1 through Dec 31. E.g. for -days:9 it will run - from Sep 1 through Dec 31. +These command-line arguments can be used to specify which pages to work +on:
- -years: run on all year pages in numerical order. Stop at year 2050. - If the argument is given in the form -years:XYZ, it - will run from [[XYZ]] through [[2050]]. If XYZ is a - negative value, it is interpreted as a year BC. If the - argument is simply given as -years, it will run from 1 - through 2050. +-days: Like -years, but runs through all date pages. Stops at + Dec 31. If the argument is given in the form -days:X, it + will start at month no. X through Dec 31. If the + argument is simply given as -days, it will run from Jan + 1 through Dec 31. E.g. for -days:9 it will run from Sep + 1 through Dec 31.
- This implies -noredirect. +-years: Run on all year pages in numerical order. Stop at year + 2050. If the argument is given in the form -years:XYZ, + it will run from [[XYZ]] through [[2050]]. If XYZ is a + negative value, it is interpreted as a year BC. If the + argument is simply given as -years, it will run from 1 + through 2050.
- -new: Work on the 100 newest pages. If given as -new:x, will work - on the x newest pages. - When multiple -namespace parameters are given, x pages are - inspected, and only the ones in the selected name spaces are - processed. Use -namespace:all for all namespaces. Without - -namespace, only article pages are processed. + This option implies ``-noredirect``.
- This implies -noredirect. +-new: Work on the 100 newest pages. If given as -new:x, will + work on the x newest pages. When multiple -namespace + parameters are given, x pages are inspected, and only + the ones in the selected name spaces are processed. Use + ``-namespace:all`` for all namespaces. Without + ``-namespace``, only article pages are processed.
- -restore: restore a set of "dumped" pages the bot was working on - when it terminated. The dump file will be subsequently - removed. + This option implies ``-noredirect``.
- -restore:all restore a set of "dumped" pages of all dumpfiles to a given - family remaining in the "interwiki-dumps" directory. All - these dump files will be subsequently removed. If restoring - process interrupts again, it saves all unprocessed pages in - one new dump file of the given site. +-restore: Restore a set of "dumped" pages the bot was working on + when it terminated. The dump file will be subsequently + removed.
- -continue: like restore, but after having gone through the dumped - pages, continue alphabetically starting at the last of the - dumped pages. The dump file will be subsequently removed. +-restore:all Restore a set of "dumped" pages of all dumpfiles to a + given family remaining in the "interwiki-dumps" + directory. All these dump files will be subsequently + removed. If restoring process interrupts again, it saves + all unprocessed pages in one new dump file of the given + site. + +-continue: Like restore, but after having gone through the dumped + pages, continue alphabetically starting at the last of + the dumped pages. The dump file will be subsequently + removed.
¶ms;
-Additionally, these arguments can be used to restrict the bot to certain pages: +Additionally, these arguments can be used to restrict the bot to certain +pages:
- -namespace:n Number or name of namespace to process. The parameter can be - used multiple times. It works in combination with all other - parameters, except for the -start parameter. If you e.g. - want to iterate over all categories starting at M, use - -start:Category:M. +-namespace:n [int] Number or name of namespace to process. The + parameter can be used multiple times. It works in + combination with all other parameters, except for the + ``-start`` parameter. If you e.g. want to iterate over + all categories starting at M, use ``-start:Category:M``.
- -number: used as -number:#, specifies that the bot should process - that amount of pages and then stop. This is only useful in - combination with -start. The default is not to stop. +-number: [int] Used as -number:#, specifies that the bot should + process that amount of pages and then stop. This is only + useful in combination with ``-start``. The default is + not to stop.
- -until: used as -until:title, specifies that the bot should - process pages in wiki default sort order up to, and - including, "title" and then stop. This is only useful in - combination with -start. The default is not to stop. - Note: do not specify a namespace, even if -start has one. +-until: [str] Used as -until:title, specifies that the bot + should process pages in wiki default sort order up to, + and including, "title" and then stop. This is only + useful in combination with ``-start``. The default is + not to stop.
- -bracket only work on pages that have (in the home language) - parenthesis in their title. All other pages are skipped. - (note: without ending colon) + .. note:: Do not specify a namespace, even if ``-start`` + has one.
- -skipfile: used as -skipfile:filename, skip all links mentioned in - the given file. This does not work with -number! +-bracket Only work on pages that have (in the home language) + parenthesis in their title. All other pages are skipped.
- -skipauto use to skip all pages that can be translated automatically, - like dates, centuries, months, etc. - (note: without ending colon) +-skipfile: Used as -skipfile:filename, skip all links mentioned in + the given file. This does not work with ``-number``!
- -lack: used as -lack:xx with xx a language code: only work on pages - without links to language xx. You can also add a number nn - like -lack:xx:nn, so that the bot only works on pages with - at least nn interwiki links (the default value for nn is 1). +-skipauto Use to skip all pages that can be translated + automatically, like dates, centuries, months, etc. + +-lack: Used as -lack:xx with xx a language code: only work on + pages without links to language xx. You can also add a + number nn like ``-lack:xx:nn``, so that the bot only + works on pages with at least nn interwiki links (the + default value for nn is 1).
These arguments control miscellaneous bot behaviour:
- -quiet Use this option to get less output - (note: without ending colon) +-quiet Use this option to get less output
- -async Put page on queue to be saved to wiki asynchronously. This - enables loading pages during saving throttling and gives a - better performance. - NOTE: For post-processing it always assumes that saving the - the pages was successful. - (note: without ending colon) +-async Put page on queue to be saved to wiki asynchronously. + This enables loading pages during saving throttling and + gives a better performance.
- -summary: Set an additional action summary message for the edit. This - could be used for further explainings of the bot action. - This will only be used in non-autonomous mode. + .. note:: For post-processing it always assumes that + saving the pages was successful.
- -hintsonly The bot does not ask for a page to work on, even if none of - the above page sources was specified. This will make the - first existing page of -hint or -hinfile slip in as start - page, determining properties like namespace, disambiguation - state, and so on. When no existing page is found in the - hints, the bot does nothing. - Hitting return without input on the "Which page to check:" - prompt has the same effect as using -hintsonly. - Options like -back or -same are in effect only after a page - has been found to work on. (note: without ending colon) +-summary: [str] Set an additional action summary message for the + edit. This could be used for further explainings of the + bot action. This will only be used in non-autonomous + mode. + +-hintsonly The bot does not ask for a page to work on, even if none + of the above page sources was specified. This will make + the first existing page of -hint or -hinfile slip in as + start page, determining properties like namespace, + disambiguation state, and so on. When no existing page + is found in the hints, the bot does nothing. Hitting + return without input on the "Which page to check:" + prompt has the same effect as using ``-hintsonly``. + Options like ``-back`` or ``-same`` are in effect only + after a page has been found to work on.
These arguments are useful to provide hints to the bot:
- -hint: used as -hint:de:Anweisung to give the bot a hint - where to start looking for translations. If no text - is given after the second ':', the name of the page - itself is used as the title for the hint, unless the - -hintnobracket command line option (see there) is also - selected. +-hint: Used as -hint:de:Anweisung to give the bot a hint where + to start looking for translations. If no text is given + after the second ':', the name of the page itself is + used as the title for the hint, unless the + ``-hintnobracket`` command line option (see there) is + also selected.
- There are some special hints, trying a number of languages - at once: + There are some special hints, trying a number of + languages at once:
- * all: All languages with at least ca. 100 articles - * 10: The 10 largest languages (sites with most - articles). Analogous for any other natural - number - * arab: All languages using the Arabic alphabet - * cyril: All languages that use the Cyrillic alphabet - * chinese: All Chinese dialects - * latin: All languages using the Latin script - * scand: All Scandinavian languages + * *all:* All languages with at least ca. 100 + articles + * *10:* The 10 largest languages (sites with most + articles). Analogous for any other natural number + * *arab:* All languages using the Arabic alphabet + * *cyril:* All languages that use the Cyrillic alphabet + * *chinese:* All Chinese dialects + * *latin:* All languages using the Latin script + * *scand:* All Scandinavian languages
- Names of families that forward their interlanguage links - to the wiki family being worked upon can be used, they are: + Names of families that forward their interlanguage links + to the wiki family being worked upon can be used, they + are:
- * commons: Interlanguage links of Wikimedia Commons - * incubator: Links in pages on the Wikimedia Incubator - * meta: Interlanguage links of named pages on Meta - * species: Interlanguage links of the Wikispecies wiki - * strategy: Links in pages on Wikimedia Strategy wiki - * test: Take interwiki links from Test Wikipedia - * wikimania: Interwiki links of Wikimania + * *commons:* Interlanguage links of Wikimedia Commons + * *incubator:* Links in pages on the Wikimedia Incubator + * *meta:* Interlanguage links of named pages on Meta + * *species:* Interlanguage links of the Wikispecies wiki + * *strategy:* Links in pages on Wikimedia Strategy wiki + * *test:* Take interwiki links from Test Wikipedia + * *wikimania:* Interwiki links of Wikimania
- Languages, groups and families having the same page title - can be combined, as -hint:5,scand,sr,pt,commons:New_York + Languages, groups and families having the same page + title can be combined, as + ``-hint:5,scand,sr,pt,commons:New_York``
- -hintfile: similar to -hint, except that hints are taken from the given - file, enclosed in [[]] each, instead of the command line. +-hintfile: Similar to -hint, except that hints are taken from the + given file, enclosed in [[]] each, instead of the + command line.
- -askhints: for each page one or more hints are asked. See hint: above - for the format, one can for example give "en:something" or - "20:" as hint. +-askhints: For each page one or more hints are asked. See ``-hint:`` + above for the format, one can for example give + "en:something" or "20:" as hint.
- -repository Include data repository +-repository Include data repository
- -same looks over all 'serious' languages for the same title. - -same is equivalent to -hint:all: - (note: without ending colon) +-same Looks over all 'serious' languages for the same title. + ``-same`` is equivalent to ``-hint:all``.
- -untranslated: works normally on pages with at least one interlanguage - link; asks for hints for pages that have none. +-untranslated: Works normally on pages with at least one interlanguage + link; asks for hints for pages that have none.
- -untranslatedonly: same as -untranslated, but pages which already have a - translation are skipped. Hint: do NOT use this in - combination with -start without a -number limit, because - you will go through the whole alphabet before any queries - are performed! +-untranslatedonly: Same as ``-untranslated``, + but pages which already have a translation are skipped.
- -showpage when asking for hints, show the first bit of the text - of the page always, rather than doing so only when being - asked for (by typing '?'). Only useful in combination - with a hint-asking option like -untranslated, -askhints - or -untranslatedonly. - (note: without ending colon) + .. hint:: do NOT use this in combination with ``-start`` + without a ``-number`` limit, because you will go + through the whole alphabet before any queries are + performed!
- -noauto Do not use the automatic translation feature for years and - dates, only use found links and hints. - (note: without ending colon) +-showpage When asking for hints, show the first bit of the text of + the page always, rather than doing so only when being + asked for (by typing '?'). Only useful in combination + with a hint-asking option like ``-untranslated``, + ``-askhints`` or ``-untranslatedonly``.
- -hintnobracket used to make the bot strip everything in last brackets, - and surrounding spaces from the page name, before it is - used in a -hint:xy: where the page name has been left out, - or -hint:all:, -hint:10:, etc. without a name, or - an -askhint reply, where only a language is given. +-noauto Do not use the automatic translation feature for years + and dates, only use found links and hints. + +-hintnobracket Used to make the bot strip everything in last brackets, + and surrounding spaces from the page name, before it is + used in a ``-hint:xy:`` where the page name has been + left out, or ``-hint:all:``, ``-hint:10:``, etc. without + a name, or an ``-askhint`` reply, where only a language + is given.
These arguments define how much user confirmation is required:
- -autonomous run automatically, do not ask any questions. If a question - -auto to an operator is needed, write the name of the page - to autonomous_problems.dat and continue on the next page. - (note: without ending colon) +-autonomous, -auto + Run automatically, do not ask any questions. If a + question to an operator is needed, write the name of the + page to autonomous_problems.dat and continue on the next + page.
- -confirm ask for confirmation before any page is changed on the - live wiki. Without this argument, additions and - unambiguous modifications are made without confirmation. - (note: without ending colon) +-confirm Ask for confirmation before any page is changed on the + live wiki. Without this argument, additions and + unambiguous modifications are made without confirmation.
- -force do not ask permission to make "controversial" changes, - like removing a language because none of the found - alternatives actually exists. - (note: without ending colon) +-force Do not ask permission to make "controversial" changes, + like removing a language because none of the found + alternatives actually exists.
- -cleanup like -force but only removes interwiki links to non-existent - or empty pages. +-cleanup Like ``-force`` but only removes interwiki links to + non-existent or empty pages.
- -select ask for each link whether it should be included before - changing any page. This is useful if you want to remove - invalid interwiki links and if you do multiple hints of - which some might be correct and others incorrect. Combining - -select and -confirm is possible, but seems like overkill. - (note: without ending colon) +-select Ask for each link whether it should be included before + changing any page. This is useful if you want to remove + invalid interwiki links and if you do multiple hints of + which some might be correct and others incorrect. + Combining ``-select`` and ``-confirm`` is possible, but + seems like overkill.
-These arguments specify in which way the bot should follow interwiki links: +These arguments specify in which way the bot should follow interwiki +links:
- -noredirect do not follow redirects nor category redirects. - (note: without ending colon) +-noredirect Do not follow redirects nor category redirects.
- -initialredirect work on its target if a redirect or category redirect is - entered on the command line or by a generator (note: without - ending colon). It is recommended to use this option with the - -movelog pagegenerator. +-initialredirect + Work on its target if a redirect or category redirect is + entered on the command line or by a generator.
- -neverlink: used as -neverlink:xx where xx is a language code: - Disregard any links found to language xx. You can also - specify a list of languages to disregard, separated by - commas. + .. tip:: It is recommended to use this option with the + ``-movelog`` pagegenerator.
- -ignore: used as -ignore:xx:aaa where xx is a language code, and - aaa is a page title to be ignored. +-neverlink: Used as ``-neverlink:xx`` where xx is a language code, + disregard any links found to language xx. You can also + specify a list of languages to disregard, separated by + commas.
- -ignorefile: similar to -ignore, except that the pages are taken from - the given file instead of the command line. +-ignore: Used as -ignore:xx:aaa where xx is a language code, and + aaa is a page title to be ignored.
- -localright do not follow interwiki links from other pages than the - starting page. (Warning! Should be used very sparingly, - only when you are sure you have first gotten the interwiki - links on the starting page exactly right). - (note: without ending colon) +-ignorefile: Similar to ``-ignore``, except that the pages are taken + from the given file instead of the command line.
- -hintsareright do not follow interwiki links to sites for which hints - on existing pages are given. Note that, hints given - interactively, via the -askhint command line option, - are only effective once they have been entered, thus - interwiki links on the starting page are followed - regardess of hints given when prompted. - (Warning! Should be used with caution!) - (note: without ending colon) +-localright Do not follow interwiki links from other pages than the + starting page.
- -back only work on pages that have no backlink from any other - language; if a backlink is found, all work on the page - will be halted. (note: without ending colon) + .. warning:: Should be used very sparingly, only when + you are sure you have first gotten the interwiki + links on the starting page exactly right.
-The following arguments are only important for users who have accounts for -multiple languages, and specify on which sites the bot should modify pages: +-hintsareright Do not follow interwiki links to sites for which hints + on existing pages are given. Note that, hints given + interactively, via the -askhint command line option, are + only effective once they have been entered, thus + interwiki links on the starting page are followed + regardess of hints given when prompted.
- -localonly only work on the local wiki, not on other wikis in the - family I have a login at. (note: without ending colon) + .. caution:: Should be used with care!
- -limittwo only update two pages - one in the local wiki (if logged-in) - and one in the top available one. - For example, if the local page has links to de and fr, - this option will make sure that only the local site and - the de: (larger) sites are updated. This option is useful - to quickly set two way links without updating all of the - wiki families sites. - (note: without ending colon) +-back Only work on pages that have no backlink from any other + language; if a backlink is found, all work on the page + will be halted.
- -whenneeded works like limittwo, but other languages are changed in the - following cases: +The following arguments are only important for users who have accounts +for multiple languages, and specify on which sites the bot should modify +pages:
- * If there are no interwiki links at all on the page - * If an interwiki link must be removed - * If an interwiki link must be changed and there has been - a conflict for this page +-localonly Only work on the local wiki, not on other wikis in the + family I have a login at.
- Optionally, -whenneeded can be given an additional number - (for example -whenneeded:3), in which case other languages - will be changed if there are that number or more links to - change or add. (note: without ending colon) +-limittwo Only update two pages - one in the local wiki (if + logged-in) and one in the top available one. For example, + if the local page has links to de and fr, this option + will make sure that only the local site and the de: + (larger) sites are updated. This option is useful to + quickly set two way links without updating all of the + wiki families sites.
-The following arguments influence how many pages the bot works on at once: +-whenneeded Works like ``-limittwo``, but other languages are + changed in the following cases:
- -array: The number of pages the bot tries to be working on at once. - If the number of pages loaded is lower than this number, - a new set of pages is loaded from the starting wiki. The - default is 100, but can be changed in the config variable - interwiki_min_subjects + * If there are no interwiki links at all on the page + * If an interwiki link must be removed + * If an interwiki link must be changed and there has + been a conflict for this page
- -query: The maximum number of pages that the bot will load at once. - Default value is 50. + Optionally, ``-whenneeded`` can be given an additional + number (for example ``-whenneeded:3``), in which case + other languages will be changed if there are that number + or more links to change or add. + +The following arguments influence how many pages the bot works on at +once: + +-array: The number of pages the bot tries to be working on at + once. If the number of pages loaded is lower than this + number, a new set of pages is loaded from the starting + wiki. The default is 100, but can be changed in the + config variable ``interwiki_min_subjects``. + +-query: The maximum number of pages that the bot will load at + once. Default value is 50.
Some configuration option can be used to change the working of this bot:
- interwiki_min_subjects: the minimum amount of subjects that should be - processed at the same time. +*interwiki_min_subjects* + the minimum amount of subjects that should be processed at the same + time.
- interwiki_backlink: if set to True, all problems in foreign wikis will - be reported +*interwiki_backlink* + if set to True, all problems in foreign wikis will be reported
- interwiki_shownew: should interwiki.py display every new link it discovers? +*interwiki_shownew* + should interwiki.py display every new link it discovers?
- interwiki_graph: output a graph PNG file on conflicts? You need pydot for - this: https://pypi.org/project/pydot/ +*interwiki_graph* + output a graph PNG file on conflicts? You need pydot for this: + https://pypi.org/project/pydot/
- interwiki_graph_format: the file format for interwiki graphs +*interwiki_graph_format* + the file format for interwiki graphs
- without_interwiki: save file with local articles without interwikis +*without_interwiki* + save file with local articles without interwikis
All these options can be changed through the user configuration file.
-If interwiki.py is terminated before it is finished, it will write a dump file -to the interwiki-dumps subdirectory. The program will read it if invoked with -the "-restore" or "-continue" option, and finish all the subjects in that list. -After finishing the dump file will be deleted. To run the interwiki-bot on all -pages on a language, run it with option "-start:!", and if it takes so long -that you have to break it off, use "-continue" next time. - +If this script is terminated before it is finished, it will write a dump +file to the interwiki-dumps subdirectory. The program will read it if +invoked with the ``-restore`` or ``-continue`` option, and finish all +the subjects in that list. After finishing the dump file will be deleted. +To run the script on all pages on a language, run it with option +``-start:!``, and if it takes so long that you have to break it off, use +``-continue`` next time. """ # # (C) Pywikibot team, 2003-2024 diff --git a/scripts/interwikidata.py b/scripts/interwikidata.py index 1af5d86..018c606 100755 --- a/scripts/interwikidata.py +++ b/scripts/interwikidata.py @@ -1,32 +1,33 @@ #!/usr/bin/env python3 -""" -Script to handle interwiki links based on Wikibase. +"""Script to handle interwiki links based on Wikibase.
-This script connects pages to Wikibase items using language links on the page. -If multiple language links are present, and they are connected to different -items, the bot skips. After connecting the page to an item, language links -can be removed from the page. +This script connects pages to Wikibase items using language links on the +page. If multiple language links are present, and they are connected to +different items, the bot skips. After connecting the page to an item, +language links can be removed from the page.
-These command line parameters can be used to specify which pages to work on: +These command line parameters can be used to specify which pages to work +on:
¶ms;
Furthermore, the following command line parameters are supported:
--always If used, the bot won't ask if it should add the specified - text +-always If used, the bot won't ask if it should add the specified + text.
--clean Clean pages. +-clean Clean pages.
--create Create items. +-create Create items.
--merge Merge items. +-merge Merge items.
--summary: Use your own edit summary for cleaning the page. +-summary: [str] Use your own edit summary for cleaning the page.
-.. note:: This script is a - :py:obj:`ConfigParserBot <bot.ConfigParserBot>`. All options - can be set within a settings file which is scripts.ini by default. + +.. note:: This script is a :class:`ConfigParserBot <bot.ConfigParserBot>`. + All options can be set within a settings file which is scripts.ini by + default. """
# (C) Pywikibot team, 2015-2024 diff --git a/scripts/listpages.py b/scripts/listpages.py index 0ae87e6..64688ff 100755 --- a/scripts/listpages.py +++ b/scripts/listpages.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -r""" -Print a list of pages, as defined by page generator parameters. +r"""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. diff --git a/scripts/movepages.py b/scripts/movepages.py index 1b2940a..266e369 100755 --- a/scripts/movepages.py +++ b/scripts/movepages.py @@ -1,39 +1,42 @@ #!/usr/bin/env python3 -""" -This script can move pages. +"""This script can move pages.
-These command line parameters can be used to specify which pages to work on: +These command line parameters can be used to specify which pages to work +on:
¶ms;
Furthermore, the following command line parameters are supported:
--from and -to The page to move from and the page to move to. +-from The page to move from.
--noredirect Leave no redirect behind. +-to The page to move to.
--notalkpage Do not move this page's talk page (if it exists) +-noredirect Leave no redirect behind.
--nosubpages Do not move subpages +-notalkpage Do not move this page's talk page (if it exists)
--prefix Move pages by adding a namespace prefix to the names of the - pages. (Will remove the old namespace prefix if any) - Argument can also be given as "-prefix:namespace:". +-nosubpages Do not move subpages
--always Don't prompt to make changes, just do them. +-prefix Move pages by adding a namespace prefix to the names of + the pages. (Will remove the old namespace prefix if any) + Argument can also be given as ``-prefix:namespace:``.
--skipredirects Skip redirect pages (Warning: increases server load) +-always Don't prompt to make changes, just do them.
--summary Prompt for a custom summary, bypassing the predefined message - texts. Argument can also be given as "-summary:XYZ". +-skipredirects Skip redirect pages (Warning: increases server load)
--pairsfile Read pairs of file names from a file. The file must be in a - format [[frompage]] [[topage]] [[frompage]] [[topage]] ... - Argument can also be given as "-pairsfile:filename" +-summary [str] Prompt for a custom summary, bypassing the + predefined message texts. Argument can also be given as + ``-summary:XYZ``.
+-pairsfile Read pairs of file names from a file. The file must be + in a format [[frompage]] [[topage]] [[frompage]] + [[topage]] ... Argument can also be given as + ``-pairsfile:filename`` """ # -# (C) Pywikibot team, 2006-2022 +# (C) Pywikibot team, 2006-2024 # # Distributed under the terms of the MIT license. # diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py index c5ef416..5cba3d1 100755 --- a/scripts/pagefromfile.py +++ b/scripts/pagefromfile.py @@ -1,63 +1,74 @@ #!/usr/bin/env python3 -r""" -Bot to upload pages from a text file. +r"""Bot to upload pages from a text file.
-This bot takes its input from the UTF-8 text file that contains -a number of pages to be put on the wiki. The pages should all have -the same beginning and ending text (which may not overlap). -The beginning and ending text is not uploaded with the page content -by default. +This bot takes its input from the UTF-8 text file that contains a number +of pages to be put on the wiki. The pages should all have the same +beginning and ending text (which may not overlap). The beginning and +ending text is not uploaded with the page content by default.
-As a pagename is by default taken the first text block -from the page content marked in bold (wrapped between ''' and '''). -If you expect the page title not to be present in the text -or marked by different markers, use -titlestart, -titleend, -and -notitle parameters. +As a pagename is by default taken the first text block from the page +content marked in bold (wrapped between ''' and '''). If you expect the +page title not to be present in the text or marked by different markers, +use -titlestart, -titleend, and -notitle parameters.
Specific arguments:
--file:xxx The filename we are getting our material from, - the default value is "dict.txt" --begin:xxx The text that marks the beginning of a page, - the default value is "{{-start-}}" --end:xxx The text that marks the end of the page, - the default value is "{{-stop-}}" --include Include the beginning and end markers to the page --textonly Text is given without markers. Only one page text is given. - -begin and -end options are ignored. --titlestart:xxx The text used in place of ''' for identifying - the beginning of a page title --titleend:xxx The text used in place of ''' for identifying - the end of the page title --notitle Do not include the page title, including titlestart - and titleend, to the page. Can be used to specify unique - page title above the page content --title:xxx The page title is given directly. Ignores -titlestart, - -titleend and -notitle options --nocontent:xxx If the existing page contains specified statement, - the page is skipped from editing --noredirect Do not upload on redirect pages --summary:xxx The text used as an edit summary for the upload. - If the page exists, standard messages for prepending, - appending, or replacement are appended after it --autosummary Use MediaWiki's autosummary when creating a new page, - overrides -summary --minor Set the minor edit flag on page edits --showdiff Show difference between current page and page to upload, - also forces the bot to ask for confirmation - on every edit +-file:xxx The filename we are getting our material from, + the default value is "dict.txt"
-If the page to be uploaded already exists, it is skipped by default. -But you can override this behavior if you want to: +-begin:xxx The text that marks the beginning of a page, + the default value is "{{-start-}}"
--appendtop Add the text to the top of the existing page --appendbottom Add the text to the bottom of the existing page --force Overwrite the existing page +-end:xxx The text that marks the end of the page, + the default value is "{{-stop-}}"
-It is possible to define a separator after the 'append' modes which -is added between the existing and the new text. For example -a parameter -appendtop:foo would add 'foo' between them. A new line -can be added between them by specifying '\n' as a value. +-include Include the beginning and end markers to the page + +-textonly Text is given without markers. Only one page text is + given. ``-begin`` and ``-end`` options are ignored. + +-titlestart:xxx The text used in place of ''' for identifying + the beginning of a page title + +-titleend:xxx The text used in place of ''' for identifying + the end of the page title + +-notitle Do not include the page title, including titlestart + and titleend, to the page. Can be used to specify + unique page title above the page content + +-title:xxx The page title is given directly. Ignores ``-titlestart``, + -titleend and -notitle options + +-nocontent:xxx If the existing page contains specified statement, + the page is skipped from editing + +-noredirect Do not upload on redirect pages + +-summary:xxx The text used as an edit summary for the upload. + If the page exists, standard messages for prepending, + appending, or replacement are appended after it. + +-autosummary Use MediaWiki's autosummary when creating a new page, + overrides ``-summary``- + +-minor Set the minor edit flag on page edits + +-showdiff Show difference between current page and page to upload, + also forces the bot to ask for confirmation + on every edit. + +If the page to be uploaded already exists, it is skipped by default. But +you can override this behavior if you want to: + +-appendtop Add the text to the top of the existing page +-appendbottom Add the text to the bottom of the existing page +-force Overwrite the existing page + +It is possible to define a separator after the 'append' modes which is +added between the existing and the new text. For example a parameter +``-appendtop:foo`` would add 'foo' between them. A new line can be added +between them by specifying '\n' as a value. """ # # (C) Pywikibot team, 2004-2024 diff --git a/scripts/replicate_wiki.py b/scripts/replicate_wiki.py index 9c8a523..4f11c20 100755 --- a/scripts/replicate_wiki.py +++ b/scripts/replicate_wiki.py @@ -1,28 +1,32 @@ #!/usr/bin/env python3 -""" -This bot replicates pages in a wiki to a second wiki within one family. +"""This bot replicates pages in a wiki to a second wiki within one family.
Example:
+:: + python pwb.py replicate_wiki [-r] -ns 10 -family:wikipedia -o nl li fy
-or: +or::
python pwb.py replicate_wiki [-r] -ns 10 -family:wikipedia -lang:nl li fy
-to copy all templates from nlwiki to liwiki and fywiki. It will show which -pages have to be changed if -r is not present, and will only actually write -pages if -r /is/ present. +to copy all templates from nlwiki to liwiki and fywiki. It will show +which pages have to be changed if -r is not present, and will only +actually write pages if -r is present.
You can add replicate_replace to your user config file (user-config.py), which has the following format:
- replicate_replace = { - 'wikipedia:li': {'Hoofdpagina': 'Veurblaad'} - } +.. code-block:: python
-to replace all occurrences of 'Hoofdpagina' with 'Veurblaad' when writing to -liwiki. Note that this does not take the origin wiki into account. + replicate_replace = { + 'wikipedia:li': {'Hoofdpagina': 'Veurblaad'} + } + +to replace all occurrences of 'Hoofdpagina' with 'Veurblaad' when +writing to liwiki. Note that this does not take the origin wiki into +account.
The following parameters are supported:
@@ -35,10 +39,10 @@
-dns, --dest-namespace destination namespace (if different)
- destination_wiki destination wiki(s) +destination_wiki destination wiki(s) """ # -# (C) Pywikibot team, 2012-2023 +# (C) Pywikibot team, 2012-2024 # # Distributed under the terms of the MIT license. # diff --git a/scripts/template.py b/scripts/template.py index 1e57e89..d76108a 100755 --- a/scripts/template.py +++ b/scripts/template.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -r""" -Very simple script to replace a template with another one. +r"""Very simple script to replace a template with another one.
It also converts the old MediaWiki boilerplate format to the new format.
@@ -9,94 +8,94 @@ python pwb.py template [-remove] [xml[:filename]] oldTemplate \ [newTemplate]
-Specify the template on the command line. The program will pick up the template -page, and look for all pages using it. It will then automatically loop over -them, and replace the template. +Specify the template on the command line. The program will pick up the +template page, and look for all pages using it. It will then +automatically loop over them, and replace the template.
Command line options:
-remove Remove every occurrence of the template from every article
-subst Resolves the template by putting its text directly into the - article. This is done by changing {{...}} or {{msg:...}} into - {{subst:...}}. If you want to use safesubst, you - can do -subst:safe. Substitution is not available inside + article. This is done by changing {{...}} or {{msg:...}} + into {{subst:...}}. If you want to use safesubst, you can + do -subst:safe. Substitution is not available inside <ref>...</ref>, <gallery>...</gallery>, <poem>...</poem> and <pagelist ... /> tags.
-assubst Replaces the first argument as old template with the second - argument as new template but substitutes it like -subst does. - Using both options -remove and -subst in the same command line has - the same effect. + argument as new template but substitutes it like ``-subst`` + does. Using both options -remove and -subst in the same + command line has the same effect.
-xml retrieve information from a local dump (https://dumps.wikimedia.org). If this argument isn't given, - info will be loaded from the maintenance page of the live wiki. - argument can also be given as "-xml:filename.xml". + info will be loaded from the maintenance page of the live + wiki. argument can also be given as "-xml:filename.xml".
-onlyuser: Only process pages edited by a given user
-skipuser: Only process pages not edited by a given user
--timestamp: (With -onlyuser or -skipuser). Only check for a user where his - edit is not older than the given timestamp. Timestamp must be - written in MediaWiki timestamp format which is "%Y%m%d%H%M%S". - If this parameter is missed, all edits are checked but this is - restricted to the last 100 edits. +-timestamp: (With -onlyuser or -skipuser). Only check for a user where + his edit is not older than the given timestamp. Timestamp + must be written in MediaWiki timestamp format which is + "%Y%m%d%H%M%S". If this parameter is missed, all edits are + checked but this is restricted to the last 100 edits.
--summary: Lets you pick a custom edit summary. Use quotes if edit summary - contains spaces. +-summary: [str] Lets you pick a custom edit summary. Use quotes if + edit summary contains spaces.
-always Don't bother asking to confirm any of the changes, Just Do It.
--addcat: Appends the given category to every page that is edited. This is - useful when a category is being broken out from a template - parameter or when templates are being upmerged but more - information must be preserved. +-addcat: Appends the given category to every page that is edited. + This is useful when a category is being broken out from a + template parameter or when templates are being upmerged but + more information must be preserved.
-other: First argument is the old template name, second one is the new - name. - If you want to address a template which has spaces, put quotation - marks around it, or use underscores. +other: First argument is the old template name, second one is the + new name. If you want to address a template which has + spaces, put quotation marks around it, or use underscores.
Examples --------
-If you have a template called [[Template:Cities in Washington]] and want to -change it to [[Template:Cities in Washington state]], start: +If you have a template called [[Template:Cities in Washington]] and want +to change it to [[Template:Cities in Washington state]], start:
python pwb.py template "Cities in Washington" "Cities in Washington state"
Move the page [[Template:Cities in Washington]] manually afterwards.
-If you have a template called [[Template:test]] and want to substitute it only -on pages in the User: and User talk: namespaces, do: +If you have a template called [[Template:test]] and want to substitute +it only on pages in the User: and User talk: namespaces, do:
python pwb.py template test -subst -namespace:2 -namespace:3
.. note:: -namespace: is a global Pywikibot parameter
-This next example substitutes the template lived with a supplied edit summary. -It only performs substitutions in main article namespace and doesn't prompt to -start replacing. Note that -putthrottle: is a global Pywikibot parameter: +This next example substitutes the template lived with a supplied edit +summary. It only performs substitutions in main article namespace and +doesn't prompt to start replacing. Note that -putthrottle: is a global +Pywikibot parameter:
python pwb.py template -putthrottle:30 -namespace:0 lived -subst -always \ --summary:"BOT: Substituting {{lived}}, see [[WP:SUBST]]." + -summary:"BOT: Substituting {{lived}}, see [[WP:SUBST]]."
-This next example removes the templates {{cfr}}, {{cfru}}, and {{cfr-speedy}} -from five category pages as given: +This next example removes the templates {{cfr}}, {{cfru}}, and +{{cfr-speedy}} from five category pages as given:
python pwb.py template cfr cfru cfr-speedy -remove -always \ --page:"Category:Mountain monuments and memorials" \ --page:"Category:Indian family names" \ --page:"Category:Tennis tournaments in Belgium" \ --page:"Category:Tennis tournaments in Germany" \ --page:"Category:Episcopal cathedrals in the United States" \ --summary:"Removing Cfd templates from category pages that survived." + -page:"Category:Mountain monuments and memorials" \ + -page:"Category:Indian family names" \ + -page:"Category:Tennis tournaments in Belgium" \ + -page:"Category:Tennis tournaments in Germany" \ + -page:"Category:Episcopal cathedrals in the United States" \ + -summary:"Removing Cfd templates from category pages that survived."
-This next example substitutes templates test1, test2, and space test on all -user talk pages (namespace #3): +This next example substitutes templates test1, test2, and space test on +all user talk pages (namespace #3):
python pwb.py template test1 test2 "space test" -subst -ns:3 -always """ diff --git a/scripts/touch.py b/scripts/touch.py index ae4974b..9004e63 100755 --- a/scripts/touch.py +++ b/scripts/touch.py @@ -1,24 +1,24 @@ #!/usr/bin/env python3 -""" -This bot goes over multiple pages of a wiki, and edits them without changes. +"""This bot goes over multiple pages of a wiki, and edits them without changes.
This is for example used to get category links in templates working.
Command-line arguments:
--purge Purge the page instead of touching it +-purge Purge the page instead of touching it
-Touch mode (default): +*Touch* mode (default):
--botflag Force botflag in case of edits with changes. +-botflag Force botflag in case of edits with changes.
-Purge mode: +*Purge* mode:
--converttitles Convert titles to other variants if necessary --forcelinkupdate Update the links tables --forcerecursivelinkupdate Update the links table, and update the links tables - for any page that uses this page as a template --redirects Automatically resolve redirects +-converttitles Convert titles to other variants if necessary +-forcelinkupdate Update the links tables +-forcerecursivelinkupdate + Update the links table, and update the links tables + for any page that uses this page as a template +-redirects Automatically resolve redirects
¶ms; """ diff --git a/scripts/unusedfiles.py b/scripts/unusedfiles.py index a1bff9e..82feda7 100755 --- a/scripts/unusedfiles.py +++ b/scripts/unusedfiles.py @@ -6,6 +6,7 @@ -limit:n [int] Specify number of pages to work on where *n* is the maximum number of articles to work on. If not used, all pages are processe. + -always Don't be asked every time.
This script is a :class:`ConfigParserBot <bot.ConfigParserBot>`. The diff --git a/scripts/upload.py b/scripts/upload.py index 10152bd..07d9aec 100755 --- a/scripts/upload.py +++ b/scripts/upload.py @@ -5,9 +5,9 @@
-keep Keep the filename as is
--filename: Target filename without the namespace prefix +-filename: [str] Target filename without the namespace prefix
--prefix: Add specified prefix to every filename. +-prefix: [str] Add specified prefix to every filename.
-noverify Do not ask for verification of the upload description if one is given @@ -43,9 +43,10 @@ -recursive When the filename is a directory it also uploads the files from the subdirectories.
--summary: Pick a custom edit summary for the bot. +-summary: [str] Pick a custom edit summary for the bot.
--descfile: Specify a filename where the description is stored +-descfile: [str] Specify a filename where the description is stored +
It is possible to combine ``-abortonwarn`` and ``-ignorewarn`` so that if the specific warning is given it won't apply the general one but more diff --git a/scripts/watchlist.py b/scripts/watchlist.py index 8a15ec5..f6c1df6 100755 --- a/scripts/watchlist.py +++ b/scripts/watchlist.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -""" -Allows access to the bot account's watchlist. +"""Allows access to the bot account's watchlist.
The watchlist can be updated manually by running this script.
@@ -10,14 +9,17 @@
Command line options:
--all Reloads watchlists for all wikis where a watchlist is already - present --count Count only the total number of pages on the watchlist of the - account the bot has access to --count:all Count only the total number of pages on all wikis watchlists - that the bot is connected to. --new Load watchlists for all wikis where accounts is set in user - config file +-all Reloads watchlists for all wikis where a watchlist is + already present. + +-count Count only the total number of pages on the watchlist of the + account the bot has access to. + +-count:all Count only the total number of pages on all wikis watchlists + that the bot is connected to. + +-new Load watchlists for all wikis where accounts is set in user + config file
.. versionchanged:: 7.7 watchlist is retrieved in parallel tasks. diff --git a/scripts/welcome.py b/scripts/welcome.py index 341e6e6..18a4be1 100755 --- a/scripts/welcome.py +++ b/scripts/welcome.py @@ -1,159 +1,174 @@ #!/usr/bin/env python3 -""" -Script to welcome new users. +"""Script to welcome new users.
-This script works out of the box for Wikis that have been -defined in the script. +This script works out of the box for Wikis that have been defined in the +script.
-Ensure you have community support before running this bot! +.. important:: + Ensure you have community support before running this bot!
Everything that needs customisation to support additional projects is indicated by comments.
-Description of basic functionality +**Description of basic functionality**
- * Request a list of new users every period (default: 3600 seconds) - You can choose to break the script after the first check (see arguments) - * Check if new user has passed a threshold for a number of edits - (default: 1 edit) - * Optional: check username for bad words in the username or if the username - consists solely of numbers; log this somewhere on the wiki (default: False) - Update: Added a whitelist (explanation below). - * If user has made enough edits (it can be also 0), check if user has an empty - talk page - * If user has an empty talk page, add a welcome message. - * Optional: Once the set number of users have been welcomed, add this to the - configured log page, one for each day (default: True) - * If no log page exists, create a header for the log page first. +* Request a list of new users every period (default: 3600 seconds). You + can choose to break the script after the first check (see arguments) +* Check if new user has passed a threshold for a number of edits + (default: 1 edit) +* Optional: check username for bad words in the username or if the + username consists solely of numbers; log this somewhere on the wiki + (default: False). A whitelist is also implemented (explanation below). +* If user has made enough edits (it can be also 0), check if user has an + empty talk page +* If user has an empty talk page, add a welcome message. +* Optional: Once the set number of users have been welcomed, add this to + the configured log page, one for each day (default: True) +* If no log page exists, create a header for the log page first.
-This script (by default not yet implemented) uses two templates that need to -be on the local wiki +This script uses two templates that need to be on the local wiki:
-* {{WLE}}: contains mark up code for log entries (just copy it from Commons) -* {{welcome}}: contains the information for new users +.. role:: tmpl(code) + :language: wikitext + +* :tmpl:`{{WLE}}`: contains mark up code for log entries (just copy it + from Commons) +* :tmpl:`{{welcome}}`: contains the information for new users
This script understands the following command-line arguments:
- -edit[:#] Define how many edits a new user needs to be welcomed - (default: 1, max: 50) +-edit[:#] [int] Define how many edits a new user needs to be + welcomed (default: 1, max: 50)
- -time[:#] Define how many seconds the bot sleeps before restart - (default: 3600) +-time[:#] Define how many seconds the bot sleeps before restart + (default: 3600)
- -break Use it if you don't want that the Bot restart at the end - (it will break) (default: False) +-break Use it if you don't want that the Bot restart at the + end (it will break) (default: False)
- -nlog Use this parameter if you do not want the bot to log all - welcomed users (default: False) +-nlog Use this parameter if you do not want the bot to log + all welcomed users (default: False)
- -limit[:#] Use this parameter to define how may users should be - checked (default:50) +-limit[:#] [int] Use this parameter to define how may users should + be checked (default:50)
- -offset[:TIME] Skip the latest new users (those newer than TIME) - to give interactive users a chance to welcome the - new users (default: now) - Timezone is the server timezone, GMT for Wikimedia - TIME format : yyyymmddhhmmss or yyyymmdd +-offset[:TIME] Skip the latest new users (those newer than TIME) to + give interactive users a chance to welcome the new + users (default: now) Timezone is the server timezone, + GMT for Wikimedia TIME format : yyyymmddhhmmss or yyyymmdd
- -timeoffset[:#] Skip the latest new users, accounts newer than - # minutes +-timeoffset[:#] Skip the latest new users, accounts newer than # + minutes
- -numberlog[:#] The number of users to welcome before refreshing the - welcome log (default: 4) +-numberlog[:#] The number of users to welcome before refreshing the + welcome log (default: 4)
- -filter Enable the username checks for bad names (default: False) +-filter Enable the username checks for bad names (default: + False)
- -ask Use this parameter if you want to confirm each possible - bad username (default: False) +-ask Use this parameter if you want to confirm each possible + bad username (default: False)
- -random Use a random signature, taking the signatures from a wiki - page (for instruction, see below). +-random Use a random signature, taking the signatures from a + wiki page (for instruction, see below).
- -file[:#] Use a file instead of a wikipage to take the random sign. - If you use this parameter, you don't need to use -random. +-file[:#] Use a file instead of a wikipage to take the random + sign. If you use this parameter, you don't need to use + ``-random``.
- -sign Use one signature from command line instead of the default +-sign Use one signature from command line instead of the + default
- -savedata This feature saves the random signature index to allow to - continue to welcome with the last signature used. +-savedata This feature saves the random signature index to allow + to continue to welcome with the last signature used.
- -sul Welcome the auto-created users (default: False) +-sul Welcome the auto-created users (default: False)
- -quiet Prevents users without contributions are displayed +-quiet Prevents users without contributions are displayed
-********************************* GUIDE *********************************** +GUIDE +-----
-*** Report, Bad and white list guide: *** +**Report, Bad and white list guide**
-1) Set in the code which page it will use to load the badword, the - whitelist and the report -2) In these page you have to add a "tuple" with the names that you want to - add in the two list. For example: ('cat', 'mouse', 'dog') - You can write also other text in the page, it will work without problem. -3) What will do the two pages? Well, the Bot will check if a badword is in - the username and set the "warning" as True. Then the Bot check if a word - of the whitelist is in the username. If yes it remove the word and - recheck in the bad word list to see if there are other badword in the - username. - Example +1) Set in the code which page it will use to load the badword, the + whitelist and the report.
- * dio is a badword - * Claudio is a normal name - * The username is "Claudio90 fuck!" - * The Bot finds dio and sets "warning" - * The Bot finds Claudio and sets "ok" - * The Bot finds fuck at the end and sets "warning" - * Result: The username is reported. -4) When a user is reported you have to check him and do +2) In these page you have to add a "tuple" with the names that you want + to add in the two list. For example: ('cat', 'mouse', 'dog') You can + write also other text in the page, it will work without problem.
- * If he's ok, put the {{welcome}} - * If he's not, block him - * You can decide to put a "you are blocked, change another username" - template or not. - * Delete the username from the page. +3) What will do the two pages? Well, the Bot will check if a badword is + in the username and set the "warning" as True. Then the Bot check if + a word of the whitelist is in the username. If yes it remove the word + and recheck in the bad word list to see if there are other badword in + the username.
- IMPORTANT : The Bot check the user in this order + Example:
- * Search if he has a talkpage (if yes, skip) - * Search if he's blocked, if yes he will be skipped - * Search if he's in the report page, if yes he will be skipped - * If no, he will be reported. + * dio is a badword + * Claudio is a normal name + * The username is "Claudio90 fuck!" + * The Bot finds dio and sets "warning" + * The Bot finds Claudio and sets "ok" + * The Bot finds fuck at the end and sets "warning" + * Result: The username is reported.
-*** Random signature guide: *** +4) When a user is reported you have to check him and do
-Some welcomed users will answer to the one who has signed the welcome message. -When you welcome many new users, you might be overwhelmed with such answers. -Therefore you can define usernames of other users who are willing to receive -some of these messages from newbies. + * If he's ok, put the :tmpl:`{{welcome}}` + * If he's not, block him + * You can decide to put a "you are blocked, change another username" + template or not. + * Delete the username from the page. + + .. important:: + + The Bot check the user in this order + + * Search if he has a talkpage (if yes, skip) + * Search if he's blocked, if yes he will be skipped + * Search if he's in the report page, if yes he will be skipped + * If no, he will be reported. + +**Random signature guide** + +Some welcomed users will answer to the one who has signed the welcome +message. When you welcome many new users, you might be overwhelmed with +such answers. Therefore you can define usernames of other users who are +willing to receive some of these messages from newbies.
1) Set the page that the bot will load -2) Add the signatures in this way: +2) Add the signature lines in this way:
- *<SPACE>SIGNATURE - <NEW LINE> + * SIGNATURE
-Example of signatures: + Example of signatures:
- <pre> - * [[User:Filnik|Filnik]] - * [[User:Rock|Rock]] - </pre> + .. code:: wikitext
-.. note:: The white space and <pre></pre> aren't required but I suggest - you to use them. + <pre> + * [[User:Filnik|Filnik]] + * [[User:Rock|Rock]] + </pre>
-******************************** Badwords ********************************** + .. note:: The white space after asterisk and ``<pre></pre>`` aren't + required but it is recommended you to use them. + +Badwords +--------
The list of Badwords of the code is opened. If you think that a word is -international and it must be blocked in all the projects feel free to add it. -If also you think that a word isn't so international, feel free to delete it. +international and it must be blocked in all the projects feel free to +add it. If also you think that a word isn't so international, feel free +to delete it.
-However, there is a dinamic-wikipage to load that badwords of your project or -you can add them directly in the source code that you are using without adding -or deleting. +However, there is a dinamic-wikipage to load that badwords of your +project or you can add them directly in the source code that you are +using without adding or deleting.
-Some words, like "Administrator" or "Dio" (God in italian) or "Jimbo" aren't -badwords at all but can be used for some bad-nickname. +Some words, like "Administrator" or "Dio" (God in italian) or "Jimbo" +aren't badwords at all but can be used for some bad-nickname. """ # # (C) Pywikibot team, 2006-2024
pywikibot-commits@lists.wikimedia.org