Revision: 4669 Author: rotem Date: 2007-12-09 15:41:27 +0000 (Sun, 09 Dec 2007)
Log Message: ----------- Check if the namespace is defined for this language when verifying family data.
Modified Paths: -------------- trunk/pywikipedia/family.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/family.py =================================================================== --- trunk/pywikipedia/family.py 2007-12-09 15:27:34 UTC (rev 4668) +++ trunk/pywikipedia/family.py 2007-12-09 15:41:27 UTC (rev 4669) @@ -2423,6 +2423,19 @@ (it has a custom entry for a given language)""" return self.namespaces[ns_number].has_key(code)
+ def isDefinedNSLanguage(self, ns_number, code, fallback='_default'): + """Return True if the namespace has been defined in this family + for this language or its fallback. + """ + if not self.isDefinedNS(ns_number): + return False + elif self.isNsI18N(ns_number, code): + return True + elif fallback and self.isNsI18N(ns_number, fallback): + return True + else: + return False + def normalizeNamespace(self, code, value): """Given a value, attempt to match it with all available namespaces, with default and localized versions. Sites may have more than one
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2007-12-09 15:27:34 UTC (rev 4668) +++ trunk/pywikipedia/wikipedia.py 2007-12-09 15:41:27 UTC (rev 4669) @@ -2454,7 +2454,7 @@ ids.sort() for id in ids: nshdr = header.namespaces[id] - if self.site.family.isDefinedNS(id): + if self.site.family.isDefinedNSLanguage(id, lang): ns = self.site.namespace(id) if ns == None: ns = u''
pywikipedia-l@lists.wikimedia.org