Operator: Drilnoth
Automatic or Manually assisted: Manually assisted (at first), and automatic once I'm more fully sure of pywikipediabot's abilities.
Programming language(s): Python, via Pywikipediabot.
Source code available: Simple regex can be made available, but mostly just standard pywikipedia.
Function overview: Replace templates and template parameters on request.
Links to relevant discussions (where appropriate): I'll check for consensus for an individual task before running it, unless it seems very uncontroversial (as with the example I put forth below).
Edit period(s): When there's something to be done and I have the time to work on it.
Estimated number of pages affected: Varies by task. Example below would be about 375 pages.
Exclusion compliant (Y/N): Yes (I think; pywikipediabot is exclusion by default, right?)
Already has a bot flag (Y/N): Y
Function details: Details of use have been modified; see discussion below Replaces templates and template parameters on request or to clear out uncontroversial backlogs; primarily in the area of WikiProject banners, but also other things (e.g., if all uses of a template need to be renamed because another template is being moved to the previous one's location). Individual tasks which don't seem really uncontroversial (for example, fixing up Category:Dungeons & Dragons articles in need of work force banner consolidation) will be discussed with appropriate WikiProject and/or at the village pump. If a more specific task description is needed for approval, I'd like the workforce banner consolidation approved as the main task, and other WikiProject banner work after that. This is purposefully a simple task; I haven't used pywikipediabot before and don't want to do anything too complicated. Sample edit in bot's userspace: [1]. – Drilnoth ( T • C • L) 17:41, 1 December 2009 (UTC) reply
I'm not willing to say yes beforehand to doing tasks where it requires the bot operator to decide community consensus. There was a lengthy discussion about community consensus because of tasks that appeared to one BAG member to have community consensus when they did not. If the template or a parameter has been deprecated by the community, then having a bot ready to change the templates is fine, but not blanket preapproval, imo. -- IP69.226.103.13 ( talk) 20:55, 1 December 2009 (UTC) reply
It seems you're planning to use regular expressions for the template replacements. How do you intend to handle nested templates, or templates where something nontrivial needs to be done with the named parameters? Anomie ⚔ 23:22, 1 December 2009 (UTC) reply
(r'\{\{ProjectGreyhawk[^\}]*\}\}\n?', ''),
(r'(\{\{D\&D[^\}]*)(\}\}\n?)', r'\1|Greyhawk=yes\2'),
(r'\{\{ProjectGreyhawk[^\}]*\}\}\n?', ''),
(r'(\{\{D\&D[^\}\{]*)((?:\{\{[^\}\{]*\}\}[^\}\{]*)*)?(\}\}\n?)', r'\1\2|Greyhawk=yes\3'),
{{
SegaProject}}
with {{
WikiProject Video games|tf=Sega}}
(or tf2=Sega if tf=X is already present, or tf3=Sega if both tf=X and tf2=X are already present). Also, if the {{
SegaProject}}
included "tf=Sonic", add tf=Sonic (or tf2 or tf3) to the WPVG banner as well.{{
WP Shinto}}
with {{
WikiProject Japan|shinto=yes}}
, and the same for {{
Jmyth}}
with myth=yes, {{
Gaijin tarento}}
with gaijin=yes, and {{
Project Owarai}} with owarai=yes. Also, change "tf=X" or "tf2=X" or "tf3=X" in {{
WikiProject Japan}}
to "X=yes" for 15 possible values of X, 7 of which need X slightly changed in the process. And do it all in 1 edit per page, to avoid excessive watchlist traffic.{{
SFBAProject}}
with {{
WikiProject California|sfba=yes}}
, also copying any "importance" from the former into "sfba-importance" in the latter; same for {{
WikiProject Los Angeles}}
and "la=yes" and la-importance; automatically do "class=stub" if the page contains a stub template and no class is set; and set the importance based on various categories (e.g. low for
Category:Unincorporated communities in California, mid for
Category:California ranchos, etc) or the population listed in {{
Infobox settlement}} (there are several population fields to check for). And do it all in one edit per page.(undent), okay, some sample code:
Once again, I haven't actually tested this code, so no guarantees that it is correct. Before testing any new regex, I check edits manually to make sure that there aren't any bugs.
Taking into account your comments on the basic banner-removal-and-parameter-addition, here's a better proposal. I don't think that uber-nested templates need to be worried about too much in project banners, but one could manually add in more repetition of the subtemplate-capturing code if it seems needed. As it is, it just wouldn't match templates which are uber-nested; it shouldn't screw up the page, just not edit it.
(r'\{\{(?:(?:Wiki)?Project\s*)Greyhawk[^\}]*\}\}\n?', ''), # Remove ProjectGreyhawk template (r'\|\s*Greyhawk\s*=\s*yes\s*([\|\}])', r'\1'), # Remove |Greyhawk=yes parameter if it appears in a template # Following split onto multiple lines for readability; it wouldn't be in the final code. (r'(?:\{\{\s*(?:(?:(?:Wiki)?Project\s*|WP)?D\&D|WPDND|Dungeons\s*\&\s*Dragons)\s*) # Detect template opening and banner name, but do NOT capture them; will be replaced regardless of content ((?=\}\|)[^\}\{]* # Ensure that the template name doesn't continue further, and detect everything up to the beginning or end of a template (to be captured in \1 at the end of the next step). (?:\{\{[^\}\{]*\}\}[^\}\{]*)*)? # Accounts for any templates which are nested one-level deep and captures them and all content continuing to the end of the banner itself in \1. (\}\}\n?)', # Captures banner ending and newline, if any, in \1. r'\{\{D&D\1|Greyhawk=yes\2'), # Actual replacement adds parameter and converts template name to the non-redirect form # Last regex in single-line form (r'(?:\{\{\s*(?:(?:(?:Wiki)?Project\s*|WP)?D\&D|WPDND|Dungeons\s*\&\s*Dragons)\s*)((?=\}\|)[^\}\{]*(?:\{\{[^\}\{]*\}\}[^\}\{]*)*)?(\}\}\n?)', r'\{\{D&D\1|Greyhawk=yes\2'),
Does not yet account for the possible lack of a D&D banner; I'll need to do a little more Python and regex learning first (adds too mental to-do list). I plan to stay away from the more complicated things like you mention until I'm more confident of my regex abilities; as you said, oversimplifying the regex would be a Bad Thing™. – Drilnoth ( T • C • L) 17:09, 2 December 2009 (UTC) reply
{{
D&D|Greyhawk=yes|foo=yes}}
to {{
D&D|foo=yes|Greyhawk=yes}}
, but otherwise it looks ok. Any particular reason for the adjacent but separate \1 and \2 groups instead of putting them both in \1?