def _get_matches(self, page): matches = [] # Search in page name results = TitleSearch(self._pattern, use_re=self.use_re, case=self.case)._get_matches(page) if results: matches.extend(results) # Search in page body body = page.get_raw_body() for match in self.search_re.finditer(body): matches.append(TextMatch(re_match=match)) return matches
def _get_matches(self, page): # Get matches in page links matches = [] # XXX in python 2.5 any() may be used. found = False for link in page.getPageLinks(page.request): if self.search_re.match(link): found = True break if found: # Search in page text results = self.textsearch.search(page) if results: matches.extend(results) else: # This happens e.g. for pages that use navigation macros matches.append(TextMatch(0, 0)) return matches
def _get_matches(self, page): """ match categories like this: ... some page text ... ---- ## optionally some comments, e.g. about possible categories: ## CategoryFoo CategoryTheRealAndOnly Note: there might be multiple comment lines, but all real categories must be on a single line either directly below the ---- or directly below some comment lines. """ matches = [] pattern = r'(?m)(^-----*\s*\r?\n)(^##.*\r?\n)*^(?!##)(.*)\b%s\b' % self.pattern search_re = self._build_re(pattern, use_re=self.use_re, case=self.case)[1] # we need only a regexp, but not a pattern body = page.get_raw_body() for match in search_re.finditer(body): matches.append(TextMatch(re_match=match)) return matches