Wikia

WoWWiki

MurphBot/Achievementbox

Talk0
102,281pages on
this wiki

< User:MurphBot

This is my Unix shell script for standardising the usage of {{Achievementbox}}. It has a high accuracy rate, but changes should be manually reviewed, as it can get some false-positives. It uses the pywikipediabot replace.py script to do the actual work - this script just provides the configuration in an easily repeatable manner. This was developed on MacOS 10.5.

Disclaimer Edit

I accept no responsibility if you chose to use this script - you do so entirely at your own risk, and you own any damage to your reputation or account status. If you don't understand what it does, you are probably not qualified to use it - there are some quite advanced regular expressions in here, and understanding and debugging them is not for the novice. Documentation is deliberately sparse, it is not intended to be release quality code, or for general use.

Code Edit

#!/bin/sh

python replace.py -transcludes:Achievementbox \
	-namespace:0 \
	-summary:'Standardisation of achievementbox mode, arg, type params, <onlyinclude>' \
	-recursive \
	-regex \
	'(?mi){{Achievementbox\s*\|' \
		'{{Achievementbox\n|mode={{{mode|}}}\n|arg={{{arg|}}}\n|' \
	'(?ms)({{Achievementbox\s*\|mode={{{mode\|}}}\s*\|arg={{{arg\|}}}.*?)\|mode=[^\r\n]*[\r\n]*(?=\|[^}]|}}\s*</onlyinclude>)' '\1' \
	'(?ms)({{Achievementbox\s*\|mode={{{mode\|}}}\s*\|arg={{{arg\|}}}.*?)\|arg=[^\r\n]*[\r\n]*(?=\|[^}]|}}\s*</onlyinclude>)' '\1' \
	'(?m)(?<={{Achievementbox)(.*?)^[ \t]*?\|[ \t]*?(\S)' '\1|\2' \
	'(?m)^\|type=(?!{{{doc\|)\s*([^\r\n]*)' '|type={{{doc|\1}}}' \
	'(?mi)^\|type={{{doc\|General}}}' '|type={{{doc|General}}}' \
	'(?mi)^\|type={{{doc\|Quests?}}}' '|type={{{doc|Quest}}}' \
	'(?mi)^\|type={{{doc\|Exploration}}}' '|type={{{doc|Exploration}}}' \
	'(?mi)^\|type={{{doc\|Player *vs.? *Player}}}' '|type={{{doc|Player vs. Player}}}' \
	'(?mi)^\|type={{{doc\|Dungeons? *(&|and) *Raids?}}}' '|type={{{doc|Dungeons & Raids}}}' \
	'(?mi)^\|type={{{doc\|Professions?}}}' '|type={{{doc|Professions}}}' \
	'(?mi)^\|type={{{doc\|Reputation}}}' '|type={{{doc|Reputation}}}' \
	'(?mi)^\|type={{{doc\|World *Events?}}}' '|type={{{doc|World Events}}}' \
	'(?mi)^\|type={{{doc\|Feats? *of *Strength}}}' '|type={{{doc|Feats of Strength}}}' \
	'(?msi)<onlyinclude>\s*({{Achievementbox(({{(({{.*?}})|.)*?}})|.)*?}})\s*</onlyinclude>' \
		'<onlyinclude>\1</onlyinclude>' \
	'(?msi)(?<!<onlyinclude>)({{Achievementbox(({{(({{.*?}})|.)*?}})|.)*?}})' \
		'<onlyinclude>\1</onlyinclude>' \
	'(?msi)(?<={{Achievementbox)(.*?}}</onlyinclude>)([^\r\n])' '\1\n\2' \
	'(?msi)([^\r\n])(<onlyinclude>{{Achievementbox)' '\1\n\2' \
	'(?msi)(?<={{Achievementbox)(.*?)</?noinclude>' '\1' \
	'(?msi)</?noinclude>(?=.*{{Achievementbox)' '' \

Notes Edit

The -recursive option ensures that multiple instances of a pattern match are replaced (e.g. multiple <noinclude> tags). If the combinations of patterns and replacements causes a loop, pywikipediabot will stop responding. The replacements must eventually be able to run against each article without making any further changes to avoid the potential looping.

Around Wikia's network

Random Wiki