@@ -82,55 +82,7 @@ def setup(self):
8282 self .use_colors = colors .RED != ""
8383
8484
85- def my_execfile (filename , mydict ):
86- with open (filename ) as f :
87- code = compile (f .read (), filename , 'exec' )
88- exec (code , mydict )
89-
90-
91- class ConfigurableClass :
92- DefaultConfig = None
93- config_filename = None
94-
95- def get_config (self , Config ):
96- if Config is not None :
97- return Config ()
98- # try to load config from the ~/filename file
99- filename = '~/' + self .config_filename
100- rcfile = os .path .normpath (os .path .expanduser (filename ))
101- if not os .path .exists (rcfile ):
102- return self .DefaultConfig ()
103-
104- mydict = {}
105- try :
106- my_execfile (rcfile , mydict )
107- except Exception as exc :
108- import traceback
109-
110- sys .stderr .write ("** error when importing %s: %r **\n " % (filename , exc ))
111- traceback .print_tb (sys .exc_info ()[2 ])
112- return self .DefaultConfig ()
113-
114- try :
115- Config = mydict ["Config" ]
116- except KeyError :
117- return self .DefaultConfig ()
118-
119- try :
120- return Config ()
121- except Exception as exc :
122- err = "error when setting up Config from %s: %s" % (filename , exc )
123- tb = sys .exc_info ()[2 ]
124- if tb and tb .tb_next :
125- tb = tb .tb_next
126- err_fname = tb .tb_frame .f_code .co_filename
127- err_lnum = tb .tb_lineno
128- err += " (%s:%d)" % (err_fname , err_lnum ,)
129- sys .stderr .write ("** %s **\n " % err )
130- return self .DefaultConfig ()
131-
132-
133- class Completer (rlcompleter .Completer , ConfigurableClass ):
85+ class Completer (rlcompleter .Completer ):
13486 """
13587 When doing someting like a.b.<TAB>, display only the attributes of
13688 b instead of the full a.b.attr string.
@@ -142,9 +94,9 @@ class Completer(rlcompleter.Completer, ConfigurableClass):
14294 DefaultConfig = DefaultConfig
14395 config_filename = '.fancycompleterrc.py.xxx'
14496
145- def __init__ (self , namespace = None , Config = None ):
97+ def __init__ (self , namespace = None , Config = DefaultConfig ):
14698 rlcompleter .Completer .__init__ (self , namespace )
147- self .config = self . get_config ( Config )
99+ self .config = Config ( )
148100 self .config .setup ()
149101
150102 # XXX: double check what happens in this case once fancycompleter works
0 commit comments