Skip to content

Commit 711d293

Browse files
remove autoimport functionality
--HG-- branch : scroll-frontend
1 parent 2a4a7c2 commit 711d293

File tree

2 files changed

+3
-39
lines changed

2 files changed

+3
-39
lines changed

bpython/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ def loadini(struct, configfile):
9999
'scroll': {
100100
'list_above' : False,
101101
'fill_terminal' : False,
102-
'auto_import' : False,
103102
},
104103
'gtk': {
105104
'font': 'monospace 10',
@@ -166,7 +165,6 @@ def loadini(struct, configfile):
166165

167166
struct.scroll_list_above = config.getboolean('scroll', 'list_above')
168167
struct.scroll_fill_terminal = config.getboolean('scroll', 'fill_terminal')
169-
struct.scroll_auto_import = config.getboolean('scroll', 'auto_import')
170168

171169
color_scheme_name = config.get('general', 'color_scheme')
172170
color_gtk_scheme_name = config.get('gtk', 'color_scheme')

bpython/scrollfrontend/repl.py

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -100,38 +100,6 @@ def readline(self):
100100
self.repl.send_to_stdout(value)
101101
return value
102102

103-
def get_interpreter(config, locals_=None):
104-
if config.scroll_auto_import and sys.version_info[0] == 3 and sys.version_info[1] >= 3:
105-
106-
default = {'__name__': '__main__',
107-
'__doc__': None,
108-
'__cached__': None,
109-
'__package__': None,}
110-
locals_ = default if locals_ is None else locals_
111-
autoimported = []
112-
113-
class AutoImporter(dict):
114-
def __getitem__(self, item):
115-
if dict.__contains__(self, item):
116-
return dict.__getitem__(self, item)
117-
else:
118-
try:
119-
module = __import__(item)
120-
autoimported.append(item)
121-
globals()[item] = module
122-
return module
123-
except ImportError:
124-
raise KeyError(item)
125-
@property
126-
def autoimported(self):
127-
return autoimported
128-
129-
ns = AutoImporter()
130-
ns.update(locals_)
131-
return code.InteractiveInterpreter(locals=ns)
132-
else:
133-
return code.InteractiveInterpreter(locals=locals_)
134-
135103
class Repl(BpythonRepl):
136104
"""
137105
@@ -158,7 +126,7 @@ def __init__(self, locals_=None, config=None, stuff_a_refresh_request=lambda: No
158126
config = Struct()
159127
loadini(config, default_config_path())
160128

161-
interp = get_interpreter(config, locals_=locals_)
129+
interp = code.InteractiveInterpreter(locals=locals_)
162130

163131
if banner is None:
164132
banner = _('welcome to bpython')
@@ -830,7 +798,7 @@ def reevaluate(self, insert_into_history=False):
830798
self.display_lines = []
831799

832800
self.done = True # this keeps the first prompt correct
833-
self.interp = get_interpreter(self.config)
801+
self.interp = code.InteractiveInterpreter()
834802
self.coderunner.interp = self.interp
835803
self.completer = Autocomplete(self.interp.locals, self.config)
836804
self.completer.autocomplete_mode = 'simple'
@@ -854,9 +822,7 @@ def reevaluate(self, insert_into_history=False):
854822

855823
def getstdout(self):
856824
lines = self.lines_for_display + [self.current_line_formatted]
857-
imports = (['%simport %s' % (self.ps1, name) for name in self.interp.locals.autoimported]
858-
if hasattr(self.interp.locals, 'autoimported') else [])
859-
s = '\n'.join(imports + [x.s if isinstance(x, FmtStr) else x for x in lines]
825+
s = '\n'.join([x.s if isinstance(x, FmtStr) else x for x in lines]
860826
) if lines else ''
861827
return s
862828
def send_to_external_editor(self, filename=None):

0 commit comments

Comments
 (0)