##// END OF EJS Templates
apply Matthew Neeley's patch to sort the attribute names properly when the dupes have been removed
vivainio -
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,673 +1,674 b''
1 1 """Word completion for IPython.
2 2
3 3 This module is a fork of the rlcompleter module in the Python standard
4 4 library. The original enhancements made to rlcompleter have been sent
5 5 upstream and were accepted as of Python 2.3, but we need a lot more
6 6 functionality specific to IPython, so this module will continue to live as an
7 7 IPython-specific utility.
8 8
9 9 ---------------------------------------------------------------------------
10 10 Original rlcompleter documentation:
11 11
12 12 This requires the latest extension to the readline module (the
13 13 completes keywords, built-ins and globals in __main__; when completing
14 14 NAME.NAME..., it evaluates (!) the expression up to the last dot and
15 15 completes its attributes.
16 16
17 17 It's very cool to do "import string" type "string.", hit the
18 18 completion key (twice), and see the list of names defined by the
19 19 string module!
20 20
21 21 Tip: to use the tab key as the completion key, call
22 22
23 23 readline.parse_and_bind("tab: complete")
24 24
25 25 Notes:
26 26
27 27 - Exceptions raised by the completer function are *ignored* (and
28 28 generally cause the completion to fail). This is a feature -- since
29 29 readline sets the tty device in raw (or cbreak) mode, printing a
30 30 traceback wouldn't work well without some complicated hoopla to save,
31 31 reset and restore the tty state.
32 32
33 33 - The evaluation of the NAME.NAME... form may cause arbitrary
34 34 application defined code to be executed if an object with a
35 35 __getattr__ hook is found. Since it is the responsibility of the
36 36 application (or the user) to enable this feature, I consider this an
37 37 acceptable risk. More complicated expressions (e.g. function calls or
38 38 indexing operations) are *not* evaluated.
39 39
40 40 - GNU readline is also used by the built-in functions input() and
41 41 raw_input(), and thus these also benefit/suffer from the completer
42 42 features. Clearly an interactive application can benefit by
43 43 specifying its own completer function and using raw_input() for all
44 44 its input.
45 45
46 46 - When the original stdin is not a tty device, GNU readline is never
47 47 used, and this module (and the readline module) are silently inactive.
48 48
49 49 """
50 50
51 51 #*****************************************************************************
52 52 #
53 53 # Since this file is essentially a minimally modified copy of the rlcompleter
54 54 # module which is part of the standard Python distribution, I assume that the
55 55 # proper procedure is to maintain its copyright as belonging to the Python
56 56 # Software Foundation (in addition to my own, for all new code).
57 57 #
58 58 # Copyright (C) 2001 Python Software Foundation, www.python.org
59 59 # Copyright (C) 2001-2006 Fernando Perez. <fperez@colorado.edu>
60 60 #
61 61 # Distributed under the terms of the BSD License. The full license is in
62 62 # the file COPYING, distributed as part of this software.
63 63 #
64 64 #*****************************************************************************
65 65
66 66 import __builtin__
67 67 import __main__
68 68 import glob
69 69 import keyword
70 70 import os
71 71 import re
72 72 import shlex
73 73 import sys
74 74 import IPython.rlineimpl as readline
75 75 import itertools
76 76 from IPython.ipstruct import Struct
77 77 from IPython import ipapi
78 78
79 79 import types
80 80
81 81 # Python 2.4 offers sets as a builtin
82 82 try:
83 83 set([1,2])
84 84 except NameError:
85 85 from sets import Set as set
86 86
87 87 from IPython.genutils import debugx
88 88
89 89 __all__ = ['Completer','IPCompleter']
90 90
91 91 def get_class_members(cls):
92 92 ret = dir(cls)
93 93 if hasattr(cls,'__bases__'):
94 94 for base in cls.__bases__:
95 95 ret.extend(get_class_members(base))
96 96 return ret
97 97
98 98 class Completer:
99 99 def __init__(self,namespace=None,global_namespace=None):
100 100 """Create a new completer for the command line.
101 101
102 102 Completer([namespace,global_namespace]) -> completer instance.
103 103
104 104 If unspecified, the default namespace where completions are performed
105 105 is __main__ (technically, __main__.__dict__). Namespaces should be
106 106 given as dictionaries.
107 107
108 108 An optional second namespace can be given. This allows the completer
109 109 to handle cases where both the local and global scopes need to be
110 110 distinguished.
111 111
112 112 Completer instances should be used as the completion mechanism of
113 113 readline via the set_completer() call:
114 114
115 115 readline.set_completer(Completer(my_namespace).complete)
116 116 """
117 117
118 118 # some minimal strict typechecks. For some core data structures, I
119 119 # want actual basic python types, not just anything that looks like
120 120 # one. This is especially true for namespaces.
121 121 for ns in (namespace,global_namespace):
122 122 if ns is not None and type(ns) != types.DictType:
123 123 raise TypeError,'namespace must be a dictionary'
124 124
125 125 # Don't bind to namespace quite yet, but flag whether the user wants a
126 126 # specific namespace or to use __main__.__dict__. This will allow us
127 127 # to bind to __main__.__dict__ at completion time, not now.
128 128 if namespace is None:
129 129 self.use_main_ns = 1
130 130 else:
131 131 self.use_main_ns = 0
132 132 self.namespace = namespace
133 133
134 134 # The global namespace, if given, can be bound directly
135 135 if global_namespace is None:
136 136 self.global_namespace = {}
137 137 else:
138 138 self.global_namespace = global_namespace
139 139
140 140 def complete(self, text, state):
141 141 """Return the next possible completion for 'text'.
142 142
143 143 This is called successively with state == 0, 1, 2, ... until it
144 144 returns None. The completion should begin with 'text'.
145 145
146 146 """
147 147 if self.use_main_ns:
148 148 self.namespace = __main__.__dict__
149 149
150 150 if state == 0:
151 151 if "." in text:
152 152 self.matches = self.attr_matches(text)
153 153 else:
154 154 self.matches = self.global_matches(text)
155 155 try:
156 156 return self.matches[state]
157 157 except IndexError:
158 158 return None
159 159
160 160 def global_matches(self, text):
161 161 """Compute matches when text is a simple name.
162 162
163 163 Return a list of all keywords, built-in functions and names currently
164 164 defined in self.namespace or self.global_namespace that match.
165 165
166 166 """
167 167 matches = []
168 168 match_append = matches.append
169 169 n = len(text)
170 170 for lst in [keyword.kwlist,
171 171 __builtin__.__dict__.keys(),
172 172 self.namespace.keys(),
173 173 self.global_namespace.keys()]:
174 174 for word in lst:
175 175 if word[:n] == text and word != "__builtins__":
176 176 match_append(word)
177 177 return matches
178 178
179 179 def attr_matches(self, text):
180 180 """Compute matches when text contains a dot.
181 181
182 182 Assuming the text is of the form NAME.NAME....[NAME], and is
183 183 evaluatable in self.namespace or self.global_namespace, it will be
184 184 evaluated and its attributes (as revealed by dir()) are used as
185 185 possible completions. (For class instances, class members are are
186 186 also considered.)
187 187
188 188 WARNING: this can still invoke arbitrary C code, if an object
189 189 with a __getattr__ hook is evaluated.
190 190
191 191 """
192 192 import re
193 193
194 194 # Another option, seems to work great. Catches things like ''.<tab>
195 195 m = re.match(r"(\S+(\.\w+)*)\.(\w*)$", text)
196 196
197 197 if not m:
198 198 return []
199 199
200 200 expr, attr = m.group(1, 3)
201 201 try:
202 202 object = eval(expr, self.namespace)
203 203 except:
204 204 try:
205 205 object = eval(expr, self.global_namespace)
206 206 except:
207 207 return []
208 208
209 209
210 210 # Start building the attribute list via dir(), and then complete it
211 211 # with a few extra special-purpose calls.
212 212 words = dir(object)
213 213
214 214 if hasattr(object,'__class__'):
215 215 words.append('__class__')
216 216 words.extend(get_class_members(object.__class__))
217 217
218 218 # Some libraries (such as traits) may introduce duplicates, we want to
219 219 # track and clean this up if it happens
220 220 may_have_dupes = False
221 221
222 222 # this is the 'dir' function for objects with Enthought's traits
223 223 if hasattr(object, 'trait_names'):
224 224 try:
225 225 words.extend(object.trait_names())
226 226 may_have_dupes = True
227 227 except TypeError:
228 228 # This will happen if `object` is a class and not an instance.
229 229 pass
230 230
231 231 # Support for PyCrust-style _getAttributeNames magic method.
232 232 if hasattr(object, '_getAttributeNames'):
233 233 try:
234 234 words.extend(object._getAttributeNames())
235 235 may_have_dupes = True
236 236 except TypeError:
237 237 # `object` is a class and not an instance. Ignore
238 238 # this error.
239 239 pass
240 240
241 241 if may_have_dupes:
242 242 # eliminate possible duplicates, as some traits may also
243 243 # appear as normal attributes in the dir() call.
244 words = set(words)
244 words = list(set(words))
245 words.sort()
245 246
246 247 # filter out non-string attributes which may be stuffed by dir() calls
247 248 # and poor coding in third-party modules
248 249 words = [w for w in words
249 250 if isinstance(w, basestring) and w != "__builtins__"]
250 251 # Build match list to return
251 252 n = len(attr)
252 253 return ["%s.%s" % (expr, w) for w in words if w[:n] == attr ]
253 254
254 255 class IPCompleter(Completer):
255 256 """Extension of the completer class with IPython-specific features"""
256 257
257 258 def __init__(self,shell,namespace=None,global_namespace=None,
258 259 omit__names=0,alias_table=None):
259 260 """IPCompleter() -> completer
260 261
261 262 Return a completer object suitable for use by the readline library
262 263 via readline.set_completer().
263 264
264 265 Inputs:
265 266
266 267 - shell: a pointer to the ipython shell itself. This is needed
267 268 because this completer knows about magic functions, and those can
268 269 only be accessed via the ipython instance.
269 270
270 271 - namespace: an optional dict where completions are performed.
271 272
272 273 - global_namespace: secondary optional dict for completions, to
273 274 handle cases (such as IPython embedded inside functions) where
274 275 both Python scopes are visible.
275 276
276 277 - The optional omit__names parameter sets the completer to omit the
277 278 'magic' names (__magicname__) for python objects unless the text
278 279 to be completed explicitly starts with one or more underscores.
279 280
280 281 - If alias_table is supplied, it should be a dictionary of aliases
281 282 to complete. """
282 283
283 284 Completer.__init__(self,namespace,global_namespace)
284 285 self.magic_prefix = shell.name+'.magic_'
285 286 self.magic_escape = shell.ESC_MAGIC
286 287 self.readline = readline
287 288 delims = self.readline.get_completer_delims()
288 289 delims = delims.replace(self.magic_escape,'')
289 290 self.readline.set_completer_delims(delims)
290 291 self.get_line_buffer = self.readline.get_line_buffer
291 292 self.omit__names = omit__names
292 293 self.merge_completions = shell.rc.readline_merge_completions
293 294
294 295 if alias_table is None:
295 296 alias_table = {}
296 297 self.alias_table = alias_table
297 298 # Regexp to split filenames with spaces in them
298 299 self.space_name_re = re.compile(r'([^\\] )')
299 300 # Hold a local ref. to glob.glob for speed
300 301 self.glob = glob.glob
301 302
302 303 # Determine if we are running on 'dumb' terminals, like (X)Emacs
303 304 # buffers, to avoid completion problems.
304 305 term = os.environ.get('TERM','xterm')
305 306 self.dumb_terminal = term in ['dumb','emacs']
306 307
307 308 # Special handling of backslashes needed in win32 platforms
308 309 if sys.platform == "win32":
309 310 self.clean_glob = self._clean_glob_win32
310 311 else:
311 312 self.clean_glob = self._clean_glob
312 313 self.matchers = [self.python_matches,
313 314 self.file_matches,
314 315 self.alias_matches,
315 316 self.python_func_kw_matches]
316 317
317 318 # Code contributed by Alex Schmolck, for ipython/emacs integration
318 319 def all_completions(self, text):
319 320 """Return all possible completions for the benefit of emacs."""
320 321
321 322 completions = []
322 323 comp_append = completions.append
323 324 try:
324 325 for i in xrange(sys.maxint):
325 326 res = self.complete(text, i)
326 327
327 328 if not res: break
328 329
329 330 comp_append(res)
330 331 #XXX workaround for ``notDefined.<tab>``
331 332 except NameError:
332 333 pass
333 334 return completions
334 335 # /end Alex Schmolck code.
335 336
336 337 def _clean_glob(self,text):
337 338 return self.glob("%s*" % text)
338 339
339 340 def _clean_glob_win32(self,text):
340 341 return [f.replace("\\","/")
341 342 for f in self.glob("%s*" % text)]
342 343
343 344 def file_matches(self, text):
344 345 """Match filenames, expanding ~USER type strings.
345 346
346 347 Most of the seemingly convoluted logic in this completer is an
347 348 attempt to handle filenames with spaces in them. And yet it's not
348 349 quite perfect, because Python's readline doesn't expose all of the
349 350 GNU readline details needed for this to be done correctly.
350 351
351 352 For a filename with a space in it, the printed completions will be
352 353 only the parts after what's already been typed (instead of the
353 354 full completions, as is normally done). I don't think with the
354 355 current (as of Python 2.3) Python readline it's possible to do
355 356 better."""
356 357
357 358 #print 'Completer->file_matches: <%s>' % text # dbg
358 359
359 360 # chars that require escaping with backslash - i.e. chars
360 361 # that readline treats incorrectly as delimiters, but we
361 362 # don't want to treat as delimiters in filename matching
362 363 # when escaped with backslash
363 364
364 365 protectables = ' ()[]{}'
365 366
366 367 if text.startswith('!'):
367 368 text = text[1:]
368 369 text_prefix = '!'
369 370 else:
370 371 text_prefix = ''
371 372
372 373 def protect_filename(s):
373 374 return "".join([(ch in protectables and '\\' + ch or ch)
374 375 for ch in s])
375 376
376 377 def single_dir_expand(matches):
377 378 "Recursively expand match lists containing a single dir."
378 379
379 380 if len(matches) == 1 and os.path.isdir(matches[0]):
380 381 # Takes care of links to directories also. Use '/'
381 382 # explicitly, even under Windows, so that name completions
382 383 # don't end up escaped.
383 384 d = matches[0]
384 385 if d[-1] in ['/','\\']:
385 386 d = d[:-1]
386 387
387 388 subdirs = os.listdir(d)
388 389 if subdirs:
389 390 matches = [ (d + '/' + p) for p in subdirs]
390 391 return single_dir_expand(matches)
391 392 else:
392 393 return matches
393 394 else:
394 395 return matches
395 396
396 397 lbuf = self.lbuf
397 398 open_quotes = 0 # track strings with open quotes
398 399 try:
399 400 lsplit = shlex.split(lbuf)[-1]
400 401 except ValueError:
401 402 # typically an unmatched ", or backslash without escaped char.
402 403 if lbuf.count('"')==1:
403 404 open_quotes = 1
404 405 lsplit = lbuf.split('"')[-1]
405 406 elif lbuf.count("'")==1:
406 407 open_quotes = 1
407 408 lsplit = lbuf.split("'")[-1]
408 409 else:
409 410 return []
410 411 except IndexError:
411 412 # tab pressed on empty line
412 413 lsplit = ""
413 414
414 415 if lsplit != protect_filename(lsplit):
415 416 # if protectables are found, do matching on the whole escaped
416 417 # name
417 418 has_protectables = 1
418 419 text0,text = text,lsplit
419 420 else:
420 421 has_protectables = 0
421 422 text = os.path.expanduser(text)
422 423
423 424 if text == "":
424 425 return [text_prefix + protect_filename(f) for f in self.glob("*")]
425 426
426 427 m0 = self.clean_glob(text.replace('\\',''))
427 428 if has_protectables:
428 429 # If we had protectables, we need to revert our changes to the
429 430 # beginning of filename so that we don't double-write the part
430 431 # of the filename we have so far
431 432 len_lsplit = len(lsplit)
432 433 matches = [text_prefix + text0 +
433 434 protect_filename(f[len_lsplit:]) for f in m0]
434 435 else:
435 436 if open_quotes:
436 437 # if we have a string with an open quote, we don't need to
437 438 # protect the names at all (and we _shouldn't_, as it
438 439 # would cause bugs when the filesystem call is made).
439 440 matches = m0
440 441 else:
441 442 matches = [text_prefix +
442 443 protect_filename(f) for f in m0]
443 444
444 445 #print 'mm',matches # dbg
445 446 return single_dir_expand(matches)
446 447
447 448 def alias_matches(self, text):
448 449 """Match internal system aliases"""
449 450 #print 'Completer->alias_matches:',text,'lb',self.lbuf # dbg
450 451
451 452 # if we are not in the first 'item', alias matching
452 453 # doesn't make sense
453 454 if ' ' in self.lbuf.lstrip():
454 455 return []
455 456 text = os.path.expanduser(text)
456 457 aliases = self.alias_table.keys()
457 458 if text == "":
458 459 return aliases
459 460 else:
460 461 return [alias for alias in aliases if alias.startswith(text)]
461 462
462 463 def python_matches(self,text):
463 464 """Match attributes or global python names"""
464 465
465 466 #print 'Completer->python_matches, txt=<%s>' % text # dbg
466 467 if "." in text:
467 468 try:
468 469 matches = self.attr_matches(text)
469 470 if text.endswith('.') and self.omit__names:
470 471 if self.omit__names == 1:
471 472 # true if txt is _not_ a __ name, false otherwise:
472 473 no__name = (lambda txt:
473 474 re.match(r'.*\.__.*?__',txt) is None)
474 475 else:
475 476 # true if txt is _not_ a _ name, false otherwise:
476 477 no__name = (lambda txt:
477 478 re.match(r'.*\._.*?',txt) is None)
478 479 matches = filter(no__name, matches)
479 480 except NameError:
480 481 # catches <undefined attributes>.<tab>
481 482 matches = []
482 483 else:
483 484 matches = self.global_matches(text)
484 485 # this is so completion finds magics when automagic is on:
485 486 if (matches == [] and
486 487 not text.startswith(os.sep) and
487 488 not ' ' in self.lbuf):
488 489 matches = self.attr_matches(self.magic_prefix+text)
489 490 return matches
490 491
491 492 def _default_arguments(self, obj):
492 493 """Return the list of default arguments of obj if it is callable,
493 494 or empty list otherwise."""
494 495
495 496 if not (inspect.isfunction(obj) or inspect.ismethod(obj)):
496 497 # for classes, check for __init__,__new__
497 498 if inspect.isclass(obj):
498 499 obj = (getattr(obj,'__init__',None) or
499 500 getattr(obj,'__new__',None))
500 501 # for all others, check if they are __call__able
501 502 elif hasattr(obj, '__call__'):
502 503 obj = obj.__call__
503 504 # XXX: is there a way to handle the builtins ?
504 505 try:
505 506 args,_,_1,defaults = inspect.getargspec(obj)
506 507 if defaults:
507 508 return args[-len(defaults):]
508 509 except TypeError: pass
509 510 return []
510 511
511 512 def python_func_kw_matches(self,text):
512 513 """Match named parameters (kwargs) of the last open function"""
513 514
514 515 if "." in text: # a parameter cannot be dotted
515 516 return []
516 517 try: regexp = self.__funcParamsRegex
517 518 except AttributeError:
518 519 regexp = self.__funcParamsRegex = re.compile(r'''
519 520 '.*?' | # single quoted strings or
520 521 ".*?" | # double quoted strings or
521 522 \w+ | # identifier
522 523 \S # other characters
523 524 ''', re.VERBOSE | re.DOTALL)
524 525 # 1. find the nearest identifier that comes before an unclosed
525 526 # parenthesis e.g. for "foo (1+bar(x), pa", the candidate is "foo"
526 527 tokens = regexp.findall(self.get_line_buffer())
527 528 tokens.reverse()
528 529 iterTokens = iter(tokens); openPar = 0
529 530 for token in iterTokens:
530 531 if token == ')':
531 532 openPar -= 1
532 533 elif token == '(':
533 534 openPar += 1
534 535 if openPar > 0:
535 536 # found the last unclosed parenthesis
536 537 break
537 538 else:
538 539 return []
539 540 # 2. Concatenate dotted names ("foo.bar" for "foo.bar(x, pa" )
540 541 ids = []
541 542 isId = re.compile(r'\w+$').match
542 543 while True:
543 544 try:
544 545 ids.append(iterTokens.next())
545 546 if not isId(ids[-1]):
546 547 ids.pop(); break
547 548 if not iterTokens.next() == '.':
548 549 break
549 550 except StopIteration:
550 551 break
551 552 # lookup the candidate callable matches either using global_matches
552 553 # or attr_matches for dotted names
553 554 if len(ids) == 1:
554 555 callableMatches = self.global_matches(ids[0])
555 556 else:
556 557 callableMatches = self.attr_matches('.'.join(ids[::-1]))
557 558 argMatches = []
558 559 for callableMatch in callableMatches:
559 560 try: namedArgs = self._default_arguments(eval(callableMatch,
560 561 self.namespace))
561 562 except: continue
562 563 for namedArg in namedArgs:
563 564 if namedArg.startswith(text):
564 565 argMatches.append("%s=" %namedArg)
565 566 return argMatches
566 567
567 568 def dispatch_custom_completer(self,text):
568 569 # print "Custom! '%s' %s" % (text, self.custom_completers) # dbg
569 570 line = self.full_lbuf
570 571 if not line.strip():
571 572 return None
572 573
573 574 event = Struct()
574 575 event.line = line
575 576 event.symbol = text
576 577 cmd = line.split(None,1)[0]
577 578 event.command = cmd
578 579 #print "\ncustom:{%s]\n" % event # dbg
579 580
580 581 # for foo etc, try also to find completer for %foo
581 582 if not cmd.startswith(self.magic_escape):
582 583 try_magic = self.custom_completers.s_matches(
583 584 self.magic_escape + cmd)
584 585 else:
585 586 try_magic = []
586 587
587 588
588 589 for c in itertools.chain(
589 590 self.custom_completers.s_matches(cmd),
590 591 try_magic,
591 592 self.custom_completers.flat_matches(self.lbuf)):
592 593 # print "try",c # dbg
593 594 try:
594 595 res = c(event)
595 596 return [r for r in res if r.lower().startswith(text.lower())]
596 597 except ipapi.TryNext:
597 598 pass
598 599
599 600 return None
600 601
601 602
602 603 def complete(self, text, state,line_buffer=None):
603 604 """Return the next possible completion for 'text'.
604 605
605 606 This is called successively with state == 0, 1, 2, ... until it
606 607 returns None. The completion should begin with 'text'.
607 608
608 609 :Keywords:
609 610 - line_buffer: string
610 611 If not given, the completer attempts to obtain the current line buffer
611 612 via readline. This keyword allows clients which are requesting for
612 613 text completions in non-readline contexts to inform the completer of
613 614 the entire text.
614 615 """
615 616
616 617 #print '\n*** COMPLETE: <%s> (%s)' % (text,state) # dbg
617 618
618 619 # if there is only a tab on a line with only whitespace, instead
619 620 # of the mostly useless 'do you want to see all million
620 621 # completions' message, just do the right thing and give the user
621 622 # his tab! Incidentally, this enables pasting of tabbed text from
622 623 # an editor (as long as autoindent is off).
623 624
624 625 # don't apply this on 'dumb' terminals, such as emacs buffers, so we
625 626 # don't interfere with their own tab-completion mechanism.
626 627 if line_buffer is None:
627 628 self.full_lbuf = self.get_line_buffer()
628 629 else:
629 630 self.full_lbuf = line_buffer
630 631
631 632 if not (self.dumb_terminal or self.full_lbuf.strip()):
632 633 self.readline.insert_text('\t')
633 634 return None
634 635
635 636 magic_escape = self.magic_escape
636 637 magic_prefix = self.magic_prefix
637 638
638 639 self.lbuf = self.full_lbuf[:self.readline.get_endidx()]
639 640
640 641 try:
641 642 if text.startswith(magic_escape):
642 643 text = text.replace(magic_escape,magic_prefix)
643 644 elif text.startswith('~'):
644 645 text = os.path.expanduser(text)
645 646 if state == 0:
646 647 custom_res = self.dispatch_custom_completer(text)
647 648 if custom_res is not None:
648 649 # did custom completers produce something?
649 650 self.matches = custom_res
650 651 else:
651 652 # Extend the list of completions with the results of each
652 653 # matcher, so we return results to the user from all
653 654 # namespaces.
654 655 if self.merge_completions:
655 656 self.matches = []
656 657 for matcher in self.matchers:
657 658 self.matches.extend(matcher(text))
658 659 else:
659 660 for matcher in self.matchers:
660 661 self.matches = matcher(text)
661 662 if self.matches:
662 663 break
663 664
664 665 try:
665 666 return self.matches[state].replace(magic_prefix,magic_escape)
666 667 except IndexError:
667 668 return None
668 669 except:
669 670 #from IPython.ultraTB import AutoFormattedTB; # dbg
670 671 #tb=AutoFormattedTB('Verbose');tb() #dbg
671 672
672 673 # If completion fails, don't annoy the user.
673 674 return None
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now