How to use the bpython.repl function in bpython

To help you get started, we’ve selected a few bpython examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bpython / bpython / bpython / gtk_.py View on Github external
def __init__(self, interpreter, config):
        gtk.TextView.__init__(self)
        repl.Repl.__init__(self, interpreter, config)
        self.interp.writetb = self.writetb
        self.exit_value = ()
        self.editing = Nested()
        self.reset_indent = False
        self.modify_font(pango.FontDescription(self.config.gtk_font))
        self.set_wrap_mode(gtk.WRAP_CHAR)
        self.list_win = SuggestionWindow()
        self.list_win.connect('selection-changed',
                              self.on_suggestion_selection_changed)
        self.list_win.hide()

        self.modify_base('normal', gtk.gdk.color_parse(_COLORS[self.config.color_gtk_scheme['background']]))

        self.text_buffer = self.get_buffer()
        self.interact = GTKInteraction(self.config, Statusbar())
        tags = add_tags_to_buffer(self.config.color_gtk_scheme, self.text_buffer)
github bpython / bpython / bpython / cli.py View on Github external
for line in lines:
            if py3:
                self.stdout_hist += line + "\n"
            else:
                self.stdout_hist += line.encode(getpreferredencoding()) + "\n"
            self.history.append(line)
            self.print_line(line)
            self.s_hist[-1] += self.f_string
            self.scr.addstr("\n")
            self.more = self.push(line)
            self.prompt(self.more)
            self.iy, self.ix = self.scr.getyx()
        self.evaluating = False

        self.cpos = 0
        indent = repl.next_indentation(self.s, self.config.tab_length)
        self.s = ""
        self.scr.refresh()

        if self.buffer:
            for _ in range(indent):
                self.tab()

        self.print_line(self.s)
        self.scr.redrawwin()
        return ""
github bpython / bpython / bpython / gtk_.py View on Github external
def __init__(self, config, statusbar):
        repl.Interaction.__init__(self, config, statusbar)
github ivanov / bipython / bipython / __init__.py View on Github external
if not options.interactive:
                raise urwid.ExitMainLoop()
        if not exec_args:
            sys.path.insert(0, '')
            # this is CLIRepl.startup inlined.
            filename = os.environ.get('PYTHONSTARTUP')
            if filename and os.path.isfile(filename):
                with open(filename, 'r') as f:
                    if py3:
                        interpreter.runsource(f.read(), filename, 'exec')
                    else:
                        interpreter.runsource(f.read(), filename, 'exec',
                                              encode=False)

        if banner is not None:
            repl.write(banner)
            repl.write('\n')
        myrepl.start()

        # This bypasses main_loop.set_alarm_in because we must *not*
        # hit the draw_screen call (it's unnecessary and slow).
        def run_find_coroutine():
            if find_coroutine():
                main_loop.event_loop.alarm(0, run_find_coroutine)

        run_find_coroutine()
github ivanov / bipython / bipython / __init__.py View on Github external
for line in self.history:
            if py3:
                self.stdout_hist += line + '\n'
            else:
                self.stdout_hist += line.encode(locale.getpreferredencoding()) + '\n'
            self.print_line(line)
            self.s_hist[-1] += self.f_string
            # I decided it was easier to just do this manually
            # than to make the print_line and history stuff more flexible.
            self.scr.addstr('\n')
            more = self.push(line)
            self.prompt(more)
            self.iy, self.ix = self.scr.getyx()

        self.cpos = 0
        indent = repl.next_indentation(self.s, self.config.tab_length)
        self.s = ''
        self.scr.refresh()

        if self.buffer:
            for _ in range(indent):
                self.tab()

        self.evaluating = False
        #map(self.push, self.history)