*** rlcompleter_ng.py 2008-12-10 11:56:00.000000000 -0800 --- rlcompleter_ng_2and3.py 2008-12-10 12:01:03.000000000 -0800 *************** *** 69,82 **** import readline import rlcompleter import types import os.path ! from itertools import izip, count class colors: black = '30' darkred = '31' ! darkgreen = '32' brown = '33' darkblue = '34' purple = '35' --- 69,89 ---- import readline import rlcompleter + import sys import types import os.path ! from itertools import count ! ! if sys.version_info[0] > 2: ! from functools import reduce ! unicode = str ! types.ClassType = type ! types.NoneType = type(None) class colors: black = '30' darkred = '31' ! darkgreen = '32' brown = '33' darkblue = '34' purple = '35' *************** *** 97,103 **** # WARNING: for this option to work properly, you need to patch readline with this: # http://codespeak.net/svn/user/antocuni/hack/readline-escape.patch use_colors = False ! color_by_type = { types.BuiltinMethodType: colors.turquoise, types.BuiltinMethodType: colors.turquoise, --- 104,110 ---- # WARNING: for this option to work properly, you need to patch readline with this: # http://codespeak.net/svn/user/antocuni/hack/readline-escape.patch use_colors = False ! color_by_type = { types.BuiltinMethodType: colors.turquoise, types.BuiltinMethodType: colors.turquoise, *************** *** 108,117 **** types.FunctionType: colors.blue, types.BuiltinFunctionType: colors.blue, ! types.ClassType: colors.fuchsia, type: colors.fuchsia, ! types.ModuleType: colors.teal, types.NoneType: colors.lightgray, str: colors.green, --- 115,124 ---- types.FunctionType: colors.blue, types.BuiltinFunctionType: colors.blue, ! types.ClassType: colors.fuchsia, type: colors.fuchsia, ! types.ModuleType: colors.teal, types.NoneType: colors.lightgray, str: colors.green, *************** *** 142,149 **** try: execfile(rcfile, mydict) return mydict['Config']() ! except Exception, e: ! print '** error when importing %s: %s **' % (filename, e) return self.DefaultConfig() --- 149,157 ---- try: execfile(rcfile, mydict) return mydict['Config']() ! except Exception: ! print('** error when importing %s: %s **' % (filename, ! sys.exc_info()[1])) return self.DefaultConfig() *************** *** 151,157 **** """ When doing someting like a.b., display only the attributes of b instead of the full a.b.attr string. ! Optionally, display the various completions in different colors depending on the type. """ --- 159,165 ---- """ When doing someting like a.b., display only the attributes of b instead of the full a.b.attr string. ! Optionally, display the various completions in different colors depending on the type. """ *************** *** 191,197 **** values.append(eval(name, self.namespace)) matches = [self.color_for_obj(i, name, obj) for i, name, obj ! in izip(count(), names, values)] return matches + [' '] def attr_matches(self, text): --- 199,205 ---- values.append(eval(name, self.namespace)) matches = [self.color_for_obj(i, name, obj) for i, name, obj ! in zip(count(), names, values)] return matches + [' '] def attr_matches(self, text): *************** *** 212,225 **** except: value = None values.append(value) ! prefix = commonprefix(names) if prefix and prefix != attr: return ['%s.%s' % (expr, prefix)] # autocomplete prefix matches = [self.color_for_obj(i, name, value) for i, name, value ! in izip(count(), names, values)] return matches + [' '] def color_for_obj(self, i, name, value): --- 220,233 ---- except: value = None values.append(value) ! prefix = commonprefix(names) if prefix and prefix != attr: return ['%s.%s' % (expr, prefix)] # autocomplete prefix matches = [self.color_for_obj(i, name, value) for i, name, value ! in zip(count(), names, values)] return matches + [' '] def color_for_obj(self, i, name, value): *************** *** 237,243 **** """ return the common prefix of all 'names' starting with 'base' """ def commonfunc(s1,s2): ! while not s2.startswith(s1): s1=s1[:-1] return s1 --- 245,251 ---- """ return the common prefix of all 'names' starting with 'base' """ def commonfunc(s1,s2): ! while not s2.startswith(s1): s1=s1[:-1] return s1