Manual:Pywikibot/clean_sandbox.py
File:Git icon.svg | <translate> Wikimedia [[<tvar|1>Special:MyLanguage/Gerrit</>|Git repository]] has this file:</translate> scripts/clean_sandbox.py |
File:Pywikibot MW gear icon.svg |
<translate> Pywikibot scripts</translate> |
---|
|
· <span style="" title="<translate nowrap> Edit this template</translate>"><translate> e</translate> |
clean_sandbox.py is a simple script that automatically reverts the page Project:Sandbox to a "clean" state, replacing the text on the page with a predefined message. This message is found within the file clean_sandbox.py
within the pywikibot
folder on your computer.
Usage
Using clean_sandbox.py is exceedingly easy. Just type python pwb.py clean_sandbox
If you wish, you can add a couple of arguments to the base instruction:
-hours:# Use this parameter if to make the script repeat itself after # hours. Hours can be defined as a decimal. 0.01 hours are 36 seconds; 0.1 are 6 minutes. -delay:# Use this parameter for a wait time after the last edit was made. If no parameter is given it takes it from hours and limits it between 5 and 15 minutes. The minimum delay time is 5 minutes. -text The text that substitutes in the sandbox, you can use this when you haven't configured clean_sandbox for your wiki. -summary Summary of the edit made by bot.
There isn't much point to running this script manually. Since it only works on one page, you could accomplish the same task just as easily by going into the sandbox page history and undoing to the last point where the page was clean. However, if you keep one python window open on your computer at all times, and you commit it to running this script once every 12 hours with a certain amount of delay, it's then possible to automatically clean your sandbox, regularly and in a way that waits until it appears like no one is using the sandbox. A reasonable command would therefore be:
$ python pwb.py clean_sandbox -hours:12 -delay:15
Config parser
clean sandbox.py is a config parser bot which supports reading options from a scripts.ini
configuration file. That file must contain a section header [clean_sandbox]
and followed by option: value
or option=value
entries of these option given above. Inline comments may be given by a preceeding ';' whereas comments may be start with '#' or ';'. For example:
# clean_sandbox section
[clean_sandbox]
hours: 0.2 ; repeat every 12 minutes
delay=10 ; wait 10 minutes after the last edit
text: {{subst:/Template}} ; The text to be substituted
summary: Bot: Mowed playground ; guess what it means
Options given with the command line will overwrite the config file settings and the config file settings relaces the default values.
Replacement text
By default, clean_sandbox.py
comes with a number of predefined messages in various languages. If you wish to change the message, use the -text
option or use the config parser settings explained above. Otherwise, make note of the template that is being called with the scrupt and make sure that your wiki has a template with exactly that same name. That template should contain a message about the rules or instructions your wiki has for the use of the sandbox page.