On Wed, Oct 05, 2005 at 11:18:11PM +0200, Lars Aronsson wrote:
Hi friends, I'm new to bots and have tried to read up on this list's archives, pages on meta, and the pywikipedia bot's source code. (I'm new to python too, but that's a smaller problem.)
What I want is to upload a book to Wikisource. It comes in several parts, which should be subpages to the book's main page, e.g. my_book/1, my_book/2, etc. I have 1.txt, 2.txt etc. as plain (wiki)text files in a directory on my disk.
Is pywikipedia the right tool for this task? Should I use replace.py? Do I need to modify the source?
-- Lars Aronsson (lars@aronsson.se) Aronsson Datateknik - http://aronsson.se _______________________________________________ Wikibots-l mailing list Wikibots-l@wikimedia.org http://mail.wikipedia.org/mailman/listinfo/wikibots-l
I don't know how to configure your bot to post to Wikisource, nor do I know how you can post to the Wikisource using the pywikipedia (it's been mentioned before, but I haven't really paid any attention to it) but here is a code sample that you can use to rely on:
f = file('1.txt') text = f.read() f.close() comment = 'My book'
# Take the text and use it to post a page. # Example with Wikipedia: page = wikipedia.Page(wikipedia.getSite(), 'mybook/1').put(text, comment)
You might want to check the python documentation on reading directories, then you can loop on files within that directory.