generics.py
30 lines
| 707 B
| text/x-python
|
PythonLexer
Brian Granger
|
r2498 | # encoding: utf-8 | ||
Brian Granger
|
r2205 | """Generic functions for extending IPython. | ||
""" | ||||
vivainio
|
r851 | |||
Brian Granger
|
r2205 | from IPython.core.error import TryNext | ||
Hugo
|
r24687 | from functools import singledispatch | ||
Brian Granger
|
r2498 | |||
Hugo
|
r24687 | @singledispatch | ||
vivainio
|
r851 | def inspect_object(obj): | ||
Brian Granger
|
r2205 | """Called when you do obj?""" | ||
vivainio
|
r851 | raise TryNext | ||
vivainio
|
r908 | |||
Brian Granger
|
r2498 | |||
Hugo
|
r24687 | @singledispatch | ||
vivainio
|
r908 | def complete_object(obj, prev_completions): | ||
Brian Granger
|
r2205 | """Custom completer dispatching for python objects. | ||
Parameters | ||||
---------- | ||||
obj : object | ||||
The object to complete. | ||||
prev_completions : list | ||||
List of attributes discovered so far. | ||||
vivainio
|
r908 | This should return the list of attributes in obj. If you only wish to | ||
Bernardo B. Marques
|
r4872 | add to the attributes already discovered normally, return | ||
vivainio
|
r908 | own_attrs + prev_completions. | ||
""" | ||||
raise TryNext | ||||