def interwiki_map(self): """Map from upper-cased namespaces to (namespace, prefix, title) values. """ from trac.wiki.model import WikiPage map = {} content = WikiPage(self.env, InterWikiMap._page_name).text in_map = False for line in content.split('\n'): if in_map: if line.startswith('----'): in_map = False else: m = re.match(InterWikiMap._interwiki_re, line) if m: prefix, url, title = m.groups() url = url.strip() title = title.strip() if title else prefix map[prefix.upper()] = (prefix, url, title) elif line.startswith('----'): in_map = True for prefix, value in self.interwiki_section.options(): value = value.split(None, 1) if value: url = value[0].strip() title = value[1].strip() if len(value) > 1 else prefix map[prefix.upper()] = (prefix, url, title) return map
def _get_interwiki_map(self): from trac.wiki.model import WikiPage if self._interwiki_map is None: self._interwiki_lock.acquire() try: if self._interwiki_map is None: self._interwiki_map = {} content = WikiPage(self.env, InterWikiMap._page_name).text in_map = False for line in content.split('\n'): if in_map: if line.startswith('----'): in_map = False else: m = re.match(InterWikiMap._interwiki_re, line) if m: prefix, url, title = m.groups() url = url.strip() title = title and title.strip() or prefix self[prefix] = (prefix, url, title) elif line.startswith('----'): in_map = True finally: self._interwiki_lock.release() return self._interwiki_map
def _update(self): from trac.wiki.model import WikiPage if self._interwiki_map is not None: return self._interwiki_map = {} content = WikiPage(self.env, InterWikiMap._page_name).text in_map = False for line in content.split('\n'): if in_map: if line.startswith('----'): in_map = False else: m = re.match(InterWikiMap._interwiki_re, line) if m: prefix, url, title = m.groups() url = url.strip() title = title and title.strip() or prefix self[prefix] = (prefix, url, title) elif line.startswith('----'): in_map = True
def interwiki_map(self, db): """Map from upper-cased namespaces to (namespace, prefix, title) values. """ from trac.wiki.model import WikiPage map = {} content = WikiPage(self.env, InterWikiMap._page_name, db=db).text in_map = False for line in content.split('\n'): if in_map: if line.startswith('----'): in_map = False else: m = re.match(InterWikiMap._interwiki_re, line) if m: prefix, url, title = m.groups() url = url.strip() title = title and title.strip() or prefix map[prefix.upper()] = (prefix, url, title) elif line.startswith('----'): in_map = True return map