def test_get(self): saved_Engine = se.SearchEngine se.SearchEngine = Mock try: root = Mock() engine = se.get(root) self.assertIsInstance(engine, se.SearchEngine) self.assertIs(root._searchengine, engine) self.assertIs(se.get(root), engine) finally: se.SearchEngine = saved_Engine
def test_get(self): saved_Engine = se.SearchEngine se.SearchEngine = Mock # monkey-patch class try: root = Mock() engine = se.get(root) self.assertIsInstance(engine, se.SearchEngine) self.assertIs(root._searchengine, engine) self.assertIs(se.get(root), engine) finally: se.SearchEngine = saved_Engine # restore class to module
def replace(text): root = text._root() engine = SearchEngine.get(root) if not hasattr(engine, "_replacedialog"): engine._replacedialog = ReplaceDialog(root, engine) dialog = engine._replacedialog dialog.open(text)
def _setup(text): "Create or find the singleton SearchDialog instance." root = text._root() engine = SearchEngine.get(root) if not hasattr(engine, "_searchdialog"): engine._searchdialog = SearchDialog(root, engine) return engine._searchdialog
def grep(text, io=None, flist=None): root = text._root() engine = SearchEngine.get(root) if not hasattr(engine, "_grepdialog"): engine._grepdialog = GrepDialog(root, engine, flist) dialog = engine._grepdialog searchphrase = text.get("sel.first", "sel.last") dialog.open(text, searchphrase, io)
def grep(text, io=None, flist=None): root = text._root() engine = SearchEngine.get(root) if not hasattr(engine, '_grepdialog'): engine._grepdialog = GrepDialog(root, engine, flist) dialog = engine._grepdialog searchphrase = text.get('sel.first', 'sel.last') dialog.open(text, searchphrase, io)
def replace(text): """Returns a singleton ReplaceDialog instance.The single dialog saves user entries and preferences across instances.""" root = text._root() engine = SearchEngine.get(root) if not hasattr(engine, "_replacedialog"): engine._replacedialog = ReplaceDialog(root, engine) dialog = engine._replacedialog dialog.open(text)
def _setup(text): root = text._root() engine = SearchEngine.get(root) if not hasattr(engine, "_searchdialog"): engine._searchdialog = SearchDialog(root, engine) return engine._searchdialog
def _setup(text): root = text._root() engine = SearchEngine.get(root) if not hasattr(engine, '_searchdialog'): engine._searchdialog = SearchDialog(root, engine) return engine._searchdialog