MCPcopy Index your code
hub / github.com/ipython/ipython / search

Method search

IPython/core/history.py:478–524  ·  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: str = "*",
        raw: bool = True,
        search_raw: bool = True,
        output: bool = False,
        n: Optional[int] = None,
        unique: bool = False,
    )

Source from the content-addressed store, hash-verified

476
477 @catch_corrupt_db
478 def search(
479 self,
480 pattern: str = "*",
481 raw: bool = True,
482 search_raw: bool = True,
483 output: bool = False,
484 n: Optional[int] = None,
485 unique: bool = False,
486 ) -> Iterable[tuple[int, int, InOrInOut]]:
487 """Search the database using unix glob-style matching (wildcards
488 * and ?).
489
490 Parameters
491 ----------
492 pattern : str
493 The wildcarded pattern to match when searching
494 search_raw : bool
495 If True, search the raw input, otherwise, the parsed input
496 raw, output : bool
497 See :meth:`get_range`
498 n : None or int
499 If an integer is given, it defines the limit of
500 returned entries.
501 unique : bool
502 When it is true, return only unique entries.
503
504 Returns
505 -------
506 Tuples as :meth:`get_range`
507 """
508 tosearch = "source_raw" if search_raw else "source"
509 if output:
510 tosearch = "history." + tosearch
511 self.writeout_cache()
512 sqlform = "WHERE %s GLOB ?" % tosearch
513 params: tuple[typing.Any, ...] = (pattern,)
514 if unique:
515 sqlform += " GROUP BY {0}".format(tosearch)
516 if n is not None:
517 sqlform += " ORDER BY session DESC, line DESC LIMIT ?"
518 params += (n,)
519 elif unique:
520 sqlform += " ORDER BY session, line"
521 cur = self._run_sql(sqlform, params, raw=raw, output=output, latest=unique)
522 if n is not None:
523 return reversed(list(cur))
524 return cur
525
526 @catch_corrupt_db
527 def get_range(

Callers 15

grepMethod · 0.45
init_virtualenvMethod · 0.45
reset_selectiveMethod · 0.45
transformMethod · 0.45
match_dict_keysFunction · 0.45
dict_key_matchesMethod · 0.45
historyMethod · 0.45
recallMethod · 0.45
rerunMethod · 0.45
reset_selectiveMethod · 0.45

Calls 3

writeout_cacheMethod · 0.95
_run_sqlMethod · 0.95
formatMethod · 0.45

Tested by 5

check_outputMethod · 0.36
parseMethod · 0.36
test_historyFunction · 0.36
test_infoFunction · 0.36