Current implementation
- param code: The site code as string or Site object.
Problem with string
- if xdict is an extended dictionary with family name as key for the underlying code dictionary, the config.family is used as family name. This may lead to unexpected family lookup: The family of the site object may be different from the default site, e.g. if using a MultipleSiteBot.
For example have a look to the netext dict in welcome.py. Looking up the 'commons' entry is successful for a site object but it fails for a bare 'commons' code:
>>> import pwb, pywikibot as py >>> from pywikibot.i18n import translate >>> from scripts.welcome import netext >>> s = py.Site('commons', 'commons') >>> translate(s, netext) '{{subst:welcome}} %s' >>> translate('commons', netext) is None True
Proposed solution
- A Site object should be used in favour of the code string. Keep the old implementation but show an appropriate warning