Find pages in database.
(self, pattern)
| 596 | return pid |
| 597 | |
| 598 | def find(self, pattern): |
| 599 | """Find pages in database.""" |
| 600 | |
| 601 | results = self._search_keyword(pattern) |
| 602 | |
| 603 | pat = re.compile(r'(.*?)(%s)(.*?)( \(.*\))?$' % |
| 604 | re.escape(pattern), re.I) |
| 605 | |
| 606 | if results: |
| 607 | for name, keyword, url in results: |
| 608 | |
| 609 | if os.isatty(sys.stdout.fileno()): |
| 610 | keyword = pat.sub( |
| 611 | r'\1\033[1;31m\2\033[0m\3\033[1;33m\4\033[0m', keyword) |
| 612 | print("%s - %s" % (keyword, name)) |
| 613 | else: |
| 614 | raise RuntimeError('%s: nothing appropriate.' % pattern) |
| 615 | |
| 616 | def fuzzy_find(self, pattern, max_results, show_menu=False): |
| 617 | """Find pages in database and optionally present an interactive selection menu.""" |
no test coverage detected