Tech, Bureaucrats, emailconfirmed, Administrators (Semantic MediaWiki), Curators (Semantic MediaWiki), Suppressors, Administrators, threadmoderator
118,971
edits
(Updates) Tag: 2017 source edit |
|||
Line 18: | Line 18: | ||
python pwb.py replace -cat:"Target category" -regex "\[\[Category:(.*?)\]\]\n*([\s\S]*)\n\[\[Category:(Target category)\]\]" "[[Category:\3]]\n[[Category:\1]]\n\2" "\[\[Category:(.*?)\]\]\n\[\[Category:(Target category)\]\]" "[[Category:\2]]\n[[Category:\1]]" -pt:2 | python pwb.py replace -cat:"Target category" -regex "\[\[Category:(.*?)\]\]\n*([\s\S]*)\n\[\[Category:(Target category)\]\]" "[[Category:\3]]\n[[Category:\1]]\n\2" "\[\[Category:(.*?)\]\]\n\[\[Category:(Target category)\]\]" "[[Category:\2]]\n[[Category:\1]]" -pt:2 | ||
</pre> | </pre> | ||
=== Adding category for number of parts === | |||
In this case, it's written for comics specifically: | |||
<pre style="background:black!important;color:white;font-size:.8em"> | |||
python pwb.py replace -regex "epcount( *?)=( *?)([^\n]*?)\|featuring" "epcount\1=\2\3\n|featuring" "epcount( *)=( *)(.*?)\}\}" "epcount\1=\2\3\n}}" "\|prev ( *?)=( *)(.*?)\n([\s\S]*)\n\|epcount=(.*?)\n" "|epcount\1= \5\n|prev \1=\2\3\n\4\n" "epcount=([^ ].*?)\n" "epcount = \1\n" "\|prev( *?)=( *?)(.*?)\n(\s\S]*)\n\|epcount ( *?)= ( *?)(.*?)\n" "|epcount \5= \7\n|prev\1=\2\3\n\4\n" "\|series( *)=( *)(.*?)\n\|epcount( *)=( *)(.*?)\n" "|epcount\4=\5\6\n|series\1=\2\3\n" "epcount( *)=( *)(.+)\n([\s\S]*)\n\[\[Category:(.*?)\]\]" "epcount\1=\2\3\n\4\n[[Category:\5]]\n[[Category:{{subst:#switch:\3|1=One|2=Two|3=Three|4=Four|5=Five|6=Six|7=Seven|8=Eight|9=Nine|10=Ten|11=Eleven|12=Twelve|#default=X}} part comics]]" -excepttext:" part comics\]\]" -catr:"Comic stories" -summary:"Re-organising and adding category" -pt:2 | |||
</pre> | |||
[[:Category:X part comics]], here, acts as a failsafe measure to check for exceptions. Adding in [[:category:Comics with thirteen or more parts]], which follows an unusual naming format, would be laborious (and not worth the effort, in this case). | |||
=== Adding FTRW category only if contains <nowiki>{{</nowiki><code>wikipediainfo</code>}} === | === Adding FTRW category only if contains <nowiki>{{</nowiki><code>wikipediainfo</code>}} === | ||
Line 35: | Line 42: | ||
<pre style="background:black!important;color:white"> | <pre style="background:black!important;color:white"> | ||
python pwb.py replace -regex "''\[\[(:wikipedia|wikipedia):(.*?)\|(.*?)\]\]''" "{{wi|\2|\3}}" "\[\[(:wikipedia|wikipedia):(.*?)\|(.*?)\]\]" "{{w|\2|\3}}" "\{\{(w|wi)\|(.*?)\|\2\}\}" "{{\1|\2}}" "\{\{(w|wi)\|(\w)(.*?)\|(\w)\3\}\}" "{{\1|\4\3}}" "\{\{(w|wi)\|(\w)(.*?)\|(\w)\3(s)\}\}" "{{\1|\4\3|\4\3s}}" -summary:"Converting to {{w}} and {{wi}}" -start:! -pt:2 | python pwb.py replace -regex "''\[\[(:wikipedia|wikipedia):(.*?)\|(.*?)\]\]''" "{{wi|\2|\3}}" "\[\[(:wikipedia|wikipedia):(.*?)\|(.*?)\]\]" "{{w|\2|\3}}" "\{\{(w|wi)\|(.*?)\|\2\}\}" "{{\1|\2}}" "\{\{(w|wi)\|(\w)(.*?)\|(\w)\3\}\}" "{{\1|\4\3}}" "\{\{(w|wi)\|(\w)(.*?)\|(\w)\3(s)\}\}" "{{\1|\4\3|\4\3s}}" -summary:"Converting to {{w}} and {{wi}}" -start:! -pt:2 | ||
</pre> | |||
=== Adding infobox variable based on category === | |||
The example here is for adding <code>epcount</code>, where it is missing, for one-part comic stories. (It begins with the category, excludes all pages where <code>epcount</code> is already present, then neatly places the information in the relevant section, with consistent spacing for the page in question.) | |||
<pre style="background:black!important;color:white"> | |||
python pwb.py replace -catr:"One part comics" -excepttext:"epcount( *?)=( *?)1\n" "-regex" "\|prev( )( *?)=( *?)(.*?)\n" "|epcount\2= 1\n|prev\1\2=\3\4\n" "\|series( *?)=( *?)(.*?)\n\|epcount( *)=( *)(.*?)\n" "|epcount\4=\5\6\n|series\1=\2\3\n" -pt:2 -summary:"Adding missing epcount" | |||
</pre> | |||
=== Bringing one infobox variable into line, standardising spacing === | |||
In this case, the variable is <code>epcount</code>, which we want to go before <code>prev, or, if <code>prev</code> is preceded by <code>series</code>, before <code>series</code>... | |||
<pre style="background:black!important;color:white;font-size:.8em"> | |||
python pwb.py replace -regex "epcount( *?)=( *?)([^\n]*?)\|featuring" "epcount\1=\2\3\n|featuring" "next( *?)=( *?)([^\n]*?)\|epcount( *?)=( *?)([^ ]*?)\n" "next\1=\2\3\n|epcount\4= \6\n" "epcount( *)=( *)(.*?)\}\}" "epcount\1=\2\3\n}}" "\|prev ( *?)=( *)(.*?)\n([\s\S]*)\n\|epcount=(.*?)\n" "|epcount\1= \5\n|prev \1=\2\3\n\4\n" "epcount=([^ ].*?)\n" "epcount = \1\n" "\|prev( *?)=( *?)(.*?)\n([\s\S]*)\n\|epcount( *?)=( *?)([^ ]*?)\n" "|epcount\5= \7\n|prev\1=\2\3\n\4\n" "\|epcount=( *)([^ ]*?)\n" "|epcount = \2\n" "\|series( *)=( *)(.*?)\n\|epcount( *)=( *)(.*?)\n" "|epcount\4=\5\6\n|series\1=\2\3\n" -catr:"Comic stories" -summary:"Re-organising infobox" -pt:2 | |||
</pre> | </pre> | ||
=== Catch-all template order/spacing standardisation === | === Catch-all template order/spacing standardisation === | ||
<pre style="background:black!important;color:white"> | <pre style="background:black!important;color:white;font-size:.8em"> | ||
python pwb.py replace -regex "\{\{([Tt]itle dab away|[Rr]eal world)\}\}\{\{([Rr]eal world|[Tt]itle dab away)\}\}" "{{title dab away}}\n{{real world}}" "}}{{Infobox" "}}\n{{Infobox" "\{\{(.*?)stub\}\}\n\{\{[Tt]itle dab away\}\}\n\{\{[Rr]eal world\}\}" "{{title dab away}}\n{{real world}}\n{{\1stub}}" "\{\{(.*?)stub\}\}\{\{[Tt]itle dab away\}\}" "{{title dab away}}\n{{\1stub}}" "\{\{[Rr]eal world\}\}\n\{\{[Tt]itle dab away\}\}\n{\{(.*?)stub\}\}" "{{title dab away}}\n{{real world}}\n{{\1stub}}" "\{\{[Tt]itle dab away\}\}\n\{\{(.*?)stub\}\}\n{\{[Rr]eal world\}\}" "{{title dab away}}\n{{real world}}\n{{\1stub}}" "\{\{real world\}\}\{\{(.*?)stub\}\}\n\{\{title dab away\}\}\n([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2}}{{\1stub}}" "\{\{ImageLink(.*?)\}\}\{\{real world\}\}\{\{title dab away\}\}\{\{Infobox" "{{title dab away}}\n{{real world}}\n{{ImageLink\1}}\n{{Infobox" "\{\{ImageLink(.*?)\}\}( *)\n\{\{[Rr]eal world\}\}( *)\n\{\{[Tt]itle dab away\}\}" "{{title dab away}}\n{{real world}}\n{{ImageLink\1}}" "\{\{ImageLink(.*?)\}\}\{\{[Rr]eal world\}\}\{\{[Tt]itle dab away\}\}" "{{title dab away}}\n{{real world}}\n{{ImageLink\1}}" "\{\{[Rr]eal world\}\}\{\{[Tt]itle dab away\}\}" "{{title dab away}}\n{{real world}}" "\{\{real world\}\}\{\{[Rr]etitle\|(\'\'|.)(\{\{PAGENAME\}\})(\'\'|.)\}\}" "{{retitle|\1\2\3}}\n{{real world}}" "\{\{real world\}\}\{\{[Rr]etitle\|(.*?)\}\}" "{{retitle|\1}}\n{{real world}}" "\{\{real world\}\}\{\{ImageLink(.*?)\}\}\{\{[Tt]itle dab away\}\}" "{{title dab away}}\n{{real world}}\n{{ImageLink\1}}" "\{\{real world\}\}\{\{ImageLink(.*?)\}\}" "{{real world}}\n{{ImageLink\1}}" "\{\{real world\}\}\n\{\{ImageLink(.*?)\}\}\n\{\{title dab away\}\}" "{{title dab away}}\n{{real world}}\n{{ImageLink\1}}" "\{\{real world\}\}\{\{target years\}\}" "{{real world}}\n{{target years}}" "'''\{\{[rR]eal world\}\}" "{{real world}}\n'''" "\{\{[rR]eal world\}\} \n" "{{real world}}\n" "\{\{[rR]eal world\}\}(.+)\n" "{{real world}}\n\1\n" "\{\{[rR]eal world\}\}\n\n" "{{real world}}\n" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2{{il\3}}\4{{il\5}}\6{{il\7}}\8{{il\9}}\10}}{{\1stub}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2{{il\3}}\4{{il\5}}\6{{il\7}}\8}}{{\1stub}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2{{il\3}}\4{{il\5}}\6}}{{\1stub}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2{{il\3}}\4}}{{\1stub}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2}}{{\1stub}}" "\{\{real world\}\}\n\{\{(.*?)stub\}\}\n\{\{title dab away\}\}\n([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2}}{{\1stub}}" "\n\|(.*?)\}\}\{\{" "\n|\1\n}}{{" "\}\}\{\{(.*?) stub\}\}\'\'\'" "}}{{\1 stub}}\n'''" "\}\}\{\{(.*?) stub\}\}\{\{[yY]ou may(.*?)\}\}" "}}{{\1 stub}}\n{{you may\2}}" "\}\}\{\{(.*?) stub\}\}\n\{\{(.*?)\}\}\'\'\'" "}}{{\1 stub}}\n{{\2}}\n'''" "\{\{real world\}\}\n\{\{(.*?)stub\}\}\n\{\{title dab away\}\}\n([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2}}{{\1stub}}" "\{\{real world\}\}\n([\s\S]*?)\}\}\{\{ImageLink(.*?)\}\}" "{{real world}}\n{{ImageLink\2}}\n\1}}" -pt:2 -summary:"Standardising template spacing and order" -transcludes:"real world" | python pwb.py replace -regex "\{\{([Tt]itle dab away|[Rr]eal world)\}\}\{\{([Rr]eal world|[Tt]itle dab away)\}\}" "{{title dab away}}\n{{real world}}" "}}{{Infobox" "}}\n{{Infobox" "\{\{(.*?)stub\}\}\n\{\{[Tt]itle dab away\}\}\n\{\{[Rr]eal world\}\}" "{{title dab away}}\n{{real world}}\n{{\1stub}}" "\{\{(.*?)stub\}\}\{\{[Tt]itle dab away\}\}" "{{title dab away}}\n{{\1stub}}" "\{\{[Rr]eal world\}\}\n\{\{[Tt]itle dab away\}\}\n{\{(.*?)stub\}\}" "{{title dab away}}\n{{real world}}\n{{\1stub}}" "\{\{[Tt]itle dab away\}\}\n\{\{(.*?)stub\}\}\n{\{[Rr]eal world\}\}" "{{title dab away}}\n{{real world}}\n{{\1stub}}" "\{\{real world\}\}\{\{(.*?)stub\}\}\n\{\{title dab away\}\}\n([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2}}{{\1stub}}" "\{\{ImageLink(.*?)\}\}\{\{real world\}\}\{\{title dab away\}\}\{\{Infobox" "{{title dab away}}\n{{real world}}\n{{ImageLink\1}}\n{{Infobox" "\{\{ImageLink(.*?)\}\}( *)\n\{\{[Rr]eal world\}\}( *)\n\{\{[Tt]itle dab away\}\}" "{{title dab away}}\n{{real world}}\n{{ImageLink\1}}" "\{\{ImageLink(.*?)\}\}\{\{[Rr]eal world\}\}\{\{[Tt]itle dab away\}\}" "{{title dab away}}\n{{real world}}\n{{ImageLink\1}}" "\{\{[Rr]eal world\}\}\{\{[Tt]itle dab away\}\}" "{{title dab away}}\n{{real world}}" "\{\{real world\}\}\{\{[Rr]etitle\|(\'\'|.)(\{\{PAGENAME\}\})(\'\'|.)\}\}" "{{retitle|\1\2\3}}\n{{real world}}" "\{\{real world\}\}\{\{[Rr]etitle\|(.*?)\}\}" "{{retitle|\1}}\n{{real world}}" "\{\{real world\}\}\{\{ImageLink(.*?)\}\}\{\{[Tt]itle dab away\}\}" "{{title dab away}}\n{{real world}}\n{{ImageLink\1}}" "\{\{real world\}\}\{\{ImageLink(.*?)\}\}" "{{real world}}\n{{ImageLink\1}}" "\{\{real world\}\}\n\{\{ImageLink(.*?)\}\}\n\{\{title dab away\}\}" "{{title dab away}}\n{{real world}}\n{{ImageLink\1}}" "\{\{real world\}\}\{\{target years\}\}" "{{real world}}\n{{target years}}" "'''\{\{[rR]eal world\}\}" "{{real world}}\n'''" "\{\{[rR]eal world\}\} \n" "{{real world}}\n" "\{\{[rR]eal world\}\}(.+)\n" "{{real world}}\n\1\n" "\{\{[rR]eal world\}\}\n\n" "{{real world}}\n" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2{{il\3}}\4{{il\5}}\6{{il\7}}\8{{il\9}}\10}}{{\1stub}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2{{il\3}}\4{{il\5}}\6{{il\7}}\8}}{{\1stub}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2{{il\3}}\4{{il\5}}\6}}{{\1stub}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\{\{[Ii]l(.*?)\}\}([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2{{il\3}}\4}}{{\1stub}}" "\{\{title dab away\}\}\n\{\{real world\}\}\n\{\{(.*?)stub\}\}\n([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2}}{{\1stub}}" "\{\{real world\}\}\n\{\{(.*?)stub\}\}\n\{\{title dab away\}\}\n([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2}}{{\1stub}}" "\n\|(.*?)\}\}\{\{" "\n|\1\n}}{{" "\}\}\{\{(.*?) stub\}\}\'\'\'" "}}{{\1 stub}}\n'''" "\}\}\{\{(.*?) stub\}\}\{\{[yY]ou may(.*?)\}\}" "}}{{\1 stub}}\n{{you may\2}}" "\}\}\{\{(.*?) stub\}\}\n\{\{(.*?)\}\}\'\'\'" "}}{{\1 stub}}\n{{\2}}\n'''" "\{\{real world\}\}\n\{\{(.*?)stub\}\}\n\{\{title dab away\}\}\n([\s\S]*?)\}\}" "{{title dab away}}\n{{real world}}\n\2}}{{\1stub}}" "\{\{real world\}\}\n([\s\S]*?)\}\}\{\{ImageLink(.*?)\}\}" "{{real world}}\n{{ImageLink\2}}\n\1}}" "\|([^\n]*?)( +)=([^ ]*?)\n" "|\1\2= \3\n" "\|([^\n]*?)( *?)=( {2,})([^ ]*?)\n" "|\1\2= \4\n" -pt:2 -summary:"Standardising template spacing and order" -transcludes:"real world" | ||
</pre> | </pre> | ||
edits