Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Set up a new completer and validator for the new grammar.
g = self._create_grammar()
self.completer = GrammarCompleter(g, completers={
'enabled_breakpoint': BreakPointListCompleter(only_enabled=True),
'disabled_breakpoint': BreakPointListCompleter(only_disabled=True),
'alias_name': AliasCompleter(self),
'python_code': PythonCompleter(lambda: self.curframe.f_globals, lambda: self.curframe.f_locals),
'breakpoint': BreakPointListCompleter(),
'pdb_command': PdbCommandsCompleter(self),
'python_file': PythonFileCompleter(),
'python_function': PythonFunctionCompleter(self),
})
self.validator = GrammarValidator(g, {
'python_code': PythonValidator()
})
# Make sure not to start in Vi navigation mode.
self.python_input.key_bindings_manager.reset(self.cli)
self.cli.buffers[DEFAULT_BUFFER].reset()
def pre_run():
self._source_code_window.vertical_scroll = 100000 # source_code_doc.line_count
try:
return self.cli.run(reset_current_buffer=False, pre_run=pre_run).text
except EOFError:
# Turn Control-D key press into a 'quit' command.
return 'quit'
# For internal use.
extra_key_bindings=None,
_completer=None, _validator=None,
_lexer=None, _extra_buffer_processors=None,
_extra_layout_body=None, _extra_toolbars=None,
_input_buffer_height=None):
self.get_globals = get_globals or (lambda: {})
self.get_locals = get_locals or self.get_globals
self._completer = _completer or FuzzyCompleter(
PythonCompleter(self.get_globals, self.get_locals,
lambda: self.enable_dictionary_completion),
enable_fuzzy=Condition(lambda: self.enable_fuzzy_completion))
self._validator = _validator or PythonValidator(self.get_compiler_flags)
self._lexer = _lexer or PygmentsLexer(PythonLexer)
if history_filename:
self.history = ThreadedHistory(FileHistory(history_filename))
else:
self.history = InMemoryHistory()
self._input_buffer_height = _input_buffer_height
self._extra_layout_body = _extra_layout_body or []
self._extra_toolbars = _extra_toolbars or []
self._extra_buffer_processors = _extra_buffer_processors or []
self.extra_key_bindings = extra_key_bindings or KeyBindings()
# Settings.
self.show_signature = False