generics.py
49 lines
| 1.4 KiB
| text/x-python
|
PythonLexer
Brian Granger
|
r2498 | # encoding: utf-8 | ||
Brian Granger
|
r2205 | """Generic functions for extending IPython. | ||
vivainio
|
r851 | |||
Fernando Perez
|
r1229 | See http://cheeseshop.python.org/pypi/simplegeneric. | ||
Brian Granger
|
r2205 | """ | ||
vivainio
|
r851 | |||
Brian Granger
|
r2498 | #----------------------------------------------------------------------------- | ||
# Copyright (C) 2008-2009 The IPython Development Team | ||||
# | ||||
# Distributed under the terms of the BSD License. The full license is in | ||||
# the file COPYING, distributed as part of this software. | ||||
#----------------------------------------------------------------------------- | ||||
#----------------------------------------------------------------------------- | ||||
# Imports | ||||
#----------------------------------------------------------------------------- | ||||
Brian Granger
|
r2205 | from IPython.core.error import TryNext | ||
Fernando Perez
|
r1229 | from IPython.external.simplegeneric import generic | ||
Brian Granger
|
r2498 | #----------------------------------------------------------------------------- | ||
# Imports | ||||
#----------------------------------------------------------------------------- | ||||
Brian Granger
|
r2205 | @generic | ||
vivainio
|
r851 | def inspect_object(obj): | ||
Brian Granger
|
r2205 | """Called when you do obj?""" | ||
vivainio
|
r851 | raise TryNext | ||
vivainio
|
r908 | |||
Brian Granger
|
r2498 | |||
Brian Granger
|
r2205 | @generic | ||
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 | ||
Brian Granger
|
r2205 | add to the attributes already discovered normally, return | ||
vivainio
|
r908 | own_attrs + prev_completions. | ||
""" | ||||
raise TryNext | ||||
Brian Granger
|
r2498 | |||