Bugs item #3431273, was opened at 2011-10-31 09:55
Message generated for change (Comment added) made by valhallasw
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=343127…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: category
Group: None
Status: Open
Resolution: None
Priority: 3
Private: No
Submitted By: Tgr (tgr_)
Assigned to: xqt (xqt)
Summary: AddCategory bot uses default language instead of site lang
Initial Comment:
This might be a more general problem, I did not check. I created a custom generator and
used it to construct the AddCategory bot from category.py. Apparently the bot uses the
default settings for language purposes instead of either accepting such options in the
constructor or (more conveniently) checking the site of the first page returned by the
generator and using the language of that. For example, running the bot on Commons resulted
in edits like this:
http://commons.wikimedia.org/w/index.php?title=File:Ungar-Mayer-palace_Szeg…
- both the summary and the category namespace name are in Hungarian.
version:
Pywikipedia [http] trunk/pywikipedia (r9710, 2011/10/31, 05:19:34)
Python 2.7.2+ (default, Aug 16 2011, 09:23:59)
[GCC 4.6.1]
config-settings:
use_api = True
use_api_login = True
unicode test: ok
----------------------------------------------------------------------
Comment By: Merlijn S. van Deen (valhallasw)
Date: 2011-11-14 15:28
Message:
Yes, you are correct it's a bad design. However, this is what happens when
software grows ;-)
If you can fix it, you are vey welcome to submit a patch. For now, you
could use the setSite() workaround, which should be OK (but ugly) as long
as you're running a single-threaded app.
>> wikipedia.getSite()
wikipedia:en
>>> wikipedia.setSite(wikipedia.getSite('nl', 'wikipedia')
>> wikipedia.getSite()
wikipedia:nl
you can get the site from a page object:
>> p = wikipedia.Page(wikipedia.getSite(),
'nl:test')
>> p.site()
wikipedia:nl
----------------------------------------------------------------------
Comment By: Tgr (tgr_)
Date: 2011-11-01 13:33
Message:
xqt, I understand that's how it works, but that seems like bad design to
me. The category adder bot is constructed with a generator which yields
Page objects. A Page object already references a Site object; it makes no
sense to do something with it and use the settings from a different site.
Also, I think it is a reasonable expectation that upon creating an object,
you can pass all the relevant settings to it in the constructor, or maybe a
few additional function calls, and it will not be influenced by (the lack
of) command line arguments which are handled by a totally different module.
----------------------------------------------------------------------
Comment By: xqt (xqt)
Date: 2011-10-31 10:51
Message:
This message is from "category-adding" and the code for i18n.twtranslate()
comes from self.site attribute which is assigned with pywikibot.getSite()
by constructor. getSite() gives the site your start the bot. For commons
you must run the -lang:commons -family:commons options which gives an
english text by default. Since this is your own script, could you check
whether your lang code isn't commons on commons site?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=343127…