text_prompt
stringlengths
157
13.1k
code_prompt
stringlengths
7
19.8k
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def setup_editorstack(self, parent, layout): """Setup editorstack's layout"""
layout.setSpacing(1) self.fname_label = QLabel() self.fname_label.setStyleSheet( "QLabel {margin: 0px; padding: 3px;}") layout.addWidget(self.fname_label) menu_btn = create_toolbutton(self, icon=ima.icon('tooloptions'), ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_fname_label(self): """Upadte file name label."""
filename = to_text_string(self.get_current_filename()) if len(filename) > 100: shorten_filename = u'...' + filename[-100:] else: shorten_filename = filename self.fname_label.setText(shorten_filename)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def clone_from(self, other): """Clone EditorStack from other instance"""
for other_finfo in other.data: self.clone_editor_from(other_finfo, set_current=True) self.set_stack_index(other.get_stack_index())
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def open_fileswitcher_dlg(self): """Open file list management dialog box"""
if not self.tabs.count(): return if self.fileswitcher_dlg is not None and \ self.fileswitcher_dlg.is_visible: self.fileswitcher_dlg.hide() self.fileswitcher_dlg.is_visible = False return self.fileswitcher_dlg = FileSwitcher(self,...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def go_to_line(self, line=None): """Go to line dialog"""
if line is not None: # When this method is called from the flileswitcher, a line # number is specified, so there is no need for the dialog. self.get_current_editor().go_to_line(line) else: if self.data: self.get_current_editor().exe...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_or_edit_conditional_breakpoint(self): """Set conditional breakpoint"""
if self.data: editor = self.get_current_editor() editor.debugger.toogle_breakpoint(edit_condition=True)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_bookmark(self, slot_num): """Bookmark current position to given slot."""
if self.data: editor = self.get_current_editor() editor.add_bookmark(slot_num)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def inspect_current_object(self): """Inspect current object in the Help plugin"""
editor = self.get_current_editor() editor.sig_display_signature.connect(self.display_signature_help) line, col = editor.get_cursor_line_column() editor.request_hover(line, col)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def initialize_outlineexplorer(self): """This method is called separately from 'set_oulineexplorer' to avoid doing unnecessary updates when there are multiple ...
for index in range(self.get_stack_count()): if index != self.get_stack_index(): self._refresh_outlineexplorer(index=index)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_tab_text(self, index, is_modified=None, is_readonly=None): """Return tab title."""
files_path_list = [finfo.filename for finfo in self.data] fname = self.data[index].filename fname = sourcecode.disambiguate_fname(files_path_list, fname) return self.__modified_readonly_title(fname, is_modified, is_readonly)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_tab_tip(self, filename, is_modified=None, is_readonly=None): """Return tab menu title"""
text = u"%s — %s" text = self.__modified_readonly_title(text, is_modified, is_readonly) if self.tempfile_path is not None\ and filename == encoding.to_unicode_from_fs(self.tempfile_path): temp_file_str = to_text_string(_...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def __setup_menu(self): """Setup tab context menu before showing it"""
self.menu.clear() if self.data: actions = self.menu_actions else: actions = (self.new_action, self.open_action) self.setFocus() # --> Editor.__get_focus_editortabwidget add_actions(self.menu, list(actions) + self.__get_split_actions()) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_current_filename(self, filename, focus=True): """Set current filename and return the associated editor instance."""
index = self.has_filename(filename) if index is not None: if focus: self.set_stack_index(index) editor = self.data[index].editor if focus: editor.setFocus() else: self.stack_history.remove_and_appen...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_index_from_filename(self, filename): """ Return the position index of a file in the tab bar of the editorstack from its name. """
filenames = [d.filename for d in self.data] return filenames.index(filename)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def move_editorstack_data(self, start, end): """Reorder editorstack.data so it is synchronized with the tab bar when tabs are moved."""
if start < 0 or end < 0: return else: steps = abs(end - start) direction = (end-start) // steps # +1 for right, -1 for left data = self.data self.blockSignals(True) for i in range(start, end, direction): data[i], data...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def poll_open_file_languages(self): """Get list of current opened files' languages"""
languages = [] for index in range(self.get_stack_count()): languages.append( self.tabs.widget(index).language.lower()) return set(languages)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def notify_server_ready(self, language, config): """Notify language server availability to code editors."""
for index in range(self.get_stack_count()): editor = self.tabs.widget(index) if editor.language.lower() == language: editor.start_lsp_services(config)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def close_all_right(self): """ Close all files opened to the right """
num = self.get_stack_index() n = self.get_stack_count() for i in range(num, n-1): self.close_file(num+1)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def close_all_but_this(self): """Close all files but the current one"""
self.close_all_right() for i in range(0, self.get_stack_count()-1 ): self.close_file(0)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def sort_file_tabs_alphabetically(self): """Sort open tabs alphabetically."""
while self.sorted() is False: for i in range(0, self.tabs.tabBar().count()): if(self.tabs.tabBar().tabText(i) > self.tabs.tabBar().tabText(i + 1)): self.tabs.tabBar().moveTab(i, i + 1)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def add_last_closed_file(self, fname): """Add to last closed file list."""
if fname in self.last_closed_files: self.last_closed_files.remove(fname) self.last_closed_files.insert(0, fname) if len(self.last_closed_files) > 10: self.last_closed_files.pop(-1)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def file_saved_in_other_editorstack(self, original_filename, filename): """ File was just saved in another editorstack, let's synchronize! This avoids file be...
index = self.has_filename(original_filename) if index is None: return finfo = self.data[index] finfo.newly_created = False finfo.filename = to_text_string(filename) finfo.lastmodified = QFileInfo(finfo.filename).lastModified()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def analyze_script(self, index=None): """Analyze current script with todos"""
if self.is_analysis_done: return if index is None: index = self.get_stack_index() if self.data: finfo = self.data[index] if self.todolist_enabled: finfo.run_todo_finder() self.is_analysis_done = True
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_todo_results(self, filename, todo_results): """Synchronize todo results between editorstacks"""
index = self.has_filename(filename) if index is None: return self.data[index].set_todo_results(todo_results)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def current_changed(self, index): """Stack index has changed"""
# count = self.get_stack_count() # for btn in (self.filelist_btn, self.previous_btn, self.next_btn): # btn.setEnabled(count > 1) editor = self.get_current_editor() if editor.lsp_ready and not editor.document_opened: editor.document_did_open() if ind...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def focus_changed(self): """Editor focus has changed"""
fwidget = QApplication.focusWidget() for finfo in self.data: if fwidget is finfo.editor: self.refresh() self.editor_focus_changed.emit()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _refresh_outlineexplorer(self, index=None, update=True, clear=False): """Refresh outline explorer panel"""
oe = self.outlineexplorer if oe is None: return if index is None: index = self.get_stack_index() if self.data: finfo = self.data[index] oe.setEnabled(True) if finfo.editor.oe_proxy is None: finfo.edito...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _sync_outlineexplorer_file_order(self): """ Order the root file items of the outline explorer as in the tabbar of the current EditorStack. """
if self.outlineexplorer is not None: self.outlineexplorer.treewidget.set_editor_ids_order( [finfo.editor.get_document_id() for finfo in self.data])
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def __refresh_statusbar(self, index): """Refreshing statusbar widgets"""
finfo = self.data[index] self.encoding_changed.emit(finfo.encoding) # Refresh cursor position status: line, index = finfo.editor.get_cursor_line_column() self.sig_editor_cursor_position_changed.emit(line, index)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def reload(self, index): """Reload file from disk"""
finfo = self.data[index] txt, finfo.encoding = encoding.read(finfo.filename) finfo.lastmodified = QFileInfo(finfo.filename).lastModified() position = finfo.editor.get_position('cursor') finfo.editor.set_text(txt) finfo.editor.document().setModified(False) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def revert(self): """Revert file from disk"""
index = self.get_stack_index() finfo = self.data[index] filename = finfo.filename if finfo.editor.document().isModified(): self.msgbox = QMessageBox( QMessageBox.Warning, self.title, _("All changes to <b>%s<...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def remove_trailing_spaces(self, index=None): """Remove trailing spaces"""
if index is None: index = self.get_stack_index() finfo = self.data[index] finfo.editor.remove_trailing_spaces()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def fix_indentation(self, index=None): """Replace tab characters by spaces"""
if index is None: index = self.get_stack_index() finfo = self.data[index] finfo.editor.fix_indentation()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def run_selection(self): """ Run selected text or current line in console. If some text is selected, then execute that text in console. If no text is sel...
text = self.get_current_editor().get_selection_as_executable_code() if text: self.exec_in_extconsole.emit(text.rstrip(), self.focus_to_editor) return editor = self.get_current_editor() line = editor.get_current_line() text = line.lstrip() ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def run_cell(self): """Run current cell."""
text, line = self.get_current_editor().get_cell_as_executable_code() self._run_cell_text(text, line)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def re_run_last_cell(self): """Run the previous cell again."""
text, line = (self.get_current_editor() .get_last_cell_as_executable_code()) self._run_cell_text(text, line)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def split(self, orientation=Qt.Vertical): """Create and attach a new EditorSplitter to the current EditorSplitter. The new EditorSplitter widget will contain...
self.setOrientation(orientation) self.editorstack.set_orientation(orientation) editorsplitter = EditorSplitter(self.parent(), self.plugin, self.menu_actions, register_editorstack_cb=self.register_editorstack_cb, unregister_editor...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def add_toolbars_to_menu(self, menu_title, actions): """Add toolbars to a menu."""
# Six is the position of the view menu in menus list # that you can find in plugins/editor.py setup_other_windows. view_menu = self.menus[6] if actions == self.toolbars and view_menu: toolbars = [] for toolbar in self.toolbars: action = too...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_layout_settings(self): """Return layout state"""
splitsettings = self.editorwidget.editorsplitter.get_layout_settings() return dict(size=(self.window_size.width(), self.window_size.height()), pos=(self.pos().x(), self.pos().y()), is_maximized=self.isMaximized(), is_fullscreen=self.isFul...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_layout_settings(self, settings): """Restore layout state"""
size = settings.get('size') if size is not None: self.resize( QSize(*size) ) self.window_size = self.size() pos = settings.get('pos') if pos is not None: self.move( QPoint(*pos) ) hexstate = settings.get('hexstate') if hexstat...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def file_saved_in_editorstack(self, editorstack_id_str, original_filename, filename): """A file was saved in editorstack, this notifies others"""
for editorstack in self.editorstacks: if str(id(editorstack)) != editorstack_id_str: editorstack.file_saved_in_other_editorstack(original_filename, filename)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def file_renamed_in_data_in_editorstack(self, editorstack_id_str, original_filename, filename): """A file was renamed in data in editorstack, this notifies oth...
for editorstack in self.editorstacks: if str(id(editorstack)) != editorstack_id_str: editorstack.rename_in_data(original_filename, filename)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def findinfiles_callback(self): """Find in files callback"""
widget = QApplication.focusWidget() if not self.ismaximized: self.dockwidget.setVisible(True) self.dockwidget.raise_() text = '' try: if widget.has_selected_text(): text = widget.get_selected_text() except AttributeErr...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _draw_fold_region_background(self, block, painter): """ Draw the fold region when the mouse is over and non collapsed indicator. :param top: Top position :pa...
r = FoldScope(block) th = TextHelper(self.editor) start, end = r.get_range(ignore_blank_lines=True) if start > 0: top = th.line_pos_from_number(start) else: top = 0 bottom = th.line_pos_from_number(end + 1) h = bottom - top if h ==...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _draw_rect(self, rect, painter): """ Draw the background rectangle using the current style primitive color. :param rect: The fold zone rect to draw :param pa...
c = self.editor.sideareas_color grad = QLinearGradient(rect.topLeft(), rect.topRight()) if sys.platform == 'darwin': grad.setColorAt(0, c.lighter(100)) grad.setColorAt(1, c.lighter(110)) outline = c.darker(110) els...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def find_parent_scope(block): """Find parent scope, if the block is not a fold trigger."""
original = block if not TextBlockHelper.is_fold_trigger(block): # search level of next non blank line while block.text().strip() == '' and block.isValid(): block = block.next() ref_lvl = TextBlockHelper.get_fold_lvl(block) - 1 block = orig...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _decorate_block(self, start, end): """ Create a decoration and add it to the editor. Args: start (int) start line of the decoration end (int) end line of the...
color = self._get_scope_highlight_color() draw_order = DRAW_ORDERS.get('codefolding') d = TextDecoration(self.editor.document(), start_line=start, end_line=end+1, draw_order=draw_order) d.set_background(color) d.set_full_width(True, clear=False) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _highlight_block(self, block): """ Highlights the current fold scope. :param block: Block that starts the current fold scope. """
scope = FoldScope(block) if (self._current_scope is None or self._current_scope.get_range() != scope.get_range()): self._current_scope = scope self._clear_scope_decos() # highlight current scope with darker or lighter color start, end = sc...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _show_previous_blank_lines(block): """ Show the block previous blank lines """
# set previous blank lines visibles pblock = block.previous() while (pblock.text().strip() == '' and pblock.blockNumber() >= 0): pblock.setVisible(True) pblock = pblock.previous()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def refresh_decorations(self, force=False): """ Refresh decorations colors. This function is called by the syntax highlighter when the style changed so that we m...
cursor = self.editor.textCursor() if (self._prev_cursor is None or force or self._prev_cursor.blockNumber() != cursor.blockNumber()): for deco in self._block_decos: self.editor.decorations.remove(deco) for deco in self._block_decos: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _refresh_editor_and_scrollbars(self): """ Refrehes editor content and scollbars. We generate a fake resize event to refresh scroll bar. We have the same prob...
TextHelper(self.editor).mark_whole_doc_dirty() self.editor.repaint() s = self.editor.size() s.setWidth(s.width() + 1) self.editor.resizeEvent(QResizeEvent(self.editor.size(), s))
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def collapse_all(self): """ Collapses all triggers and makes all blocks with fold level > 0 invisible. """
self._clear_block_deco() block = self.editor.document().firstBlock() last = self.editor.document().lastBlock() while block.isValid(): lvl = TextBlockHelper.get_fold_lvl(block) trigger = TextBlockHelper.is_fold_trigger(block) if trigger: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _clear_block_deco(self): """Clear the folded block decorations."""
for deco in self._block_decos: self.editor.decorations.remove(deco) self._block_decos[:] = []
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def expand_all(self): """Expands all fold triggers."""
block = self.editor.document().firstBlock() while block.isValid(): TextBlockHelper.set_collapsed(block, False) block.setVisible(True) block = block.next() self._clear_block_deco() self._refresh_editor_and_scrollbars() self.expand_all_triggered...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _on_action_toggle(self): """Toggle the current fold trigger."""
block = FoldScope.find_parent_scope(self.editor.textCursor().block()) self.toggle_fold_trigger(block)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _highlight_caret_scope(self): """ Highlight the scope of the current caret position. This get called only if :attr:` spyder.widgets.panels.FoldingPanel.highl...
cursor = self.editor.textCursor() block_nbr = cursor.blockNumber() if self._block_nbr != block_nbr: block = FoldScope.find_parent_scope( self.editor.textCursor().block()) try: s = FoldScope(block) except ValueError: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_menu_actions(self, menu_actions): """Add options to corner menu."""
if self.menu_actions is not None: add_actions(self.menu, self.menu_actions)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def add_history(self, filename, color_scheme, font, wrap): """ Add new history tab. Args: filename (str): file to be loaded in a new tab. """
filename = encoding.to_unicode_from_fs(filename) if filename in self.filenames: return editor = codeeditor.CodeEditor(self) if osp.splitext(filename)[1] == '.py': language = 'py' else: language = 'bat' editor.setup_editor(linenumbers=F...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def append_to_history(self, filename, command, go_to_eof): """ Append an entry to history filename. Args: filename (str): file to be updated in a new tab. comma...
if not is_text_string(filename): # filename is a QString filename = to_text_string(filename.toUtf8(), 'utf-8') command = to_text_string(command) index = self.filenames.index(filename) self.editors[index].append(command) if go_to_eof: self.editors[index].s...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def request(req=None, method=None, requires_response=True): """Call function req and then emit its results to the LSP server."""
if req is None: return functools.partial(request, method=method, requires_response=requires_response) @functools.wraps(req) def wrapper(self, *args, **kwargs): if self.lsp_ready: params = req(self, *args, **kwargs) if params is not N...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_focus_client(self): """Return current client with focus, if any"""
widget = QApplication.focusWidget() for client in self.get_clients(): if widget is client or widget is client.get_control(): return client
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def run_script(self, filename, wdir, args, debug, post_mortem, current_client, clear_variables): """Run script in current or dedicated client"""
norm = lambda text: remove_backslashes(to_text_string(text)) # Run Cython files in a dedicated console is_cython = osp.splitext(filename)[1] == '.pyx' if is_cython: current_client = False # Select client to execute code on it is_new_client = False ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_current_client_working_directory(self, directory): """Set current client working directory."""
shellwidget = self.get_current_shellwidget() if shellwidget is not None: shellwidget.set_cwd(directory)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_working_directory(self, dirname): """Set current working directory. In the workingdirectory and explorer plugins. """
if dirname: self.main.workingdirectory.chdir(dirname, refresh_explorer=True, refresh_console=False)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def execute_code(self, lines, current_client=True, clear_variables=False): """Execute code instructions."""
sw = self.get_current_shellwidget() if sw is not None: if sw._reading: pass else: if not current_client: # Clear console and reset namespace for # dedicated clients # See issue 5...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_new_client(self, give_focus=True, filename='', is_cython=False, is_pylab=False, is_sympy=False, given_name=None): """Create a new client"""
self.master_clients += 1 client_id = dict(int_id=to_text_string(self.master_clients), str_id='A') cf = self._new_connection_file() show_elapsed_time = self.get_option('show_elapsed_time') reset_warning = self.get_option('show_reset_namespace_warnin...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_client_for_kernel(self): """Create a client connected to an existing kernel"""
connect_output = KernelConnectionDialog.get_connection_parameters(self) (connection_file, hostname, sshkey, password, ok) = connect_output if not ok: return else: self._create_client_for_kernel(connection_file, hostname, sshkey, ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def connect_client_to_kernel(self, client, is_cython=False, is_pylab=False, is_sympy=False): """Connect a client to its kernel"""
connection_file = client.connection_file stderr_handle = None if self.test_no_stderr else client.stderr_handle km, kc = self.create_kernel_manager_and_kernel_client( connection_file, stderr_handle, is_cython=is_cython, ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def edit_file(self, filename, line): """Handle %edit magic petitions."""
if encoding.is_text_file(filename): # The default line number sent by ipykernel is always the last # one, but we prefer to use the first. self.edit_goto.emit(filename, 1, '')
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def config_options(self): """ Generate a Trailets Config instance for shell widgets using our config system This lets us create each widget with its own co...
# ---- Jupyter config ---- try: full_cfg = load_pyconfig_files(['jupyter_qtconsole_config.py'], jupyter_config_dir()) # From the full config we only select the JupyterWidget section # because the others have no effec...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def additional_options(self, is_pylab=False, is_sympy=False): """ Additional options for shell widgets that are not defined in JupyterWidget config options "...
options = dict( pylab=self.get_option('pylab'), autoload_pylab=self.get_option('pylab/autoload'), sympy=self.get_option('symbolic_math'), show_banner=self.get_option('show_banner') ) if is_pylab is True: options['autoload_pyl...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def register_client(self, client, give_focus=True): """Register new client"""
client.configure_shellwidget(give_focus=give_focus) # Local vars shellwidget = client.shellwidget control = shellwidget._control page_control = shellwidget._page_control # Create new clients with Ctrl+T shortcut shellwidget.new_client.connect(self.crea...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_client_index_from_id(self, client_id): """Return client index from id"""
for index, client in enumerate(self.clients): if id(client) == client_id: return index
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_related_clients(self, client): """ Get all other clients that are connected to the same kernel as `client` """
related_clients = [] for cl in self.get_clients(): if cl.connection_file == client.connection_file and \ cl is not client: related_clients.append(cl) return related_clients
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def restart(self): """ Restart the console This is needed when we switch projects to update PYTHONPATH and the selected interpreter """
self.master_clients = 0 self.create_new_client_if_empty = False for i in range(len(self.clients)): client = self.clients[-1] try: client.shutdown() except Exception as e: QMessageBox.warning(self, _('Warning'), ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_client_from_path(self, path): """Create a client with its cwd pointing to path."""
self.create_new_client() sw = self.get_current_shellwidget() sw.set_cwd(path)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_client_for_file(self, filename, is_cython=False): """Create a client to execute code related to a file."""
# Create client self.create_new_client(filename=filename, is_cython=is_cython) # Don't increase the count of master clients self.master_clients -= 1 # Rename client tab with filename client = self.get_current_client() client.allow_rename = False ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def get_client_for_file(self, filename): """Get client associated with a given file."""
client = None for idx, cl in enumerate(self.get_clients()): if self.filenames[idx] == filename: self.tabwidget.setCurrentIndex(idx) client = cl break return client
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def set_elapsed_time(self, client): """Set elapsed time for slave clients."""
related_clients = self.get_related_clients(client) for cl in related_clients: if cl.timer is not None: client.create_time_label() client.t0 = cl.t0 client.timer.timeout.connect(client.show_time) client.timer.start(1000) ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def tunnel_to_kernel(self, connection_info, hostname, sshkey=None, password=None, timeout=10): """ Tunnel connections to a kernel via ssh. Remote ports are...
lports = zmqtunnel.select_random_ports(4) rports = (connection_info['shell_port'], connection_info['iopub_port'], connection_info['stdin_port'], connection_info['hb_port']) remote_ip = connection_info['ip'] for lp, rp in zip(lports, rports): self.ssh_...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_kernel_spec(self, is_cython=False, is_pylab=False, is_sympy=False): """Create a kernel spec for our own kernels"""
# Before creating our kernel spec, we always need to # set this value in spyder.ini CONF.set('main', 'spyder_pythonpath', self.main.get_spyder_pythonpath()) return SpyderKernelSpec(is_cython=is_cython, is_pylab=is_pylab, ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def create_kernel_manager_and_kernel_client(self, connection_file, stderr_handle, is_cython=False, is_pylab=False, is_sympy=False): """Create kernel manager...
# Kernel spec kernel_spec = self.create_kernel_spec(is_cython=is_cython, is_pylab=is_pylab, is_sympy=is_sympy) # Kernel manager try: kernel_manager = QtKernelManager(connecti...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def restart_kernel(self): """Restart kernel of current client."""
client = self.get_current_client() if client is not None: self.switch_to_plugin() client.restart_kernel()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def reset_kernel(self): """Reset kernel of current client."""
client = self.get_current_client() if client is not None: self.switch_to_plugin() client.reset_namespace()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def interrupt_kernel(self): """Interrupt kernel of current client."""
client = self.get_current_client() if client is not None: self.switch_to_plugin() client.stop_button_click_handler()
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_execution_state_kernel(self): """Update actions following the execution state of the kernel."""
client = self.get_current_client() if client is not None: executing = client.stop_button.isEnabled() self.interrupt_action.setEnabled(executing)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def connect_external_kernel(self, shellwidget): """ Connect an external kernel to the Variable Explorer and Help, if it is a Spyder kernel. """
sw = shellwidget kc = shellwidget.kernel_client if self.main.help is not None: self.main.help.set_shell(sw) if self.main.variableexplorer is not None: self.main.variableexplorer.add_shellwidget(sw) sw.set_namespace_view_settings() ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def disambiguate_fname(self, fname): """Generate a file name without ambiguation."""
files_path_list = [filename for filename in self.filenames if filename] return sourcecode.disambiguate_fname(files_path_list, fname)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def update_tabs_text(self): """Update the text from the tabs."""
# This is needed to prevent that hanged consoles make reference # to an index that doesn't exist. See issue 4881 try: for index, fname in enumerate(self.filenames): client = self.clients[index] if fname: self.rename_client_t...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def rename_client_tab(self, client, given_name): """Rename client's tab"""
index = self.get_client_index_from_id(id(client)) if given_name is not None: client.given_name = given_name self.tabwidget.setTabText(index, client.get_name())
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def rename_tabs_after_change(self, given_name): """Rename tabs after a change in name."""
client = self.get_current_client() # Prevent renames that want to assign the same name of # a previous tab repeated = False for cl in self.get_clients(): if id(client) != id(cl) and given_name == cl.given_name: repeated = True ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def tab_name_editor(self): """Trigger the tab name editor."""
index = self.tabwidget.currentIndex() self.tabwidget.tabBar().tab_name_editor.edit_tab(index)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def show_intro(self): """Show intro to IPython help"""
from IPython.core.usage import interactive_usage self.main.help.show_rich_text(interactive_usage)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def show_guiref(self): """Show qtconsole help"""
from qtconsole.usage import gui_reference self.main.help.show_rich_text(gui_reference, collapse=True)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def show_quickref(self): """Show IPython Cheat Sheet"""
from IPython.core.usage import quick_reference self.main.help.show_plain_text(quick_reference)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def _remove_old_stderr_files(self): """ Remove stderr files left by previous Spyder instances. This is only required on Windows because we can't clean up s...
if os.name == 'nt': tmpdir = get_temp_dir() for fname in os.listdir(tmpdir): if osp.splitext(fname)[1] == '.stderr': try: os.remove(osp.join(tmpdir, fname)) except Exception: ...
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def rotate(self): """ Rotate the kill ring, then yank back the new top. Returns ------- A text string or None. """
self._index -= 1 if self._index >= 0: return self._ring[self._index] return None
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def kill_cursor(self, cursor): """ Kills the text selected by the give cursor. """
text = cursor.selectedText() if text: cursor.removeSelectedText() self.kill(text)
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def yank(self): """ Yank back the most recently killed text. """
text = self._ring.yank() if text: self._skip_cursor = True cursor = self._text_edit.textCursor() cursor.insertText(text) self._prev_yank = text
<SYSTEM_TASK:> Solve the following problem using Python, implementing the functions described below, one line at a time <END_TASK> <USER_TASK:> Description: def fixpath(path): """Normalize path fixing case, making absolute and removing symlinks"""
norm = osp.normcase if os.name == 'nt' else osp.normpath return norm(osp.abspath(osp.realpath(path)))