User:Shizhao/人事任免投票资格代码
外观
# -*- coding: utf-8 -*-
import os, sys,wikipedia,config,userlib,query,time,datetime
site = wikipedia.getSite()
#使用时替换page标题
page = wikipedia.Page(site, u"Wikipedia:申请成为管理员/Makecat")
users= page.contributingUsers()
print users
#人事任免投票資格的判定
def check(user):
vote1=False
vote2=False
p=u''
p1=u''
p2=u''
#解任投票聯署提出或上任投票開始1個月前,有100次或以上中文維基百科編輯數,並在聯署提出或上任投票開始前3個月內有一次編輯數(不包括用戶頁及用戶對話頁的名字空間頁面)
#注意更改时间
params = {
'action': 'query',
'list': 'usercontribs',
'ucuser': user,
'ucprop': ['timestamp'],
'uclimit': 101,
'ucdir': 'older',
'ucstart': '2011-10-07T10:04:00Z'
}
result = query.GetData(params, site)
#注意更改时间
params1 = {
'action': 'query',
'list': 'usercontribs',
'ucuser': user,
'ucprop': ['timestamp'],
'uclimit': 2,
'ucdir': 'older',
'ucstart': '2011-11-07T10:04:00Z',
'ucend' : '2011-08-07T10:04:00Z',
'ucnamespace': '0|1|4|5|6|7|8|9|10|11|12|13|14|15|100|101'
}
result1 = query.GetData(params1, site)
if len(result['query']['usercontribs'])>=100 and len(result1['query']['usercontribs'])>=1:
print user +u' is 1, ', len(result['query']['usercontribs']), len(result1['query']['usercontribs'])
vote1=True
p1=u'#* [[File:Symbol OK.svg|18px|]] 符合人事任免投票資格条件一\n'
else:
print user +' NOT 1', len(result['query']['usercontribs']), len(result1['query']['usercontribs'])
p1=u'#* [[File:No-Symbol.svg|18px|]] 不符合人事任免投票資格条件一\n'
# 擁有中文維基百科3000次編輯數,或1500次中文維基百科條目編輯數。
params20 = {
'action': 'query',
'list': 'usercontribs',
'ucuser': user,
'ucprop': ['timestamp'],
'uclimit': 3001
}
result20 = query.GetData(params20, site)
params21 = {
'action': 'query',
'list': 'usercontribs',
'ucuser': user,
'ucprop': ['timestamp'],
'uclimit': 1501,
'ucnamespace': '0'
}
result21 = query.GetData(params21, site)
if len(result20['query']['usercontribs']) >=3000 or len(result21['query']['usercontribs']) >=1500:
vote2=True
print user + ' is 2', len(result20['query']['usercontribs']), len(result21['query']['usercontribs'])
p2=u'#* [[File:Symbol OK.svg|18px|]] 符合人事任免投票資格条件二\n'
else:
print user+' NOT 2' , len(result20['query']['usercontribs']), len(result21['query']['usercontribs'])
p2=u'#* [[File:No-Symbol.svg|18px|]] 不符合人事任免投票資格条件二\n'
if vote1==True or vote2==True:
print user+' is ok'
p=u'# [[File:Symbol OK.svg|24px|]] {{user|'+user+u'}}: \'\'\'符合[[维基百科:人事任免投票資格|]]\'\'\'\n'
p=p+p1+p2
else:
print user+ ' not OK!'
p=u'# [[File:No-Symbol.svg|24px|]] {{user|'+user+u'}}: \'\'\'不符合[[维基百科:人事任免投票資格|]]\'\'\'\n'
try:
buser = userlib.User(site, user)
if buser.isBlocked():
p=p+u'#* {{注意}} \'\'\'该用户已被封禁!\'\'\'\n'
except:
pass
return p
test = wikipedia.Page(site, u"User:Shizhao/vote1")
text=u''
for user in users:
text=text+check(user)
#print text
test.put(text)