##// END OF EJS Templates
- Small tab-completion bug fix for Enthought objects.
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 2036 2007-01-27 07:30:22Z fperez $"""
4 $Id: Magic.py 2066 2007-01-31 18:56:06Z 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
@@ -3068,5 +3068,4 b' Defaulting color scheme to \'NoColor\'"""'
3068 suffix = (sys.platform == 'win32' and '.ini' or '')
3068 suffix = (sys.platform == 'win32' and '.ini' or '')
3069 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3069 (userdir / ('ipythonrc' + suffix)).write_text('# Empty, see ipy_user_conf.py\n')
3070
3070
3071
3072 # end Magic
3071 # end Magic
@@ -215,13 +215,15 b' class Completer:'
215 words.append('__class__')
215 words.append('__class__')
216 words.extend(get_class_members(object.__class__))
216 words.extend(get_class_members(object.__class__))
217
217
218 # Some libraries (such as traits) may introduce duplicates, we want to
219 # track and clean this up if it happens
220 may_have_dupes = False
221
218 # this is the 'dir' function for objects with Enthought's traits
222 # this is the 'dir' function for objects with Enthought's traits
219 if hasattr(object, 'trait_names'):
223 if hasattr(object, 'trait_names'):
220 try:
224 try:
221 words.extend(object.trait_names())
225 words.extend(object.trait_names())
222 # eliminate possible duplicates, as some traits may also
226 may_have_dupes = True
223 # appear as normal attributes in the dir() call.
224 words = set(words)
225 except TypeError:
227 except TypeError:
226 # This will happen if `object` is a class and not an instance.
228 # This will happen if `object` is a class and not an instance.
227 pass
229 pass
@@ -230,13 +232,17 b' class Completer:'
230 if hasattr(object, '_getAttributeNames'):
232 if hasattr(object, '_getAttributeNames'):
231 try:
233 try:
232 words.extend(object._getAttributeNames())
234 words.extend(object._getAttributeNames())
233 # Eliminate duplicates.
235 may_have_dupes = True
234 words = set(words)
235 except TypeError:
236 except TypeError:
236 # `object` is a class and not an instance. Ignore
237 # `object` is a class and not an instance. Ignore
237 # this error.
238 # this error.
238 pass
239 pass
239
240
241 if may_have_dupes:
242 # eliminate possible duplicates, as some traits may also
243 # appear as normal attributes in the dir() call.
244 words = set(words)
245
240 # filter out non-string attributes which may be stuffed by dir() calls
246 # filter out non-string attributes which may be stuffed by dir() calls
241 # and poor coding in third-party modules
247 # and poor coding in third-party modules
242 words = [w for w in words
248 words = [w for w in words
@@ -372,6 +372,7 b' class Demo:'
372 print marquee('Executing silent block # %s (%s remaining)' %
372 print marquee('Executing silent block # %s (%s remaining)' %
373 (index,self.nblocks-index-1))
373 (index,self.nblocks-index-1))
374 else:
374 else:
375 self.pre_cmd()
375 self.show(index)
376 self.show(index)
376 if self.auto_all or self._auto[index]:
377 if self.auto_all or self._auto[index]:
377 print marquee('output')
378 print marquee('output')
@@ -384,7 +385,6 b' class Demo:'
384 try:
385 try:
385 save_argv = sys.argv
386 save_argv = sys.argv
386 sys.argv = self.sys_argv
387 sys.argv = self.sys_argv
387 self.pre_cmd()
388 self.runlines(next_block)
388 self.runlines(next_block)
389 self.post_cmd()
389 self.post_cmd()
390 finally:
390 finally:
@@ -1,3 +1,10 b''
1 2007-01-31 Fernando Perez <Fernando.Perez@colorado.edu>
2
3 * IPython/completer.py (Completer.attr_matches): Fix small
4 tab-completion bug with Enthought Traits objects with units.
5 Thanks to a bug report by Tom Denniston
6 <tom.denniston-AT-alum.dartmouth.org>.
7
1 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
8 2007-01-27 Fernando Perez <Fernando.Perez@colorado.edu>
2
9
3 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
10 * IPython/Extensions/ipy_stock_completers.py (runlistpy): fix a
General Comments 0
You need to be logged in to leave comments. Login now