Show More
@@ -69,11 +69,10 b' from IPython.core.error import TryNext' | |||
|
69 | 69 | from IPython.core.inputsplitter import ESC_MAGIC |
|
70 | 70 | from IPython.core.latex_symbols import latex_symbols, reverse_latex_symbol |
|
71 | 71 | from IPython.utils import generics |
|
72 | from IPython.utils import io | |
|
73 | 72 | from IPython.utils.decorators import undoc |
|
74 | 73 | from IPython.utils.dir2 import dir2, get_real_method |
|
75 | 74 | from IPython.utils.process import arg_split |
|
76 | from IPython.utils.py3compat import builtin_mod, string_types, PY3 | |
|
75 | from IPython.utils.py3compat import builtin_mod, string_types, PY3, cast_unicode_py2 | |
|
77 | 76 | from traitlets import CBool, Enum |
|
78 | 77 | |
|
79 | 78 | #----------------------------------------------------------------------------- |
@@ -348,7 +347,7 b' class Completer(Configurable):' | |||
|
348 | 347 | for word in lst: |
|
349 | 348 | if word[:n] == text and word != "__builtins__": |
|
350 | 349 | match_append(word) |
|
351 | return matches | |
|
350 | return [cast_unicode_py2(m) for m in matches] | |
|
352 | 351 | |
|
353 | 352 | def attr_matches(self, text): |
|
354 | 353 | """Compute matches when text contains a dot. |
@@ -401,8 +400,7 b' class Completer(Configurable):' | |||
|
401 | 400 | pass |
|
402 | 401 | # Build match list to return |
|
403 | 402 | n = len(attr) |
|
404 |
re |
|
|
405 | return res | |
|
403 | return [u"%s.%s" % (expr, w) for w in words if w[:n] == attr ] | |
|
406 | 404 | |
|
407 | 405 | |
|
408 | 406 | def get__all__entries(obj): |
@@ -412,7 +410,7 b' def get__all__entries(obj):' | |||
|
412 | 410 | except: |
|
413 | 411 | return [] |
|
414 | 412 | |
|
415 | return [w for w in words if isinstance(w, string_types)] | |
|
413 | return [cast_unicode_py2(w) for w in words if isinstance(w, string_types)] | |
|
416 | 414 | |
|
417 | 415 | |
|
418 | 416 | def match_dict_keys(keys, prefix, delims): |
@@ -682,9 +680,9 b' class IPCompleter(Completer):' | |||
|
682 | 680 | # when escaped with backslash |
|
683 | 681 | if text.startswith('!'): |
|
684 | 682 | text = text[1:] |
|
685 | text_prefix = '!' | |
|
683 | text_prefix = u'!' | |
|
686 | 684 | else: |
|
687 | text_prefix = '' | |
|
685 | text_prefix = u'' | |
|
688 | 686 | |
|
689 | 687 | text_until_cursor = self.text_until_cursor |
|
690 | 688 | # track strings with open quotes |
@@ -715,7 +713,7 b' class IPCompleter(Completer):' | |||
|
715 | 713 | text = os.path.expanduser(text) |
|
716 | 714 | |
|
717 | 715 | if text == "": |
|
718 | return [text_prefix + protect_filename(f) for f in self.glob("*")] | |
|
716 | return [cast_unicode_py2(text_prefix + protect_filename(f)) for f in self.glob("*")] | |
|
719 | 717 | |
|
720 | 718 | # Compute the matches from the filesystem |
|
721 | 719 | m0 = self.clean_glob(text.replace('\\','')) |
@@ -737,11 +735,8 b' class IPCompleter(Completer):' | |||
|
737 | 735 | matches = [text_prefix + |
|
738 | 736 | protect_filename(f) for f in m0] |
|
739 | 737 | |
|
740 | #io.rprint('mm', matches) # dbg | |
|
741 | ||
|
742 | 738 | # Mark directories in input list by appending '/' to their names. |
|
743 |
|
|
|
744 | return matches | |
|
739 | return [cast_unicode_py2(x+'/') if os.path.isdir(x) else x for x in matches] | |
|
745 | 740 | |
|
746 | 741 | def magic_matches(self, text): |
|
747 | 742 | """Match magics""" |
@@ -763,9 +758,9 b' class IPCompleter(Completer):' | |||
|
763 | 758 | comp = [ pre2+m for m in cell_magics if m.startswith(bare_text)] |
|
764 | 759 | if not text.startswith(pre2): |
|
765 | 760 | comp += [ pre+m for m in line_magics if m.startswith(bare_text)] |
|
766 | return comp | |
|
761 | return [cast_unicode_py2(c) for c in comp] | |
|
767 | 762 | |
|
768 | def python_matches(self,text): | |
|
763 | def python_matches(self, text): | |
|
769 | 764 | """Match attributes or global python names""" |
|
770 | 765 | |
|
771 | 766 | #io.rprint('Completer->python_matches, txt=%r' % text) # dbg |
@@ -787,7 +782,6 b' class IPCompleter(Completer):' | |||
|
787 | 782 | matches = [] |
|
788 | 783 | else: |
|
789 | 784 | matches = self.global_matches(text) |
|
790 | ||
|
791 | 785 | return matches |
|
792 | 786 | |
|
793 | 787 | def _default_arguments_from_docstring(self, doc): |
@@ -916,7 +910,7 b' class IPCompleter(Completer):' | |||
|
916 | 910 | |
|
917 | 911 | for namedArg in namedArgs: |
|
918 | 912 | if namedArg.startswith(text): |
|
919 | argMatches.append("%s=" %namedArg) | |
|
913 | argMatches.append(u"%s=" %namedArg) | |
|
920 | 914 | return argMatches |
|
921 | 915 | |
|
922 | 916 | def dict_key_matches(self, text): |
@@ -1075,7 +1069,6 b' class IPCompleter(Completer):' | |||
|
1075 | 1069 | return u'', [] |
|
1076 | 1070 | |
|
1077 | 1071 | def dispatch_custom_completer(self, text): |
|
1078 | #io.rprint("Custom! '%s' %s" % (text, self.custom_completers)) # dbg | |
|
1079 | 1072 | line = self.line_buffer |
|
1080 | 1073 | if not line.strip(): |
|
1081 | 1074 | return None |
@@ -1101,17 +1094,16 b' class IPCompleter(Completer):' | |||
|
1101 | 1094 | for c in itertools.chain(self.custom_completers.s_matches(cmd), |
|
1102 | 1095 | try_magic, |
|
1103 | 1096 | self.custom_completers.flat_matches(self.text_until_cursor)): |
|
1104 | #print "try",c # dbg | |
|
1105 | 1097 | try: |
|
1106 | 1098 | res = c(event) |
|
1107 | 1099 | if res: |
|
1108 | 1100 | # first, try case sensitive match |
|
1109 | withcase = [r for r in res if r.startswith(text)] | |
|
1101 | withcase = [cast_unicode_py2(r) for r in res if r.startswith(text)] | |
|
1110 | 1102 | if withcase: |
|
1111 | 1103 | return withcase |
|
1112 | 1104 | # if none, then case insensitive ones are ok too |
|
1113 | 1105 | text_low = text.lower() |
|
1114 | return [r for r in res if r.lower().startswith(text_low)] | |
|
1106 | return [cast_unicode_py2(r) for r in res if r.lower().startswith(text_low)] | |
|
1115 | 1107 | except TryNext: |
|
1116 | 1108 | pass |
|
1117 | 1109 |
General Comments 0
You need to be logged in to leave comments.
Login now