Last modified: 2014-09-04 15:22:32 UTC
Originally from: http://sourceforge.net/p/pywikipediabot/feature-requests/332/ Reported by: pathoschild Created on: 2013-02-23 02:45:38 Subject: Let bots use canonical namespaces Original description: Let bots use canonical namespaces instead of translations from the family files. This is useful for crosswiki bots, where invalid namespace names may not be detected by the operator \(most recently \[1\]\[2\]\). The attached patch implements this by adding an optional constructor argument to Page. For example, the current behaviour is unchanged: ns = wikipedia.Page\(site, title\).namespaceName\(\) \# Utilisateur:Pathoschild But a constructor argument enables canonical namespaces: ns = wikipedia.Page\(site, title, translateNamespace=False\).namespaceName\(\) \# User:Pathoschild \[1\] http://meta.wikimedia.org/wiki/User\_talk:Pathoschild?oldid=5269904\#Probl.C3.A8me\_avec\_ton\_bot\_sur\_Wikinews\_portugais \[2\] http://meta.wikimedia.org/wiki/User\_talk:Pathoschild?oldid=5269904\#Polish\_Wikivoyage\_user\_js\_files
Patch which enables canonical namespace support.
- **labels**: 3222924 -->
The patch is against compat, but core has the same problem. Core now has a Namespace class, which captures the canonical namespaces data of the wiki. Relevant code at: https://git.wikimedia.org/blob/pywikibot%2Fcore.git/9b67ec1424d160d1968ef3f3da9f179675d68070/pywikibot%2Fsite.py#L131 https://git.wikimedia.org/blob/pywikibot%2Fcore.git/9b67ec1424d160d1968ef3f3da9f179675d68070/pywikibot%2Fsite.py#L577 The Namespace class isnt utilised in the old link parsing algorithms. There are a few core changesets related to this problem: https://gerrit.wikimedia.org/r/#/c/150872/ - Link normalization https://gerrit.wikimedia.org/r/#/c/148337/ - force using namespace param; ignore namespace in title