Misplaced Pages

User:Betacommand/Sandbox: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:Betacommand Browse history interactively← Previous editNext edit →Content deleted Content addedVisualWikitext
Revision as of 19:21, 19 March 2007 editBetacommand (talk | contribs)86,927 editsNo edit summary← Previous edit Revision as of 17:49, 23 March 2007 edit undoBetacommand (talk | contribs)86,927 editsNo edit summaryNext edit →
Line 1: Line 1:
<code>#!/usr/bin/python
==Templates that should be substituted==
# coded by Betacommand
This is a list of templates that should always be substituted, organised by ]. Each list is ordered alphabetically with grouped series.
# -*- coding: utf-8 -*-
import sys, wikipedia
import wikipedia, pagegenerators, catlib
import editarticle
import re


===Article namespace===
* {{tl|bio-cats}}
* {{tl|chembox}}, {{tl|chembox simple organic}}, {{tl|chembox simple inorganic}}
* {{tl|footnotes}}, {{tl|Footnotestext}} — substituting these inserts a commentary only visible in edit mode, with a short explanation of how footnotes work (the first also inserts the <nowiki><references/></nowiki> tag),
* {{tl|lived}} — shortcut used to add birth/death categories to biographical articles
* {{tl|prettytable}}, {{tl|Prettytable-center}}, {{tl|Prettytable95}}, {{tl|Prettytable100}}, {{tl|Prettytable100center}}, {{tl|Prettyinfobox}}, {{tl|PrettytableN}}, {{tl|Prettytablewidth}}, {{tl|F1 race table}}, {{tl|Prettytable-center2}}
* {{tl|sub}}, {{tl|sup}} &ndash; but suggest these not subst:ed if used many times on one page, otherwise code likely to become cluttered. ] <span style="font-size:90%;">]</span> 15:55, 28 November 2006 (UTC)


def main():
===Article talk===
acceptall = False #replace.py varable that I havent fixed yet
<!--- {{tl|moved}}, {{tl|moved-n}} - under debate, see talk -->
website= ''
* {{tl|tmfrom}}, {{tl|tmto}}
site = wikipedia.getSite()
##code choped from speedy_delete.py
if website == '':
website = wikipedia.input(u'Please enter the website to be removed:\n')
website = website
##end choped code
website
print website
address = '*.' + website
text = ''
websitepage = wikipedia.Page(site,website)
wikipedia.setAction('removing inappropriate link per ], ], ], and ] ')
pages = sorted(set())
for page in pages:
if page.namespace()==0:
pg = page.get()
if re.search("={1,}\s?xternal inks?\s?={1,}", pg):
array = re.split("(={1,}\s?External inks?\s?={1,})", pg)
lastpart = array
regex= '\*??\|)\n'
lastpart = re.sub(regex,'',lastpart)
if re.search("(www|http|ftp)", lastpart):
pass
else:
regex= '={1,}\s?xternal inks?\s?={1,}\n'
lastpart = re.sub(regex,'',lastpart)
new_text = array + array + lastpart
if (len(new_text)-len(pg))!= 0:
## note the next part was copied from replace.py
##
##
wikipedia.output(u'\n>>> %s <<<' % page.title())
wikipedia.showDiff(pg, new_text)
if not acceptall:
choice = wikipedia.inputChoice(u'Do you want to delete the link?', , , 'S')
if choice in :
acceptall = True
if acceptall or choice in :
try:
page.put(new_text)
except wikipedia.EditConflict:
wikipedia.output(u'Skipping %s because of edit conflict' % (page.title()))
except wikipedia.SpamfilterError, url:
wikipedia.output(u'Cannot change %s because of blacklist entry %s' % (page.title(),url))
## my code again
else: pass
else: print "Page doesn't contain \"External links\" section"


if __name__ == '__main__':
===User talk namespace===
try:
'''Warnings'''
main()
* {{tl|3RR}} {{tl|3RR2}} {{tl|3RR5}}
finally:
* {{tl|anon vandal}}
wikipedia.stopme()
* {{tl|attack}} {{tl|No personal attacks}} {{tl|Npa}} {{tl|Npa2}} {{tl|Npa3}} {{tl|Npa4}}
</code>
* {{tl|blatantvandal}} {{tl|bv}}
* {{tl|blank}} {{tl|blank2}} {{tl|blank3}} {{tl|blank4}}
* {{tl|drmafd}} {{tl|drmafd2}} {{tl|drmafd3}} {{tl|drmafd4}} {{tl|drmafd5}}
* {{tl|Edit summary personal}} {{tl|Editsummarynew}}
* {{tl|MIPblock}}
* {{tl|multipleIPs}}
* {{tl|name your images}} {{tl|image source}} {{tl|image copyright}}
* {{tl|nn-warn}}
* {{tl|nothanks}} {{tl|nothanks-sd}}
* {{tl|sofixit}}
* {{tl|subst}}
* {{tl|Summary}} {{tl|Edit summary}}
* {{tl|spam}} {{tl|spam2}} {{tl|spam2a}} {{tl|spam3}} {{tl|spam4}}
* {{tl|test-self}}
* {{tl|test-n}} {{tl|test2-n}} {{tl|test2a}} {{tl|test2a-n}} {{tl|test2b}} {{tl|test3-n}} {{tl|test4a}} {{tl|test4-n}}
* {{tl|test}} {{tl|test0}} {{tl|test1}} {{tl|test2}} {{tl|test2a}} {{tl|test3}} {{tl|test4}} {{tl|test5}} {{tl|test6}}
* {{tl|UsernameBlocked}}
* {{tl|vanity}}
* {{tl|vblock}}
* {{tl|verror}} {{tl|verror2}} {{tl|verror3}} {{tl|verror4}}
* {{tl|vw}}

'''Suggestions'''
* {{tl|Award}}, {{]}}
* {{tl|firstarticle}}
* {{tl|newvoter}}
* {{tl|welcome}} {{tl|welcome2}} {{tl|welcome3}} {{tl|welcome4}} {{tl|welcomeip}} {{tl|anon}} {{tl|welcome-anon}} {{tl|welcome-anon-from}} — and all ]
* {{tl|tilde}}

===Image namespace===
* {{tl|Album Image}} — simple code, uses {{tl|albumcover}}.

===Deletion-process documentation===
* {{tl|afd bottom}}, {{tl|afd top}}
* {{tl|mfd top}}, {{tl|mfd bottom}},
* {{tl|mfd}}

===Misc. templates===
* {{tl|debate top}}, {{tl|debate bottom}} — similar boilerplate message as for the deletion related messages, but for regular discussions instead.
* {{tl|nobr}} used to ensure that wikilinks don't break across lines
* {{tl|TFAfooter}} links relevant to current featured article, notably used on the .
* User signature templates cause undue server strain as changes to a minor user template must then be widely propagated.
* {{tl|WP:RM}}, {{tl|Move2}} simplify ].

===Uncategorised suggestions===
<!-- * ''There are currently no uncategorised suggestions.'' -->
* <span class="plainlinksneverexpand">]&#160;(<small>&#160;]&#160;&#160;&#160;</small>)</span> belongs technically to the article namespace

Revision as of 17:49, 23 March 2007

#!/usr/bin/python

  1. coded by Betacommand
  2. -*- coding: utf-8 -*-

import sys, wikipedia import wikipedia, pagegenerators, catlib import editarticle import re


def main():

   acceptall = False   #replace.py varable that I havent fixed yet
   website= 
   site = wikipedia.getSite()
    1. code choped from speedy_delete.py
   if website == :
     website = wikipedia.input(u'Please enter the website to be removed:\n')
   website = website
    1. end choped code
   website
   print website
   address = '*.' + website
   text = 
   websitepage = wikipedia.Page(site,website)
   wikipedia.setAction('removing inappropriate link per WP:EL, WP:SPAM, WP:RS, and WP:NOT ')
   pages = sorted(set())
   for page in pages:
     if page.namespace()==0:
       pg = page.get()
       if re.search("={1,}\s?xternal inks?\s?={1,}", pg):
         array = re.split("(={1,}\s?External inks?\s?={1,})", pg)
         lastpart = array
         regex= '\*??\|)\n'
         lastpart = re.sub(regex,,lastpart)
         if re.search("(www|http|ftp)", lastpart):
           pass
         else:
           regex= '={1,}\s?xternal inks?\s?={1,}\n'
           lastpart = re.sub(regex,,lastpart)            
         new_text = array + array + lastpart
         if (len(new_text)-len(pg))!= 0:
    1. note the next part was copied from replace.py
           wikipedia.output(u'\n>>> %s <<<' % page.title())
           wikipedia.showDiff(pg, new_text)
           if not acceptall:
               choice = wikipedia.inputChoice(u'Do you want to delete the link?', , , 'S')
               if choice in :
                   acceptall = True
           if acceptall or choice in :
               try:
                   page.put(new_text)
               except wikipedia.EditConflict:
                   wikipedia.output(u'Skipping %s because of edit conflict' % (page.title()))
               except wikipedia.SpamfilterError, url:
                   wikipedia.output(u'Cannot change %s because of blacklist entry %s' % (page.title(),url))
    1. my code again
         else: pass
       else: print "Page doesn't contain \"External links\" section"

if __name__ == '__main__':

 try:
   main()
 finally:
   wikipedia.stopme()