##// END OF EJS Templates
wildcard fixes for subclasses
fperez -
Show More
@@ -1,7 +1,7 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """Magic functions for InteractiveShell.
2 """Magic functions for InteractiveShell.
3
3
4 $Id: Magic.py 919 2005-10-15 07:57:05Z fperez $"""
4 $Id: Magic.py 922 2005-11-13 10:21:08Z fperez $"""
5
5
6 #*****************************************************************************
6 #*****************************************************************************
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
7 # Copyright (C) 2001 Janko Hauser <jhauser@zscout.de> and
@@ -816,7 +816,7 b' Currently the magic system has the following functions:\\n"""'
816 array_type = Numeric.ArrayType.__name__
816 array_type = Numeric.ArrayType.__name__
817
817
818 # Find all variable names and types so we can figure out column sizes
818 # Find all variable names and types so we can figure out column sizes
819 get_vars = lambda i: self.locals[i]
819 get_vars = lambda i: self.shell.user_ns[i]
820 type_name = lambda v: type(v).__name__
820 type_name = lambda v: type(v).__name__
821 varlist = map(get_vars,varnames)
821 varlist = map(get_vars,varnames)
822 typelist = map(type_name,varlist)
822 typelist = map(type_name,varlist)
@@ -871,8 +871,9 b' Currently the magic system has the following functions:\\n"""'
871 if not ans.lower() == 'y':
871 if not ans.lower() == 'y':
872 print 'Nothing done.'
872 print 'Nothing done.'
873 return
873 return
874 user_ns = self.shell.user_ns
874 for i in self.magic_who_ls():
875 for i in self.magic_who_ls():
875 del(self.locals[i])
876 del(user_ns[i])
876
877
877 def magic_config(self,parameter_s=''):
878 def magic_config(self,parameter_s=''):
878 """Show IPython's internal configuration."""
879 """Show IPython's internal configuration."""
@@ -6,7 +6,7 b' Uses syntax highlighting for presenting the various information elements.'
6 Similar in spirit to the inspect module, but all calls take a name argument to
6 Similar in spirit to the inspect module, but all calls take a name argument to
7 reference the name under which an object is being read.
7 reference the name under which an object is being read.
8
8
9 $Id: OInspect.py 919 2005-10-15 07:57:05Z fperez $
9 $Id: OInspect.py 922 2005-11-13 10:21:08Z fperez $
10 """
10 """
11
11
12 #*****************************************************************************
12 #*****************************************************************************
@@ -403,40 +403,40 b' class Inspector:'
403
403
404 Optional arguments:
404 Optional arguments:
405
405
406 - oname: rest of the commandline containging pattern and options
406 - oname: rest of the commandline containging pattern and options.
407
407
408 - formatter: Not used
408 - formatter: Not used.
409
410 - shell: The shell object from the Magic class. Needed to
411 access the namespaces
412
409
410 - shell: The shell object from the Magic class. Needed to access
411 the namespaces.
413 """
412 """
414 option_list=["-c","-a"]
413 option_list = ['-c','-a']
415 import pdb
416 # pdb.set_trace()
417 cmds=oname.split()
414 cmds = oname.split()
418 filter=""
415 filter = ''
419 type_pattern="all"
416 type_pattern = 'all'
420 ns_cmds=[]
421 options=[x for x in cmds if x in option_list]
417 options = [x for x in cmds if x in option_list]
422 ignorecase="-c" not in options
418 ignorecase = '-c' not in options
423 showhidden="-a" in options
419 showhidden = '-a' in options
424 ns_cmds=[x for x in cmds if x[0] in "-+" and x not in option_list]
420 ns_cmds = [x for x in cmds if x[0] in '-+' and x not in option_list]
425 cmds=[x for x in cmds if x[0] not in "-+"]
421 cmds = [x for x in cmds if x[0] not in '-+']
426 if len(cmds)>2: #assume we want to choose name spaces.
422 len_cmds = len(cmds)
427 #Rather poor design forces the use of a typepattern in order to choose name spaces
423 if len_cmds == 1:
428 cmds=cmds[:2]
429 if len(cmds)==2:
430 filter,type_pattern=cmds
431 elif len(cmds)==1:
432 filter=cmds[0].strip()
424 filter = cmds[0].strip()
425 elif len_cmds == 2:
426 filter,type_pattern = cmds
427 elif len_cmds>2:
428 # assume we want to choose name spaces. Rather poor design forces
429 #the use of a typepattern in order to choose name spaces
430 cmds = cmds[:2]
433
431
434 do_list=choose_namespaces(shell,ns_cmds)
432 do_list = choose_namespaces(shell,ns_cmds)
435
433
436 search_result=[]
434 search_result = []
437 for ns in do_list:
435 for ns in do_list:
438 tmp_res=list(list_namespace(ns,type_pattern,filter,ignorecase=ignorecase,showhidden=showhidden))
436 tmp_res = list(list_namespace(ns,type_pattern,filter,
437 ignorecase=ignorecase,
438 showhidden=showhidden))
439 search_result.extend(tmp_res)
439 search_result.extend(tmp_res)
440 search_result.sort()
440 search_result.sort()
441
441
442 page("\n".join(search_result))
442 page('\n'.join(search_result))
@@ -74,14 +74,13 b' class NameSpace(object):'
74 self.namepattern=namepattern
74 self.namepattern = namepattern
75 self.typepattern=typepattern
75 self.typepattern = typepattern
76 self.ignorecase=ignorecase
76 self.ignorecase = ignorecase
77 if type(obj)==type(dict()):
77
78 # We should only match EXACT dicts here, so DON'T use isinstance()
79 if type(obj) == types.DictType:
78 self._ns=obj
80 self._ns = obj
79 else:
81 else:
80 try:
82 self._ns = dict([(key,getattr(obj,key)) for key in dir(obj)
81 self._ns=self.object.__dict__
83 if isinstance(key, basestring)])
82 except exceptions.AttributeError:
83 self._ns=dict([(key,getattr(self.object,key))
84 for key in dir(self.object)])
85
84
86 def get_ns(self):
85 def get_ns(self):
87 """Return name space dictionary with objects matching type and name patterns."""
86 """Return name space dictionary with objects matching type and name patterns."""
@@ -1,3 +1,9 b''
1 2005-11-13 <Fernando.Perez@colorado.edu>
2
3 * IPython/wildcard.py (NameSpace.__init__): fix resolution of
4 attributes in wildcard searches for subclasses. Modified version
5 of a patch by Jorgen.
6
1 2005-11-12 <Fernando.Perez@colorado.edu>
7 2005-11-12 <Fernando.Perez@colorado.edu>
2
8
3 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
9 * IPython/iplib.py (embed_mainloop): Fix handling of globals for
General Comments 0
You need to be logged in to leave comments. Login now