On 10/26/07, Brianna Laugher <[EMAIL PROTECTED]> wrote:
> Can you give an example of how you would e.g. get all the files
> uploaded on a particular day? does it do the kind of "timestamp
> looping" I mentioned?
>
It does. It is implemented using iterators, so it is actually only
fetched from the server when it is asked. For example:

import mwclient
site = mwclient.Site('commons.wikimedia.org')
site.login(username, password) # Optional

logs = site.logevents(type = 'upload')
for i in logs:
 print i

NB, don't do this in reality, since it will loop over the whole upload
log. Try that at Commons.

Page editting:

page = site.Pages['Commons:Sandbox']
text = page.edit()
page.save(text + u'\ntest', summary = 'Test edit')

Uploading:

site.Images.upload(open('file.jpg'), 'destination.jpg', 'Image description')

I guess I should clean up the code a bit and add documentation... Some
not so useful docs reside at
<http://fisheye.ts.wikimedia.org/browse/bryan/mwclient/trunk/README.txt?r=341>.
I hope to get this done once I have cleaned up my todo list a bit, but
it is already fairly usable.

See also some of my bots:
* DRBot: <http://fisheye.ts.wikimedia.org/browse/bryan/bots/drbot.py>
* FlickreviewR <http://fisheye.ts.wikimedia.org/browse/bryan/flickreviewr>
* POTY 2007 software also uses mwclient to send emails.
<http://fisheye.ts.wikimedia.org/browse/bryan/poty2007/index.py>

Bryan

_______________________________________________
Mediawiki-api mailing list
[email protected]
http://lists.wikimedia.org/mailman/listinfo/mediawiki-api

Reply via email to