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)
| 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): |