Skip to content

Instantly share code, notes, and snippets.

@legoktm
Last active December 30, 2015 05:19
Show Gist options
  • Save legoktm/7781996 to your computer and use it in GitHub Desktop.
Save legoktm/7781996 to your computer and use it in GitHub Desktop.
This will probably work.
#!/usr/bin/python
# Public domain
import wikitools
username = 'Legoktm'
password = 'hunter2'
messages = ['Signupstart', 'Signupend']
reason = '...'
def matrix(wiki):
params = {
'action': 'sitematrix',
'format': 'json',
}
req = wikitools.api.APIRequest(wiki, params)
data = req.query()
for val in data['sitematrix']:
if val.isdigit():
for site in data['sitematrix'][val]:
yield wikitools.Wiki(site['url'])
elif val == 'specials':
for site in data['sitematrix'][val]:
if not 'private' in site: # Let someone else touch these...
yield wikitools.Wiki(site['url'])
def do_wiki(wiki):
wiki.login(username, password)
for msg in messages:
pg = wikitools.Page(wiki, 'MediaWiki:' + msg)
if pg.exists:
pg.edit(text='', summary=reason)
def main():
meta = wikitools.Wiki('https://meta.wikimedia.org/w/api.php')
for wiki in matrix(meta):
do_wiki(wiki)
if __name__ == '__main__':
main()
@mzmcbride
Copy link

It doesn't look as though you log in. I see username and password defined, but no call to .login().

I'm also not sure what the purpose of calling .setPageInfo() is. I think creating the Page() object is sufficient to use .exists.

@legoktm
Copy link
Author

legoktm commented Dec 8, 2013

Thanks, fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment