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 setup(text): """Create window for Find""" root = text._root() engine = searchengine.get(root) if not hasattr(engine, "_searchdialog"): engine._searchdialog = SearchDialog(root, engine) return engine._searchdialog
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 replace(text): """Create window for Replace""" root = text._root() engine = searchengine.get(root) if not hasattr(engine, "_replacedialog"): engine._replacedialog = ReplaceDialog(root, engine) dialog = engine._replacedialog dialog.open(text)
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 __init__(self, parent): import re from idlelib import searchengine self.root = parent self.engine = searchengine.get(parent) self.create_widgets() print(parent.geometry()) width,height, x,y = list(map(int, re.split('[x+]', parent.geometry()))) self.top.geometry("+%d+%d" % (x + 40, y + 175))
def _setup(text): """Return the new or existing singleton SearchDialog instance. The singleton dialog saves user entries and preferences across instances. Args: text: Text widget containing the text to be searched. """ root = text._root() engine = searchengine.get(root) if not hasattr(engine, "_searchdialog"): engine._searchdialog = SearchDialog(root, engine) return engine._searchdialog
def replace(text): """Create or reuse a singleton ReplaceDialog instance. The singleton dialog saves user entries and preferences across instances. Args: text: Text widget containing the text to be searched. """ root = text._root() engine = searchengine.get(root) if not hasattr(engine, "_replacedialog"): engine._replacedialog = ReplaceDialog(root, engine) dialog = engine._replacedialog dialog.open(text)
def grep(text, io=None, flist=None): """Create or find singleton GrepDialog instance. Args: text: Text widget that contains the selected text for default search phrase. io: iomenu.IOBinding instance with default path to search. flist: filelist.FileList instance for OutputWindow parent. """ 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): """Open the Find in Files dialog. Module-level function to access the singleton GrepDialog instance and open the dialog. If text is selected, it is used as the search phrase; otherwise, the previous entry is used. Args: text: Text widget that contains the selected text for default search phrase. io: iomenu.IOBinding instance with default path to search. flist: filelist.FileList instance for OutputWindow parent. """ 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)