MCPcopy Create free account
hub / github.com/ipython/ipython / search

Method search

IPython/core/history.py:372–411  ·  view source on GitHub ↗

Search the database using unix glob-style matching (wildcards * and ?). Parameters ---------- pattern : str The wildcarded pattern to match when searching search_raw : bool If True, search the raw input, otherwise, the parsed input

(self, pattern="*", raw=True, search_raw=True,
               output=False, n=None, unique=False)

Source from the content-addressed store, hash-verified

370
371 @catch_corrupt_db
372 def search(self, pattern="*", raw=True, search_raw=True,
373 output=False, n=None, unique=False):
374 """Search the database using unix glob-style matching (wildcards
375 * and ?).
376
377 Parameters
378 ----------
379 pattern : str
380 The wildcarded pattern to match when searching
381 search_raw : bool
382 If True, search the raw input, otherwise, the parsed input
383 raw, output : bool
384 See :meth:`get_range`
385 n : None or int
386 If an integer is given, it defines the limit of
387 returned entries.
388 unique : bool
389 When it is true, return only unique entries.
390
391 Returns
392 -------
393 Tuples as :meth:`get_range`
394 """
395 tosearch = "source_raw" if search_raw else "source"
396 if output:
397 tosearch = "history." + tosearch
398 self.writeout_cache()
399 sqlform = "WHERE %s GLOB ?" % tosearch
400 params = (pattern,)
401 if unique:
402 sqlform += ' GROUP BY {0}'.format(tosearch)
403 if n is not None:
404 sqlform += " ORDER BY session DESC, line DESC LIMIT ?"
405 params += (n,)
406 elif unique:
407 sqlform += " ORDER BY session, line"
408 cur = self._run_sql(sqlform, params, raw=raw, output=output)
409 if n is not None:
410 return reversed(list(cur))
411 return cur
412
413 @catch_corrupt_db
414 def get_range(self, session, start=1, stop=None, raw=True,output=False):

Callers 15

grepMethod · 0.45
wrap_paragraphsFunction · 0.45
reset_selectiveMethod · 0.45
transformMethod · 0.45
match_dict_keysFunction · 0.45
dict_key_matchesMethod · 0.45
help_endFunction · 0.45
test_historyFunction · 0.45
historyMethod · 0.45
recallMethod · 0.45
rerunMethod · 0.45

Calls 3

writeout_cacheMethod · 0.95
_run_sqlMethod · 0.95
formatMethod · 0.45

Tested by 3

test_historyFunction · 0.36
check_outputMethod · 0.36
parseMethod · 0.36