Jump to content

User:Fetofs/aicarchive.py

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
#aicarchive.py
#Archives an AfC page on the current day page


from wikipedia import *
import time

currenttime = time.gmtime(time.time())
times = map(str, currenttime)

def add0(string):
    if len(string) == 1:
        return '0' + string
    else:
        return string

day = add0(times[2])
month = add0(times[1])
hour = add0(times[3])
minute = add0(times[4])


year = times[0]

archivepage = 'Wikipedia:Articles for creation/%s-%s-%s' % (year, month, day)
Today = 'Wikipedia:Articles for creation/Today'

Movelink = 'http://en.wikipedia.org/w/index.php?title=Special:Movepage&wpOldTitle=' + Today + '&wpNewTitle=' + archivepage + '&wpReason=Archiving%20[[WP:AFC]]%20page'

print 'Follow the following link:'
print
print Movelink
print
raw_input("Once you're done, type any key")

#step 2; replacing with generic header
Today = Page('en', 'Wikipedia:Articles for creation/Today')
setAction('Replacing redirect with generic header')
Today.put('Please now follow the link back to [[Wikipedia:Articles for creation]].')

#step 3; adding archive to List          
List = Page('en', 'Wikipedia:Articles for creation/List')
Listtext = Page.get(List)

if Listtext[41:43] != month:
    print 'REMINDER: different months detected. Month archival is likely to be possible!'

newtext = '* [[' + archivepage + ']] — Archive made at' + hour + minute + ' [[UTC]] on [[' + year + '-' + month + '-' + day + ']]\n' + Listtext
setAction('Listing archive page')
List.put(newtext)