Wikipedia talk:Rename of Image-class to File-class
Script
editI noticed that Happy-melon mentioned he had a script that could be used to help with this task. Here is what he provided:
def catMaintenance(): #Used to populate [[:Category:C-Class articles]]
if 'y' in raw_input('Confirm questionable actions? '):
prompt = True
else:
prompt = False
import api
bcats = api.category('Category:B-Class articles')[1]
ccats = api.category('Category:C-Class articles')[1]
for bcat in bcats[:]:
cat = re.sub(r'B\-Class',r'C-Class',bcat)
if cat in ccats:
bcats.remove(bcat)
num = len(bcats)
for cat in bcats:
bclass = wikipedia.Page(site, cat)
cclass = wikipedia.Page(site, re.sub('B\-Class','C-Class',cat) )
#print cclass
if cclass.exists():
print cclass.title()+' already exists. Skipping'
continue
elif api.logEvents(cclass.title(),events='delete'):
print cclass.title()+' has previously been deleted. Skipping...'
continue
else:
btext = bclass.get()
ctext = btext
ctext = re.sub('B(?=[ \-][Cc]lass)','C',ctext)
ctext = re.sub(r'class=B','class=C',ctext)
ctext = re.sub(r'\[\[\s*[Cc]ategory:\s*C-Class[ _]articles\s*\]\]','[[Category:C-Class articles|'+re.sub(r'(?i)[Cc]ategory:C-Class (.*) [Aa]rticles',r'\1',cclass.title())+']]',ctext)
ctext = re.sub(r'(\|\s*)B([\|\}\]])',r'\1C\2',ctext)
ctext = re.sub(r"(['\"])B(['\"])",r'\1C\2',ctext)
print '***********************************************************************'
wikipedia.output(ctext)
print '********************************************'
check = ctext
check = re.sub(r'(?i)(\[\[\s*category:.*?\]\]|\{\{\s*(catmore(1)?|cat class|categorytoc|wpmilhist task force assessment level category|tlx?).*?\}\})','',check)
check = re.sub(r'\{\{[^\|]+?\}\}','',check)
check = re.sub(r'(?i)(\[\[.+?\]\]|\.|\;|\,|\'|\")','',check)
check = re.sub(r'[ \n]*','',check)
check = re.sub(r"(?i)thiscategorycontainsarticlesthathavebeen(ratedasC-Class|assessed)by(the)?Articlesareautomaticallyplacedinthiscategorywhenthecorrespondingratingisgivenpleaseseetheformoreinformation",'',check)
check = re.sub(r'[^bB]','',check)
#print check
if not check or (prompt and 'y' not in raw_input('Skip '+cclass.title()+'? ')):
cclass.put(ctext,'Populating [[:Category:C-Class articles]]')
elif prompt and 'y' in raw_input('Use a regex? '):
ctext = re.sub(raw_input('Pattern: '),raw_input('Replace with: '),ctext)
print ctext
if 'y' in raw_input('OK? '):
cclass.put(ctext,'Populating [[:Category:C-Class articles]]')
num -= 1
print str(num) + ' to go...'
print '***********************************************************************'
return
It seems to relate to C-class categories, but I suppose we could adapt it maybe? — Martin (MSGJ · talk) 17:52, 25 July 2010 (UTC)
Cydebot
editI've set Cydebot to work through creating the File-Class categories that haven't been yet (so attribution is preserved). –xenotalk 13:52, 26 July 2010 (UTC)
- Looks good. So will the bot delete the old categories as well when they are empty? — Martin (MSGJ · talk) 16:44, 26 July 2010 (UTC)
- Yea, it should... Not sure if it checks that incoming links were fixed though, are there many hard-coded links to these types of cats? –xenotalk 16:46, 26 July 2010 (UTC)
- Don't think so. {{cat class}} will detect the new categories automatically, and an edit to {{grading scheme}} might be in order. — Martin (MSGJ · talk) 17:03, 26 July 2010 (UTC)
- Yea, it should... Not sure if it checks that incoming links were fixed though, are there many hard-coded links to these types of cats? –xenotalk 16:46, 26 July 2010 (UTC)
Renaming the class
editIs this going to require editing of every banner using Image-Class, or can it be done automagically somehow? (If not exist Image-Class cat, then use File-Class
or something). –xenotalk 14:08, 26 July 2010 (UTC)
- Once all the categories are created, it will just be a simple change in Template:Class mask I think. — Martin (MSGJ · talk) 16:24, 26 July 2010 (UTC)
- Cydebot is doing the final run thru now. –xenotalk 18:04, 26 July 2010 (UTC)
- (edit conflict)What I was thinking was this: setting
|image=yes
should still turn on Image-class. This is for consistency with how all the other classes behave in this template. For example|sausage=yes
turns on Sausage-class. It would not be logical to prevent WikiPrpjects from using Image-class if that is what they actually want. This would only affect the small number of projects shown in Category:WikiProjects explicitly using Image-class. —Preceding unsigned comment added by MSGJ (talk • contribs) 18:08, 26 July 2010 (UTC)- Guess I was just looking for the easiest way to do it. But it would be sloppy, I admit. –xenotalk 18:10, 26 July 2010 (UTC)
- This is the easiest way I think. 99% of projects using Image-class do so by setting
|FQS=yes
and these will all be changed with one edit. — Martin (MSGJ · talk) 18:12, 26 July 2010 (UTC)- Oh ok, excellent. I agree that projects that want to explicitly use Image-Class should have a way to do so. –xenotalk 18:15, 26 July 2010 (UTC)
- Don't forget the 8 banners at Category:WikiProject banners that don't use WPBS and hence the class mask. -- WOSlinker (talk) 19:07, 26 July 2010 (UTC)
- Oh ok, excellent. I agree that projects that want to explicitly use Image-Class should have a way to do so. –xenotalk 18:15, 26 July 2010 (UTC)
- This is the easiest way I think. 99% of projects using Image-class do so by setting
- Guess I was just looking for the easiest way to do it. But it would be sloppy, I admit. –xenotalk 18:10, 26 July 2010 (UTC)
- Looks like they are all of them created now, and the class mask can be updated. –xenotalk 20:00, 26 July 2010 (UTC)
- Okay, but WOSlinker is making my head hurt. — Martin (MSGJ · talk) 21:14, 26 July 2010 (UTC)
- Done — Martin (MSGJ · talk) 21:53, 26 July 2010 (UTC)
- Okay, but WOSlinker is making my head hurt. — Martin (MSGJ · talk) 21:14, 26 July 2010 (UTC)
@MSGJ re [1] so are these not going to live in the former Image-Class toplevel? So this is not necessary? –xenotalk 20:34, 26 July 2010 (UTC)
- Well I did suggest that we perhaps don't need that category anymore. — Martin (MSGJ · talk) 21:15, 26 July 2010 (UTC)
Like watching grass grow
editOr paint dry. Lol. –xenotalk 14:04, 21 August 2010 (UTC)
- Lol. Not many left now. — Martin (MSGJ · talk) 17:17, 21 August 2010 (UTC)
- You could start applying null edits to the relevant pages with your bot account. — Martin (MSGJ · talk) 16:39, 1 September 2010 (UTC)
- Only 6 categories left now. -- WOSlinker (talk) 19:48, 18 September 2010 (UTC)
- I have added {{delete when empty}} to the remaining two categories. — Martin (MSGJ · talk) 14:29, 14 October 2010 (UTC)