16 from functools
import (total_ordering, cmp_to_key)
20 from ..
import robotapi
21 from ..action
import ActionInfo
22 from ..pluginapi
import Plugin
23 from ..publish
import RideOpenTagSearch
24 from .dialogsearchtests
import TestsDialog
25 from ..widgets
import ImageProvider
31 HEADER =
'Search Tests'
40 shortcut=
'F3', doc=self.
__doc____doc__,
41 icon=ImageProvider().TEST_SEARCH_ICON, position=50))
44 ImageProvider().TEST_SEARCH_ICON, default=
True)
51 self.
_dialog_dialog.set_search_model(
53 self.
_dialog_dialog.set_focus_to_default_location()
57 self.
_dialog_dialog.set_tag_search_model(
59 self.
_dialog_dialog.set_focus_to_default_location()
65 self.
_dialog_dialog._select_page(1)
79 self.
treetree.SelectTests(tests)
89 test, match_location = self.
_selection_selection
90 self.
treetree.select_node_by_data(test)
91 self.
_dialog_dialog.set_focus_to_default_location(test)
98 current_suite = self.
frameframe._controller.data
101 result = self.
_search_search(matcher, current_suite)
102 return sorted(result, key=cmp_to_key(
lambda x, y:
103 self.
m_cmpm_cmp(x[1], y[1])))
106 for test
in data.tests:
107 match = matcher.matches(test)
110 for s
in data.suites:
111 for test, match
in self.
_search_search(matcher, s):
119 return (a > b) - (a < b)
122 return self.
namename.
lower() == other.name.lower()
125 return hash(repr(self))
128 return self.
namename.
lower() < other.name.lower()
135 includes.split())
if includes.split()
else None
139 tags = [str(tag)
for tag
in test.tags]
162 name = test.name.lower()
165 if any(self.
_match_in_match_in(str(tag).
lower())
for tag
in test.tags):
167 doc = test.documentation.value.lower()
173 return any(word
in text
for word
in self.
_texts_lower_texts_lower)
178 def __init__(self, original_search_terms, search_terms_lower, test):
187 def __cmp__(self, other):
190 totals, other_totals = self.
_total_matches_total_matches(), other._total_matches()
191 if totals != other_totals:
192 return self.
m_cmpm_cmp(other_totals, totals)
195 self.
_test_test.name, other._test.name)
200 self.
_tags_tags(), other._tags())
203 return self.
m_cmpm_cmp(self.
_test_test.name, other._test.name)
205 def _compare(self, my_result, other_result, my_cmp, other_cmp):
206 if my_result
and not other_result:
208 if not my_result
and other_result:
210 if my_result
and other_result:
211 return self.
m_cmpm_cmp(my_cmp, other_cmp)
218 if word
in self.
_test_test.name.lower()
219 or any(word
in t
for t
in self.
_tags_tags())
220 or word
in self.
_test_test.documentation.value.lower())
233 if self.
__tags__tags
is None:
238 return self.
_test_test.name
242 return (a > b) - (a < b)
245 return self.
__hash____hash__() == other.__hash__()
248 return not self.
__eq____eq__(other)
251 return hash(repr(self))
Used to create menu entries, keyboard shortcuts and/or toolbar buttons.
Entry point to RIDE plugin API – all plugins must extend this class.
def subscribe(self, listener, *topics)
Start to listen to messages with the given topics.
def register_action(self, action_info)
Registers a menu entry and optionally a shortcut and a toolbar icon.
def unregister_actions(self)
Unregisters all actions registered by this plugin.
def register_search_action(self, description, handler, icon, default=False)
def __init__(self, original_search_terms, search_terms_lower, test)
def _compare(self, my_result, other_result, my_cmp, other_cmp)
def _helper_cmp_(self, other)
def _match_in(self, text)
def _match_in(self, text)
A plugin for searching tests based on name, tags and documentation.
def enable(self)
This method is called by RIDE when the plugin is enabled.
def show_search_for(self, text)
def disable(self)
Called by RIDE when the plugin is disabled.
def _search_results(self, matcher)
def show_tag_search(self, message)
def show_search_for_tag_patterns(self, includes, excludes)
def _dialog_closed(self, event)
def _selected(self, selection)
def _do_with_selection(self, evt=None)
def _create_tests_dialog(self)
def _add_to_selected(self, tests)
def show_empty_search(self, event)
def _search(self, matcher, data)