Show More
@@ -173,6 +173,9 b' class NamespaceMagics(Magics):' | |||||
173 | 'builtin', 'user', 'user_global','internal', 'alias', where |
|
173 | 'builtin', 'user', 'user_global','internal', 'alias', where | |
174 | 'builtin' and 'user' are the search defaults. Note that you should |
|
174 | 'builtin' and 'user' are the search defaults. Note that you should | |
175 | not use quotes when specifying namespaces. |
|
175 | not use quotes when specifying namespaces. | |
|
176 | ||||
|
177 | -l: List all available object types for object matching. This function | |||
|
178 | can be used without arguments. | |||
176 |
|
179 | |||
177 | 'Builtin' contains the python module builtin, 'user' contains all |
|
180 | 'Builtin' contains the python module builtin, 'user' contains all | |
178 | user data, 'alias' only contain the shell aliases and no python |
|
181 | user data, 'alias' only contain the shell aliases and no python | |
@@ -200,6 +203,10 b' class NamespaceMagics(Magics):' | |||||
200 | Show objects beginning with a single _:: |
|
203 | Show objects beginning with a single _:: | |
201 |
|
204 | |||
202 | %psearch -a _* list objects beginning with a single underscore |
|
205 | %psearch -a _* list objects beginning with a single underscore | |
|
206 | ||||
|
207 | List available objects:: | |||
|
208 | ||||
|
209 | %psearch -l list all available object types | |||
203 | """ |
|
210 | """ | |
204 | try: |
|
211 | try: | |
205 | parameter_s.encode('ascii') |
|
212 | parameter_s.encode('ascii') | |
@@ -211,10 +218,15 b' class NamespaceMagics(Magics):' | |||||
211 | def_search = ['user_local', 'user_global', 'builtin'] |
|
218 | def_search = ['user_local', 'user_global', 'builtin'] | |
212 |
|
219 | |||
213 | # Process options/args |
|
220 | # Process options/args | |
214 | opts,args = self.parse_options(parameter_s,'cias:e:',list_all=True) |
|
221 | opts,args = self.parse_options(parameter_s,'cias:e:l',list_all=True) | |
215 | opt = opts.get |
|
222 | opt = opts.get | |
216 | shell = self.shell |
|
223 | shell = self.shell | |
217 | psearch = shell.inspector.psearch |
|
224 | psearch = shell.inspector.psearch | |
|
225 | ||||
|
226 | # select list object types | |||
|
227 | list_types = False | |||
|
228 | if 'l' in opts: | |||
|
229 | list_types = True | |||
218 |
|
230 | |||
219 | # select case options |
|
231 | # select case options | |
220 | if 'i' in opts: |
|
232 | if 'i' in opts: | |
@@ -232,7 +244,7 b' class NamespaceMagics(Magics):' | |||||
232 | # Call the actual search |
|
244 | # Call the actual search | |
233 | try: |
|
245 | try: | |
234 | psearch(args,shell.ns_table,ns_search, |
|
246 | psearch(args,shell.ns_table,ns_search, | |
235 | show_all=opt('a'),ignore_case=ignore_case) |
|
247 | show_all=opt('a'),ignore_case=ignore_case, list_types=list_types) | |
236 | except: |
|
248 | except: | |
237 | shell.showtraceback() |
|
249 | shell.showtraceback() | |
238 |
|
250 |
@@ -35,6 +35,7 b' from IPython.utils.dir2 import safe_hasattr' | |||||
35 | from IPython.utils.path import compress_user |
|
35 | from IPython.utils.path import compress_user | |
36 | from IPython.utils.text import indent |
|
36 | from IPython.utils.text import indent | |
37 | from IPython.utils.wildcard import list_namespace |
|
37 | from IPython.utils.wildcard import list_namespace | |
|
38 | from IPython.utils.wildcard import typestr2type | |||
38 | from IPython.utils.coloransi import TermColors, ColorScheme, ColorSchemeTable |
|
39 | from IPython.utils.coloransi import TermColors, ColorScheme, ColorSchemeTable | |
39 | from IPython.utils.py3compat import cast_unicode |
|
40 | from IPython.utils.py3compat import cast_unicode | |
40 | from IPython.utils.colorable import Colorable |
|
41 | from IPython.utils.colorable import Colorable | |
@@ -962,7 +963,7 b' class Inspector(Colorable):' | |||||
962 | return False |
|
963 | return False | |
963 |
|
964 | |||
964 | def psearch(self,pattern,ns_table,ns_search=[], |
|
965 | def psearch(self,pattern,ns_table,ns_search=[], | |
965 | ignore_case=False,show_all=False): |
|
966 | ignore_case=False,show_all=False, list_types=False): | |
966 | """Search namespaces with wildcards for objects. |
|
967 | """Search namespaces with wildcards for objects. | |
967 |
|
968 | |||
968 | Arguments: |
|
969 | Arguments: | |
@@ -981,6 +982,8 b' class Inspector(Colorable):' | |||||
981 |
|
982 | |||
982 | - show_all(False): show all names, including those starting with |
|
983 | - show_all(False): show all names, including those starting with | |
983 | underscores. |
|
984 | underscores. | |
|
985 | ||||
|
986 | - list_types(False): list all available object types for object matching. | |||
984 | """ |
|
987 | """ | |
985 | #print 'ps pattern:<%r>' % pattern # dbg |
|
988 | #print 'ps pattern:<%r>' % pattern # dbg | |
986 |
|
989 | |||
@@ -988,6 +991,11 b' class Inspector(Colorable):' | |||||
988 | type_pattern = 'all' |
|
991 | type_pattern = 'all' | |
989 | filter = '' |
|
992 | filter = '' | |
990 |
|
993 | |||
|
994 | # list all object types | |||
|
995 | if list_types: | |||
|
996 | page.page('\n'.join(sorted(typestr2type))) | |||
|
997 | return | |||
|
998 | ||||
991 | cmds = pattern.split() |
|
999 | cmds = pattern.split() | |
992 | len_cmds = len(cmds) |
|
1000 | len_cmds = len(cmds) | |
993 | if len_cmds == 1: |
|
1001 | if len_cmds == 1: |
General Comments 0
You need to be logged in to leave comments.
Login now