repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.lsp_server_ready
def lsp_server_ready(self, language, configuration): """Notify all stackeditors about LSP server availability.""" for editorstack in self.editorstacks: editorstack.notify_server_ready(language, configuration)
python
def lsp_server_ready(self, language, configuration): """Notify all stackeditors about LSP server availability.""" for editorstack in self.editorstacks: editorstack.notify_server_ready(language, configuration)
[ "def", "lsp_server_ready", "(", "self", ",", "language", ",", "configuration", ")", ":", "for", "editorstack", "in", "self", ".", "editorstacks", ":", "editorstack", ".", "notify_server_ready", "(", "language", ",", "configuration", ")" ]
Notify all stackeditors about LSP server availability.
[ "Notify", "all", "stackeditors", "about", "LSP", "server", "availability", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L301-L304
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.visibility_changed
def visibility_changed(self, enable): """DockWidget visibility has changed""" SpyderPluginWidget.visibility_changed(self, enable) if self.dockwidget is None: return if self.dockwidget.isWindow(): self.dock_toolbar.show() else: self.dock_toolbar.hide() if enable: self.refresh_plugin() self.sig_update_plugin_title.emit()
python
def visibility_changed(self, enable): """DockWidget visibility has changed""" SpyderPluginWidget.visibility_changed(self, enable) if self.dockwidget is None: return if self.dockwidget.isWindow(): self.dock_toolbar.show() else: self.dock_toolbar.hide() if enable: self.refresh_plugin() self.sig_update_plugin_title.emit()
[ "def", "visibility_changed", "(", "self", ",", "enable", ")", ":", "SpyderPluginWidget", ".", "visibility_changed", "(", "self", ",", "enable", ")", "if", "self", ".", "dockwidget", "is", "None", ":", "return", "if", "self", ".", "dockwidget", ".", "isWindow", "(", ")", ":", "self", ".", "dock_toolbar", ".", "show", "(", ")", "else", ":", "self", ".", "dock_toolbar", ".", "hide", "(", ")", "if", "enable", ":", "self", ".", "refresh_plugin", "(", ")", "self", ".", "sig_update_plugin_title", ".", "emit", "(", ")" ]
DockWidget visibility has changed
[ "DockWidget", "visibility", "has", "changed" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L329-L340
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.closing_plugin
def closing_plugin(self, cancelable=False): """Perform actions before parent main window is closed""" state = self.splitter.saveState() self.set_option('splitter_state', qbytearray_to_str(state)) filenames = [] editorstack = self.editorstacks[0] active_project_path = None if self.projects is not None: active_project_path = self.projects.get_active_project_path() if not active_project_path: self.set_open_filenames() else: self.projects.set_project_filenames( [finfo.filename for finfo in editorstack.data]) self.set_option('layout_settings', self.editorsplitter.get_layout_settings()) self.set_option('windows_layout_settings', [win.get_layout_settings() for win in self.editorwindows]) # self.set_option('filenames', filenames) self.set_option('recent_files', self.recent_files) # Stop autosave timer before closing windows self.autosave.stop_autosave_timer() try: if not editorstack.save_if_changed(cancelable) and cancelable: return False else: for win in self.editorwindows[:]: win.close() return True except IndexError: return True
python
def closing_plugin(self, cancelable=False): """Perform actions before parent main window is closed""" state = self.splitter.saveState() self.set_option('splitter_state', qbytearray_to_str(state)) filenames = [] editorstack = self.editorstacks[0] active_project_path = None if self.projects is not None: active_project_path = self.projects.get_active_project_path() if not active_project_path: self.set_open_filenames() else: self.projects.set_project_filenames( [finfo.filename for finfo in editorstack.data]) self.set_option('layout_settings', self.editorsplitter.get_layout_settings()) self.set_option('windows_layout_settings', [win.get_layout_settings() for win in self.editorwindows]) # self.set_option('filenames', filenames) self.set_option('recent_files', self.recent_files) # Stop autosave timer before closing windows self.autosave.stop_autosave_timer() try: if not editorstack.save_if_changed(cancelable) and cancelable: return False else: for win in self.editorwindows[:]: win.close() return True except IndexError: return True
[ "def", "closing_plugin", "(", "self", ",", "cancelable", "=", "False", ")", ":", "state", "=", "self", ".", "splitter", ".", "saveState", "(", ")", "self", ".", "set_option", "(", "'splitter_state'", ",", "qbytearray_to_str", "(", "state", ")", ")", "filenames", "=", "[", "]", "editorstack", "=", "self", ".", "editorstacks", "[", "0", "]", "active_project_path", "=", "None", "if", "self", ".", "projects", "is", "not", "None", ":", "active_project_path", "=", "self", ".", "projects", ".", "get_active_project_path", "(", ")", "if", "not", "active_project_path", ":", "self", ".", "set_open_filenames", "(", ")", "else", ":", "self", ".", "projects", ".", "set_project_filenames", "(", "[", "finfo", ".", "filename", "for", "finfo", "in", "editorstack", ".", "data", "]", ")", "self", ".", "set_option", "(", "'layout_settings'", ",", "self", ".", "editorsplitter", ".", "get_layout_settings", "(", ")", ")", "self", ".", "set_option", "(", "'windows_layout_settings'", ",", "[", "win", ".", "get_layout_settings", "(", ")", "for", "win", "in", "self", ".", "editorwindows", "]", ")", "# self.set_option('filenames', filenames)\r", "self", ".", "set_option", "(", "'recent_files'", ",", "self", ".", "recent_files", ")", "# Stop autosave timer before closing windows\r", "self", ".", "autosave", ".", "stop_autosave_timer", "(", ")", "try", ":", "if", "not", "editorstack", ".", "save_if_changed", "(", "cancelable", ")", "and", "cancelable", ":", "return", "False", "else", ":", "for", "win", "in", "self", ".", "editorwindows", "[", ":", "]", ":", "win", ".", "close", "(", ")", "return", "True", "except", "IndexError", ":", "return", "True" ]
Perform actions before parent main window is closed
[ "Perform", "actions", "before", "parent", "main", "window", "is", "closed" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L348-L382
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.get_plugin_actions
def get_plugin_actions(self): """Return a list of actions related to plugin""" # ---- File menu and toolbar ---- self.new_action = create_action( self, _("&New file..."), icon=ima.icon('filenew'), tip=_("New file"), triggered=self.new, context=Qt.WidgetShortcut ) self.register_shortcut(self.new_action, context="Editor", name="New file", add_sc_to_tip=True) self.open_last_closed_action = create_action( self, _("O&pen last closed"), tip=_("Open last closed"), triggered=self.open_last_closed ) self.register_shortcut(self.open_last_closed_action, context="Editor", name="Open last closed") self.open_action = create_action(self, _("&Open..."), icon=ima.icon('fileopen'), tip=_("Open file"), triggered=self.load, context=Qt.WidgetShortcut) self.register_shortcut(self.open_action, context="Editor", name="Open file", add_sc_to_tip=True) self.revert_action = create_action(self, _("&Revert"), icon=ima.icon('revert'), tip=_("Revert file from disk"), triggered=self.revert) self.save_action = create_action(self, _("&Save"), icon=ima.icon('filesave'), tip=_("Save file"), triggered=self.save, context=Qt.WidgetShortcut) self.register_shortcut(self.save_action, context="Editor", name="Save file", add_sc_to_tip=True) self.save_all_action = create_action(self, _("Sav&e all"), icon=ima.icon('save_all'), tip=_("Save all files"), triggered=self.save_all, context=Qt.WidgetShortcut) self.register_shortcut(self.save_all_action, context="Editor", name="Save all", add_sc_to_tip=True) save_as_action = create_action(self, _("Save &as..."), None, ima.icon('filesaveas'), tip=_("Save current file as..."), triggered=self.save_as, context=Qt.WidgetShortcut) self.register_shortcut(save_as_action, "Editor", "Save As") save_copy_as_action = create_action(self, _("Save copy as..."), None, ima.icon('filesaveas'), _("Save copy of current file as..."), triggered=self.save_copy_as) print_preview_action = create_action(self, _("Print preview..."), tip=_("Print preview..."), triggered=self.print_preview) self.print_action = create_action(self, _("&Print..."), icon=ima.icon('print'), tip=_("Print current file..."), triggered=self.print_file) # Shortcut for close_action is defined in widgets/editor.py self.close_action = create_action(self, _("&Close"), icon=ima.icon('fileclose'), tip=_("Close current file"), triggered=self.close_file) self.close_all_action = create_action(self, _("C&lose all"), icon=ima.icon('filecloseall'), tip=_("Close all opened files"), triggered=self.close_all_files, context=Qt.WidgetShortcut) self.register_shortcut(self.close_all_action, context="Editor", name="Close all") # ---- Find menu and toolbar ---- _text = _("&Find text") find_action = create_action(self, _text, icon=ima.icon('find'), tip=_text, triggered=self.find, context=Qt.WidgetShortcut) self.register_shortcut(find_action, context="_", name="Find text", add_sc_to_tip=True) find_next_action = create_action(self, _("Find &next"), icon=ima.icon('findnext'), triggered=self.find_next, context=Qt.WidgetShortcut) self.register_shortcut(find_next_action, context="_", name="Find next") find_previous_action = create_action(self, _("Find &previous"), icon=ima.icon('findprevious'), triggered=self.find_previous, context=Qt.WidgetShortcut) self.register_shortcut(find_previous_action, context="_", name="Find previous") _text = _("&Replace text") replace_action = create_action(self, _text, icon=ima.icon('replace'), tip=_text, triggered=self.replace, context=Qt.WidgetShortcut) self.register_shortcut(replace_action, context="_", name="Replace text") # ---- Debug menu and toolbar ---- set_clear_breakpoint_action = create_action(self, _("Set/Clear breakpoint"), icon=ima.icon('breakpoint_big'), triggered=self.set_or_clear_breakpoint, context=Qt.WidgetShortcut) self.register_shortcut(set_clear_breakpoint_action, context="Editor", name="Breakpoint") set_cond_breakpoint_action = create_action(self, _("Set/Edit conditional breakpoint"), icon=ima.icon('breakpoint_cond_big'), triggered=self.set_or_edit_conditional_breakpoint, context=Qt.WidgetShortcut) self.register_shortcut(set_cond_breakpoint_action, context="Editor", name="Conditional breakpoint") clear_all_breakpoints_action = create_action(self, _('Clear breakpoints in all files'), triggered=self.clear_all_breakpoints) self.winpdb_action = create_action(self, _("Debug with winpdb"), triggered=self.run_winpdb) self.winpdb_action.setEnabled(WINPDB_PATH is not None and PY2) # --- Debug toolbar --- debug_action = create_action(self, _("&Debug"), icon=ima.icon('debug'), tip=_("Debug file"), triggered=self.debug_file) self.register_shortcut(debug_action, context="_", name="Debug", add_sc_to_tip=True) debug_next_action = create_action(self, _("Step"), icon=ima.icon('arrow-step-over'), tip=_("Run current line"), triggered=lambda: self.debug_command("next")) self.register_shortcut(debug_next_action, "_", "Debug Step Over", add_sc_to_tip=True) debug_continue_action = create_action(self, _("Continue"), icon=ima.icon('arrow-continue'), tip=_("Continue execution until next breakpoint"), triggered=lambda: self.debug_command("continue")) self.register_shortcut(debug_continue_action, "_", "Debug Continue", add_sc_to_tip=True) debug_step_action = create_action(self, _("Step Into"), icon=ima.icon('arrow-step-in'), tip=_("Step into function or method of current line"), triggered=lambda: self.debug_command("step")) self.register_shortcut(debug_step_action, "_", "Debug Step Into", add_sc_to_tip=True) debug_return_action = create_action(self, _("Step Return"), icon=ima.icon('arrow-step-out'), tip=_("Run until current function or method returns"), triggered=lambda: self.debug_command("return")) self.register_shortcut(debug_return_action, "_", "Debug Step Return", add_sc_to_tip=True) debug_exit_action = create_action(self, _("Stop"), icon=ima.icon('stop_debug'), tip=_("Stop debugging"), triggered=lambda: self.debug_command("exit")) self.register_shortcut(debug_exit_action, "_", "Debug Exit", add_sc_to_tip=True) # --- Run toolbar --- run_action = create_action(self, _("&Run"), icon=ima.icon('run'), tip=_("Run file"), triggered=self.run_file) self.register_shortcut(run_action, context="_", name="Run", add_sc_to_tip=True) configure_action = create_action(self, _("&Configuration per file..."), icon=ima.icon('run_settings'), tip=_("Run settings"), menurole=QAction.NoRole, triggered=self.edit_run_configurations) self.register_shortcut(configure_action, context="_", name="Configure", add_sc_to_tip=True) re_run_action = create_action(self, _("Re-run &last script"), icon=ima.icon('run_again'), tip=_("Run again last file"), triggered=self.re_run_file) self.register_shortcut(re_run_action, context="_", name="Re-run last script", add_sc_to_tip=True) run_selected_action = create_action(self, _("Run &selection or " "current line"), icon=ima.icon('run_selection'), tip=_("Run selection or " "current line"), triggered=self.run_selection, context=Qt.WidgetShortcut) self.register_shortcut(run_selected_action, context="Editor", name="Run selection", add_sc_to_tip=True) run_cell_action = create_action(self, _("Run cell"), icon=ima.icon('run_cell'), shortcut=QKeySequence(RUN_CELL_SHORTCUT), tip=_("Run current cell (Ctrl+Enter)\n" "[Use #%% to create cells]"), triggered=self.run_cell, context=Qt.WidgetShortcut) run_cell_advance_action = create_action(self, _("Run cell and advance"), icon=ima.icon('run_cell_advance'), shortcut=QKeySequence(RUN_CELL_AND_ADVANCE_SHORTCUT), tip=_("Run current cell and go to the next one " "(Shift+Enter)"), triggered=self.run_cell_and_advance, context=Qt.WidgetShortcut) re_run_last_cell_action = create_action(self, _("Re-run last cell"), tip=_("Re run last cell "), triggered=self.re_run_last_cell, context=Qt.WidgetShortcut) self.register_shortcut(re_run_last_cell_action, context="Editor", name='re-run last cell', add_sc_to_tip=True) # --- Source code Toolbar --- self.todo_list_action = create_action(self, _("Show todo list"), icon=ima.icon('todo_list'), tip=_("Show comments list (TODO/FIXME/XXX/HINT/TIP/@todo/" "HACK/BUG/OPTIMIZE/!!!/???)"), triggered=self.go_to_next_todo) self.todo_menu = QMenu(self) self.todo_menu.setStyleSheet("QMenu {menu-scrollable: 1;}") self.todo_list_action.setMenu(self.todo_menu) self.todo_menu.aboutToShow.connect(self.update_todo_menu) self.warning_list_action = create_action(self, _("Show warning/error list"), icon=ima.icon('wng_list'), tip=_("Show code analysis warnings/errors"), triggered=self.go_to_next_warning) self.warning_menu = QMenu(self) self.warning_menu.setStyleSheet("QMenu {menu-scrollable: 1;}") self.warning_list_action.setMenu(self.warning_menu) self.warning_menu.aboutToShow.connect(self.update_warning_menu) self.previous_warning_action = create_action(self, _("Previous warning/error"), icon=ima.icon('prev_wng'), tip=_("Go to previous code analysis warning/error"), triggered=self.go_to_previous_warning, context=Qt.WidgetShortcut) self.register_shortcut(self.previous_warning_action, context="Editor", name="Previous warning", add_sc_to_tip=True) self.next_warning_action = create_action(self, _("Next warning/error"), icon=ima.icon('next_wng'), tip=_("Go to next code analysis warning/error"), triggered=self.go_to_next_warning, context=Qt.WidgetShortcut) self.register_shortcut(self.next_warning_action, context="Editor", name="Next warning", add_sc_to_tip=True) self.previous_edit_cursor_action = create_action(self, _("Last edit location"), icon=ima.icon('last_edit_location'), tip=_("Go to last edit location"), triggered=self.go_to_last_edit_location, context=Qt.WidgetShortcut) self.register_shortcut(self.previous_edit_cursor_action, context="Editor", name="Last edit location", add_sc_to_tip=True) self.previous_cursor_action = create_action(self, _("Previous cursor position"), icon=ima.icon('prev_cursor'), tip=_("Go to previous cursor position"), triggered=self.go_to_previous_cursor_position, context=Qt.WidgetShortcut) self.register_shortcut(self.previous_cursor_action, context="Editor", name="Previous cursor position", add_sc_to_tip=True) self.next_cursor_action = create_action(self, _("Next cursor position"), icon=ima.icon('next_cursor'), tip=_("Go to next cursor position"), triggered=self.go_to_next_cursor_position, context=Qt.WidgetShortcut) self.register_shortcut(self.next_cursor_action, context="Editor", name="Next cursor position", add_sc_to_tip=True) # --- Edit Toolbar --- self.toggle_comment_action = create_action(self, _("Comment")+"/"+_("Uncomment"), icon=ima.icon('comment'), tip=_("Comment current line or selection"), triggered=self.toggle_comment, context=Qt.WidgetShortcut) self.register_shortcut(self.toggle_comment_action, context="Editor", name="Toggle comment") blockcomment_action = create_action(self, _("Add &block comment"), tip=_("Add block comment around " "current line or selection"), triggered=self.blockcomment, context=Qt.WidgetShortcut) self.register_shortcut(blockcomment_action, context="Editor", name="Blockcomment") unblockcomment_action = create_action(self, _("R&emove block comment"), tip = _("Remove comment block around " "current line or selection"), triggered=self.unblockcomment, context=Qt.WidgetShortcut) self.register_shortcut(unblockcomment_action, context="Editor", name="Unblockcomment") # ---------------------------------------------------------------------- # The following action shortcuts are hard-coded in CodeEditor # keyPressEvent handler (the shortcut is here only to inform user): # (context=Qt.WidgetShortcut -> disable shortcut for other widgets) self.indent_action = create_action(self, _("Indent"), "Tab", icon=ima.icon('indent'), tip=_("Indent current line or selection"), triggered=self.indent, context=Qt.WidgetShortcut) self.unindent_action = create_action(self, _("Unindent"), "Shift+Tab", icon=ima.icon('unindent'), tip=_("Unindent current line or selection"), triggered=self.unindent, context=Qt.WidgetShortcut) self.text_uppercase_action = create_action(self, _("Toggle Uppercase"), tip=_("Change to uppercase current line or selection"), triggered=self.text_uppercase, context=Qt.WidgetShortcut) self.register_shortcut(self.text_uppercase_action, context="Editor", name="transform to uppercase") self.text_lowercase_action = create_action(self, _("Toggle Lowercase"), tip=_("Change to lowercase current line or selection"), triggered=self.text_lowercase, context=Qt.WidgetShortcut) self.register_shortcut(self.text_lowercase_action, context="Editor", name="transform to lowercase") # ---------------------------------------------------------------------- self.win_eol_action = create_action(self, _("Carriage return and line feed (Windows)"), toggled=lambda checked: self.toggle_eol_chars('nt', checked)) self.linux_eol_action = create_action(self, _("Line feed (UNIX)"), toggled=lambda checked: self.toggle_eol_chars('posix', checked)) self.mac_eol_action = create_action(self, _("Carriage return (Mac)"), toggled=lambda checked: self.toggle_eol_chars('mac', checked)) eol_action_group = QActionGroup(self) eol_actions = (self.win_eol_action, self.linux_eol_action, self.mac_eol_action) add_actions(eol_action_group, eol_actions) eol_menu = QMenu(_("Convert end-of-line characters"), self) add_actions(eol_menu, eol_actions) trailingspaces_action = create_action(self, _("Remove trailing spaces"), triggered=self.remove_trailing_spaces) # Checkable actions showblanks_action = self._create_checkable_action( _("Show blank spaces"), 'blank_spaces', 'set_blanks_enabled') scrollpastend_action = self._create_checkable_action( _("Scroll past the end"), 'scroll_past_end', 'set_scrollpastend_enabled') showindentguides_action = self._create_checkable_action( _("Show indent guides."), 'indent_guides', 'set_indent_guides') show_classfunc_dropdown_action = self._create_checkable_action( _("Show selector for classes and functions."), 'show_class_func_dropdown', 'set_classfunc_dropdown_visible') showcode_analysis_pep8_action = self._create_checkable_action( _("Show code style warnings (pep8)"), 'code_analysis/pep8', 'set_pep8_enabled') self.checkable_actions = { 'blank_spaces': showblanks_action, 'scroll_past_end': scrollpastend_action, 'indent_guides': showindentguides_action, 'show_class_func_dropdown': show_classfunc_dropdown_action, 'code_analysis/pep8': showcode_analysis_pep8_action} fixindentation_action = create_action(self, _("Fix indentation"), tip=_("Replace tab characters by space characters"), triggered=self.fix_indentation) gotoline_action = create_action(self, _("Go to line..."), icon=ima.icon('gotoline'), triggered=self.go_to_line, context=Qt.WidgetShortcut) self.register_shortcut(gotoline_action, context="Editor", name="Go to line") workdir_action = create_action(self, _("Set console working directory"), icon=ima.icon('DirOpenIcon'), tip=_("Set current console (and file explorer) working " "directory to current script directory"), triggered=self.__set_workdir) self.max_recent_action = create_action(self, _("Maximum number of recent files..."), triggered=self.change_max_recent_files) self.clear_recent_action = create_action(self, _("Clear this list"), tip=_("Clear recent files list"), triggered=self.clear_recent_files) # ---- File menu/toolbar construction ---- self.recent_file_menu = QMenu(_("Open &recent"), self) self.recent_file_menu.aboutToShow.connect(self.update_recent_file_menu) file_menu_actions = [self.new_action, MENU_SEPARATOR, self.open_action, self.open_last_closed_action, self.recent_file_menu, MENU_SEPARATOR, MENU_SEPARATOR, self.save_action, self.save_all_action, save_as_action, save_copy_as_action, self.revert_action, MENU_SEPARATOR, print_preview_action, self.print_action, MENU_SEPARATOR, self.close_action, self.close_all_action, MENU_SEPARATOR] self.main.file_menu_actions += file_menu_actions file_toolbar_actions = ([self.new_action, self.open_action, self.save_action, self.save_all_action] + self.main.file_toolbar_actions) self.main.file_toolbar_actions = file_toolbar_actions # ---- Find menu/toolbar construction ---- self.main.search_menu_actions = [find_action, find_next_action, find_previous_action, replace_action] self.main.search_toolbar_actions = [find_action, find_next_action, replace_action] # ---- Edit menu/toolbar construction ---- self.edit_menu_actions = [self.toggle_comment_action, blockcomment_action, unblockcomment_action, self.indent_action, self.unindent_action, self.text_uppercase_action, self.text_lowercase_action] self.main.edit_menu_actions += [MENU_SEPARATOR] + self.edit_menu_actions edit_toolbar_actions = [self.toggle_comment_action, self.unindent_action, self.indent_action] self.main.edit_toolbar_actions += edit_toolbar_actions # ---- Search menu/toolbar construction ---- self.main.search_menu_actions += [gotoline_action] self.main.search_toolbar_actions += [gotoline_action] # ---- Run menu/toolbar construction ---- run_menu_actions = [run_action, run_cell_action, run_cell_advance_action, re_run_last_cell_action, MENU_SEPARATOR, run_selected_action, re_run_action, configure_action, MENU_SEPARATOR] self.main.run_menu_actions += run_menu_actions run_toolbar_actions = [run_action, run_cell_action, run_cell_advance_action, run_selected_action, re_run_action] self.main.run_toolbar_actions += run_toolbar_actions # ---- Debug menu/toolbar construction ---- # NOTE: 'list_breakpoints' is used by the breakpoints # plugin to add its "List breakpoints" action to this # menu debug_menu_actions = [debug_action, debug_next_action, debug_step_action, debug_return_action, debug_continue_action, debug_exit_action, MENU_SEPARATOR, set_clear_breakpoint_action, set_cond_breakpoint_action, clear_all_breakpoints_action, 'list_breakpoints', MENU_SEPARATOR, self.winpdb_action] self.main.debug_menu_actions += debug_menu_actions debug_toolbar_actions = [debug_action, debug_next_action, debug_step_action, debug_return_action, debug_continue_action, debug_exit_action] self.main.debug_toolbar_actions += debug_toolbar_actions # ---- Source menu/toolbar construction ---- source_menu_actions = [eol_menu, showblanks_action, scrollpastend_action, showindentguides_action, show_classfunc_dropdown_action, showcode_analysis_pep8_action, trailingspaces_action, fixindentation_action, MENU_SEPARATOR, self.todo_list_action, self.warning_list_action, self.previous_warning_action, self.next_warning_action, MENU_SEPARATOR, self.previous_edit_cursor_action, self.previous_cursor_action, self.next_cursor_action] self.main.source_menu_actions += source_menu_actions source_toolbar_actions = [self.todo_list_action, self.warning_list_action, self.previous_warning_action, self.next_warning_action, MENU_SEPARATOR, self.previous_edit_cursor_action, self.previous_cursor_action, self.next_cursor_action] self.main.source_toolbar_actions += source_toolbar_actions # ---- Dock widget and file dependent actions ---- self.dock_toolbar_actions = (file_toolbar_actions + [MENU_SEPARATOR] + source_toolbar_actions + [MENU_SEPARATOR] + run_toolbar_actions + [MENU_SEPARATOR] + debug_toolbar_actions + [MENU_SEPARATOR] + edit_toolbar_actions) self.pythonfile_dependent_actions = [run_action, configure_action, set_clear_breakpoint_action, set_cond_breakpoint_action, debug_action, run_selected_action, run_cell_action, run_cell_advance_action, re_run_last_cell_action, blockcomment_action, unblockcomment_action, self.winpdb_action] self.cythonfile_compatible_actions = [run_action, configure_action] self.file_dependent_actions = self.pythonfile_dependent_actions + \ [self.save_action, save_as_action, save_copy_as_action, print_preview_action, self.print_action, self.save_all_action, gotoline_action, workdir_action, self.close_action, self.close_all_action, self.toggle_comment_action, self.revert_action, self.indent_action, self.unindent_action] self.stack_menu_actions = [gotoline_action, workdir_action] return self.file_dependent_actions
python
def get_plugin_actions(self): """Return a list of actions related to plugin""" # ---- File menu and toolbar ---- self.new_action = create_action( self, _("&New file..."), icon=ima.icon('filenew'), tip=_("New file"), triggered=self.new, context=Qt.WidgetShortcut ) self.register_shortcut(self.new_action, context="Editor", name="New file", add_sc_to_tip=True) self.open_last_closed_action = create_action( self, _("O&pen last closed"), tip=_("Open last closed"), triggered=self.open_last_closed ) self.register_shortcut(self.open_last_closed_action, context="Editor", name="Open last closed") self.open_action = create_action(self, _("&Open..."), icon=ima.icon('fileopen'), tip=_("Open file"), triggered=self.load, context=Qt.WidgetShortcut) self.register_shortcut(self.open_action, context="Editor", name="Open file", add_sc_to_tip=True) self.revert_action = create_action(self, _("&Revert"), icon=ima.icon('revert'), tip=_("Revert file from disk"), triggered=self.revert) self.save_action = create_action(self, _("&Save"), icon=ima.icon('filesave'), tip=_("Save file"), triggered=self.save, context=Qt.WidgetShortcut) self.register_shortcut(self.save_action, context="Editor", name="Save file", add_sc_to_tip=True) self.save_all_action = create_action(self, _("Sav&e all"), icon=ima.icon('save_all'), tip=_("Save all files"), triggered=self.save_all, context=Qt.WidgetShortcut) self.register_shortcut(self.save_all_action, context="Editor", name="Save all", add_sc_to_tip=True) save_as_action = create_action(self, _("Save &as..."), None, ima.icon('filesaveas'), tip=_("Save current file as..."), triggered=self.save_as, context=Qt.WidgetShortcut) self.register_shortcut(save_as_action, "Editor", "Save As") save_copy_as_action = create_action(self, _("Save copy as..."), None, ima.icon('filesaveas'), _("Save copy of current file as..."), triggered=self.save_copy_as) print_preview_action = create_action(self, _("Print preview..."), tip=_("Print preview..."), triggered=self.print_preview) self.print_action = create_action(self, _("&Print..."), icon=ima.icon('print'), tip=_("Print current file..."), triggered=self.print_file) # Shortcut for close_action is defined in widgets/editor.py self.close_action = create_action(self, _("&Close"), icon=ima.icon('fileclose'), tip=_("Close current file"), triggered=self.close_file) self.close_all_action = create_action(self, _("C&lose all"), icon=ima.icon('filecloseall'), tip=_("Close all opened files"), triggered=self.close_all_files, context=Qt.WidgetShortcut) self.register_shortcut(self.close_all_action, context="Editor", name="Close all") # ---- Find menu and toolbar ---- _text = _("&Find text") find_action = create_action(self, _text, icon=ima.icon('find'), tip=_text, triggered=self.find, context=Qt.WidgetShortcut) self.register_shortcut(find_action, context="_", name="Find text", add_sc_to_tip=True) find_next_action = create_action(self, _("Find &next"), icon=ima.icon('findnext'), triggered=self.find_next, context=Qt.WidgetShortcut) self.register_shortcut(find_next_action, context="_", name="Find next") find_previous_action = create_action(self, _("Find &previous"), icon=ima.icon('findprevious'), triggered=self.find_previous, context=Qt.WidgetShortcut) self.register_shortcut(find_previous_action, context="_", name="Find previous") _text = _("&Replace text") replace_action = create_action(self, _text, icon=ima.icon('replace'), tip=_text, triggered=self.replace, context=Qt.WidgetShortcut) self.register_shortcut(replace_action, context="_", name="Replace text") # ---- Debug menu and toolbar ---- set_clear_breakpoint_action = create_action(self, _("Set/Clear breakpoint"), icon=ima.icon('breakpoint_big'), triggered=self.set_or_clear_breakpoint, context=Qt.WidgetShortcut) self.register_shortcut(set_clear_breakpoint_action, context="Editor", name="Breakpoint") set_cond_breakpoint_action = create_action(self, _("Set/Edit conditional breakpoint"), icon=ima.icon('breakpoint_cond_big'), triggered=self.set_or_edit_conditional_breakpoint, context=Qt.WidgetShortcut) self.register_shortcut(set_cond_breakpoint_action, context="Editor", name="Conditional breakpoint") clear_all_breakpoints_action = create_action(self, _('Clear breakpoints in all files'), triggered=self.clear_all_breakpoints) self.winpdb_action = create_action(self, _("Debug with winpdb"), triggered=self.run_winpdb) self.winpdb_action.setEnabled(WINPDB_PATH is not None and PY2) # --- Debug toolbar --- debug_action = create_action(self, _("&Debug"), icon=ima.icon('debug'), tip=_("Debug file"), triggered=self.debug_file) self.register_shortcut(debug_action, context="_", name="Debug", add_sc_to_tip=True) debug_next_action = create_action(self, _("Step"), icon=ima.icon('arrow-step-over'), tip=_("Run current line"), triggered=lambda: self.debug_command("next")) self.register_shortcut(debug_next_action, "_", "Debug Step Over", add_sc_to_tip=True) debug_continue_action = create_action(self, _("Continue"), icon=ima.icon('arrow-continue'), tip=_("Continue execution until next breakpoint"), triggered=lambda: self.debug_command("continue")) self.register_shortcut(debug_continue_action, "_", "Debug Continue", add_sc_to_tip=True) debug_step_action = create_action(self, _("Step Into"), icon=ima.icon('arrow-step-in'), tip=_("Step into function or method of current line"), triggered=lambda: self.debug_command("step")) self.register_shortcut(debug_step_action, "_", "Debug Step Into", add_sc_to_tip=True) debug_return_action = create_action(self, _("Step Return"), icon=ima.icon('arrow-step-out'), tip=_("Run until current function or method returns"), triggered=lambda: self.debug_command("return")) self.register_shortcut(debug_return_action, "_", "Debug Step Return", add_sc_to_tip=True) debug_exit_action = create_action(self, _("Stop"), icon=ima.icon('stop_debug'), tip=_("Stop debugging"), triggered=lambda: self.debug_command("exit")) self.register_shortcut(debug_exit_action, "_", "Debug Exit", add_sc_to_tip=True) # --- Run toolbar --- run_action = create_action(self, _("&Run"), icon=ima.icon('run'), tip=_("Run file"), triggered=self.run_file) self.register_shortcut(run_action, context="_", name="Run", add_sc_to_tip=True) configure_action = create_action(self, _("&Configuration per file..."), icon=ima.icon('run_settings'), tip=_("Run settings"), menurole=QAction.NoRole, triggered=self.edit_run_configurations) self.register_shortcut(configure_action, context="_", name="Configure", add_sc_to_tip=True) re_run_action = create_action(self, _("Re-run &last script"), icon=ima.icon('run_again'), tip=_("Run again last file"), triggered=self.re_run_file) self.register_shortcut(re_run_action, context="_", name="Re-run last script", add_sc_to_tip=True) run_selected_action = create_action(self, _("Run &selection or " "current line"), icon=ima.icon('run_selection'), tip=_("Run selection or " "current line"), triggered=self.run_selection, context=Qt.WidgetShortcut) self.register_shortcut(run_selected_action, context="Editor", name="Run selection", add_sc_to_tip=True) run_cell_action = create_action(self, _("Run cell"), icon=ima.icon('run_cell'), shortcut=QKeySequence(RUN_CELL_SHORTCUT), tip=_("Run current cell (Ctrl+Enter)\n" "[Use #%% to create cells]"), triggered=self.run_cell, context=Qt.WidgetShortcut) run_cell_advance_action = create_action(self, _("Run cell and advance"), icon=ima.icon('run_cell_advance'), shortcut=QKeySequence(RUN_CELL_AND_ADVANCE_SHORTCUT), tip=_("Run current cell and go to the next one " "(Shift+Enter)"), triggered=self.run_cell_and_advance, context=Qt.WidgetShortcut) re_run_last_cell_action = create_action(self, _("Re-run last cell"), tip=_("Re run last cell "), triggered=self.re_run_last_cell, context=Qt.WidgetShortcut) self.register_shortcut(re_run_last_cell_action, context="Editor", name='re-run last cell', add_sc_to_tip=True) # --- Source code Toolbar --- self.todo_list_action = create_action(self, _("Show todo list"), icon=ima.icon('todo_list'), tip=_("Show comments list (TODO/FIXME/XXX/HINT/TIP/@todo/" "HACK/BUG/OPTIMIZE/!!!/???)"), triggered=self.go_to_next_todo) self.todo_menu = QMenu(self) self.todo_menu.setStyleSheet("QMenu {menu-scrollable: 1;}") self.todo_list_action.setMenu(self.todo_menu) self.todo_menu.aboutToShow.connect(self.update_todo_menu) self.warning_list_action = create_action(self, _("Show warning/error list"), icon=ima.icon('wng_list'), tip=_("Show code analysis warnings/errors"), triggered=self.go_to_next_warning) self.warning_menu = QMenu(self) self.warning_menu.setStyleSheet("QMenu {menu-scrollable: 1;}") self.warning_list_action.setMenu(self.warning_menu) self.warning_menu.aboutToShow.connect(self.update_warning_menu) self.previous_warning_action = create_action(self, _("Previous warning/error"), icon=ima.icon('prev_wng'), tip=_("Go to previous code analysis warning/error"), triggered=self.go_to_previous_warning, context=Qt.WidgetShortcut) self.register_shortcut(self.previous_warning_action, context="Editor", name="Previous warning", add_sc_to_tip=True) self.next_warning_action = create_action(self, _("Next warning/error"), icon=ima.icon('next_wng'), tip=_("Go to next code analysis warning/error"), triggered=self.go_to_next_warning, context=Qt.WidgetShortcut) self.register_shortcut(self.next_warning_action, context="Editor", name="Next warning", add_sc_to_tip=True) self.previous_edit_cursor_action = create_action(self, _("Last edit location"), icon=ima.icon('last_edit_location'), tip=_("Go to last edit location"), triggered=self.go_to_last_edit_location, context=Qt.WidgetShortcut) self.register_shortcut(self.previous_edit_cursor_action, context="Editor", name="Last edit location", add_sc_to_tip=True) self.previous_cursor_action = create_action(self, _("Previous cursor position"), icon=ima.icon('prev_cursor'), tip=_("Go to previous cursor position"), triggered=self.go_to_previous_cursor_position, context=Qt.WidgetShortcut) self.register_shortcut(self.previous_cursor_action, context="Editor", name="Previous cursor position", add_sc_to_tip=True) self.next_cursor_action = create_action(self, _("Next cursor position"), icon=ima.icon('next_cursor'), tip=_("Go to next cursor position"), triggered=self.go_to_next_cursor_position, context=Qt.WidgetShortcut) self.register_shortcut(self.next_cursor_action, context="Editor", name="Next cursor position", add_sc_to_tip=True) # --- Edit Toolbar --- self.toggle_comment_action = create_action(self, _("Comment")+"/"+_("Uncomment"), icon=ima.icon('comment'), tip=_("Comment current line or selection"), triggered=self.toggle_comment, context=Qt.WidgetShortcut) self.register_shortcut(self.toggle_comment_action, context="Editor", name="Toggle comment") blockcomment_action = create_action(self, _("Add &block comment"), tip=_("Add block comment around " "current line or selection"), triggered=self.blockcomment, context=Qt.WidgetShortcut) self.register_shortcut(blockcomment_action, context="Editor", name="Blockcomment") unblockcomment_action = create_action(self, _("R&emove block comment"), tip = _("Remove comment block around " "current line or selection"), triggered=self.unblockcomment, context=Qt.WidgetShortcut) self.register_shortcut(unblockcomment_action, context="Editor", name="Unblockcomment") # ---------------------------------------------------------------------- # The following action shortcuts are hard-coded in CodeEditor # keyPressEvent handler (the shortcut is here only to inform user): # (context=Qt.WidgetShortcut -> disable shortcut for other widgets) self.indent_action = create_action(self, _("Indent"), "Tab", icon=ima.icon('indent'), tip=_("Indent current line or selection"), triggered=self.indent, context=Qt.WidgetShortcut) self.unindent_action = create_action(self, _("Unindent"), "Shift+Tab", icon=ima.icon('unindent'), tip=_("Unindent current line or selection"), triggered=self.unindent, context=Qt.WidgetShortcut) self.text_uppercase_action = create_action(self, _("Toggle Uppercase"), tip=_("Change to uppercase current line or selection"), triggered=self.text_uppercase, context=Qt.WidgetShortcut) self.register_shortcut(self.text_uppercase_action, context="Editor", name="transform to uppercase") self.text_lowercase_action = create_action(self, _("Toggle Lowercase"), tip=_("Change to lowercase current line or selection"), triggered=self.text_lowercase, context=Qt.WidgetShortcut) self.register_shortcut(self.text_lowercase_action, context="Editor", name="transform to lowercase") # ---------------------------------------------------------------------- self.win_eol_action = create_action(self, _("Carriage return and line feed (Windows)"), toggled=lambda checked: self.toggle_eol_chars('nt', checked)) self.linux_eol_action = create_action(self, _("Line feed (UNIX)"), toggled=lambda checked: self.toggle_eol_chars('posix', checked)) self.mac_eol_action = create_action(self, _("Carriage return (Mac)"), toggled=lambda checked: self.toggle_eol_chars('mac', checked)) eol_action_group = QActionGroup(self) eol_actions = (self.win_eol_action, self.linux_eol_action, self.mac_eol_action) add_actions(eol_action_group, eol_actions) eol_menu = QMenu(_("Convert end-of-line characters"), self) add_actions(eol_menu, eol_actions) trailingspaces_action = create_action(self, _("Remove trailing spaces"), triggered=self.remove_trailing_spaces) # Checkable actions showblanks_action = self._create_checkable_action( _("Show blank spaces"), 'blank_spaces', 'set_blanks_enabled') scrollpastend_action = self._create_checkable_action( _("Scroll past the end"), 'scroll_past_end', 'set_scrollpastend_enabled') showindentguides_action = self._create_checkable_action( _("Show indent guides."), 'indent_guides', 'set_indent_guides') show_classfunc_dropdown_action = self._create_checkable_action( _("Show selector for classes and functions."), 'show_class_func_dropdown', 'set_classfunc_dropdown_visible') showcode_analysis_pep8_action = self._create_checkable_action( _("Show code style warnings (pep8)"), 'code_analysis/pep8', 'set_pep8_enabled') self.checkable_actions = { 'blank_spaces': showblanks_action, 'scroll_past_end': scrollpastend_action, 'indent_guides': showindentguides_action, 'show_class_func_dropdown': show_classfunc_dropdown_action, 'code_analysis/pep8': showcode_analysis_pep8_action} fixindentation_action = create_action(self, _("Fix indentation"), tip=_("Replace tab characters by space characters"), triggered=self.fix_indentation) gotoline_action = create_action(self, _("Go to line..."), icon=ima.icon('gotoline'), triggered=self.go_to_line, context=Qt.WidgetShortcut) self.register_shortcut(gotoline_action, context="Editor", name="Go to line") workdir_action = create_action(self, _("Set console working directory"), icon=ima.icon('DirOpenIcon'), tip=_("Set current console (and file explorer) working " "directory to current script directory"), triggered=self.__set_workdir) self.max_recent_action = create_action(self, _("Maximum number of recent files..."), triggered=self.change_max_recent_files) self.clear_recent_action = create_action(self, _("Clear this list"), tip=_("Clear recent files list"), triggered=self.clear_recent_files) # ---- File menu/toolbar construction ---- self.recent_file_menu = QMenu(_("Open &recent"), self) self.recent_file_menu.aboutToShow.connect(self.update_recent_file_menu) file_menu_actions = [self.new_action, MENU_SEPARATOR, self.open_action, self.open_last_closed_action, self.recent_file_menu, MENU_SEPARATOR, MENU_SEPARATOR, self.save_action, self.save_all_action, save_as_action, save_copy_as_action, self.revert_action, MENU_SEPARATOR, print_preview_action, self.print_action, MENU_SEPARATOR, self.close_action, self.close_all_action, MENU_SEPARATOR] self.main.file_menu_actions += file_menu_actions file_toolbar_actions = ([self.new_action, self.open_action, self.save_action, self.save_all_action] + self.main.file_toolbar_actions) self.main.file_toolbar_actions = file_toolbar_actions # ---- Find menu/toolbar construction ---- self.main.search_menu_actions = [find_action, find_next_action, find_previous_action, replace_action] self.main.search_toolbar_actions = [find_action, find_next_action, replace_action] # ---- Edit menu/toolbar construction ---- self.edit_menu_actions = [self.toggle_comment_action, blockcomment_action, unblockcomment_action, self.indent_action, self.unindent_action, self.text_uppercase_action, self.text_lowercase_action] self.main.edit_menu_actions += [MENU_SEPARATOR] + self.edit_menu_actions edit_toolbar_actions = [self.toggle_comment_action, self.unindent_action, self.indent_action] self.main.edit_toolbar_actions += edit_toolbar_actions # ---- Search menu/toolbar construction ---- self.main.search_menu_actions += [gotoline_action] self.main.search_toolbar_actions += [gotoline_action] # ---- Run menu/toolbar construction ---- run_menu_actions = [run_action, run_cell_action, run_cell_advance_action, re_run_last_cell_action, MENU_SEPARATOR, run_selected_action, re_run_action, configure_action, MENU_SEPARATOR] self.main.run_menu_actions += run_menu_actions run_toolbar_actions = [run_action, run_cell_action, run_cell_advance_action, run_selected_action, re_run_action] self.main.run_toolbar_actions += run_toolbar_actions # ---- Debug menu/toolbar construction ---- # NOTE: 'list_breakpoints' is used by the breakpoints # plugin to add its "List breakpoints" action to this # menu debug_menu_actions = [debug_action, debug_next_action, debug_step_action, debug_return_action, debug_continue_action, debug_exit_action, MENU_SEPARATOR, set_clear_breakpoint_action, set_cond_breakpoint_action, clear_all_breakpoints_action, 'list_breakpoints', MENU_SEPARATOR, self.winpdb_action] self.main.debug_menu_actions += debug_menu_actions debug_toolbar_actions = [debug_action, debug_next_action, debug_step_action, debug_return_action, debug_continue_action, debug_exit_action] self.main.debug_toolbar_actions += debug_toolbar_actions # ---- Source menu/toolbar construction ---- source_menu_actions = [eol_menu, showblanks_action, scrollpastend_action, showindentguides_action, show_classfunc_dropdown_action, showcode_analysis_pep8_action, trailingspaces_action, fixindentation_action, MENU_SEPARATOR, self.todo_list_action, self.warning_list_action, self.previous_warning_action, self.next_warning_action, MENU_SEPARATOR, self.previous_edit_cursor_action, self.previous_cursor_action, self.next_cursor_action] self.main.source_menu_actions += source_menu_actions source_toolbar_actions = [self.todo_list_action, self.warning_list_action, self.previous_warning_action, self.next_warning_action, MENU_SEPARATOR, self.previous_edit_cursor_action, self.previous_cursor_action, self.next_cursor_action] self.main.source_toolbar_actions += source_toolbar_actions # ---- Dock widget and file dependent actions ---- self.dock_toolbar_actions = (file_toolbar_actions + [MENU_SEPARATOR] + source_toolbar_actions + [MENU_SEPARATOR] + run_toolbar_actions + [MENU_SEPARATOR] + debug_toolbar_actions + [MENU_SEPARATOR] + edit_toolbar_actions) self.pythonfile_dependent_actions = [run_action, configure_action, set_clear_breakpoint_action, set_cond_breakpoint_action, debug_action, run_selected_action, run_cell_action, run_cell_advance_action, re_run_last_cell_action, blockcomment_action, unblockcomment_action, self.winpdb_action] self.cythonfile_compatible_actions = [run_action, configure_action] self.file_dependent_actions = self.pythonfile_dependent_actions + \ [self.save_action, save_as_action, save_copy_as_action, print_preview_action, self.print_action, self.save_all_action, gotoline_action, workdir_action, self.close_action, self.close_all_action, self.toggle_comment_action, self.revert_action, self.indent_action, self.unindent_action] self.stack_menu_actions = [gotoline_action, workdir_action] return self.file_dependent_actions
[ "def", "get_plugin_actions", "(", "self", ")", ":", "# ---- File menu and toolbar ----\r", "self", ".", "new_action", "=", "create_action", "(", "self", ",", "_", "(", "\"&New file...\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'filenew'", ")", ",", "tip", "=", "_", "(", "\"New file\"", ")", ",", "triggered", "=", "self", ".", "new", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "new_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"New file\"", ",", "add_sc_to_tip", "=", "True", ")", "self", ".", "open_last_closed_action", "=", "create_action", "(", "self", ",", "_", "(", "\"O&pen last closed\"", ")", ",", "tip", "=", "_", "(", "\"Open last closed\"", ")", ",", "triggered", "=", "self", ".", "open_last_closed", ")", "self", ".", "register_shortcut", "(", "self", ".", "open_last_closed_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Open last closed\"", ")", "self", ".", "open_action", "=", "create_action", "(", "self", ",", "_", "(", "\"&Open...\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'fileopen'", ")", ",", "tip", "=", "_", "(", "\"Open file\"", ")", ",", "triggered", "=", "self", ".", "load", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "open_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Open file\"", ",", "add_sc_to_tip", "=", "True", ")", "self", ".", "revert_action", "=", "create_action", "(", "self", ",", "_", "(", "\"&Revert\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'revert'", ")", ",", "tip", "=", "_", "(", "\"Revert file from disk\"", ")", ",", "triggered", "=", "self", ".", "revert", ")", "self", ".", "save_action", "=", "create_action", "(", "self", ",", "_", "(", "\"&Save\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'filesave'", ")", ",", "tip", "=", "_", "(", "\"Save file\"", ")", ",", "triggered", "=", "self", ".", "save", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "save_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Save file\"", ",", "add_sc_to_tip", "=", "True", ")", "self", ".", "save_all_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Sav&e all\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'save_all'", ")", ",", "tip", "=", "_", "(", "\"Save all files\"", ")", ",", "triggered", "=", "self", ".", "save_all", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "save_all_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Save all\"", ",", "add_sc_to_tip", "=", "True", ")", "save_as_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Save &as...\"", ")", ",", "None", ",", "ima", ".", "icon", "(", "'filesaveas'", ")", ",", "tip", "=", "_", "(", "\"Save current file as...\"", ")", ",", "triggered", "=", "self", ".", "save_as", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "save_as_action", ",", "\"Editor\"", ",", "\"Save As\"", ")", "save_copy_as_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Save copy as...\"", ")", ",", "None", ",", "ima", ".", "icon", "(", "'filesaveas'", ")", ",", "_", "(", "\"Save copy of current file as...\"", ")", ",", "triggered", "=", "self", ".", "save_copy_as", ")", "print_preview_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Print preview...\"", ")", ",", "tip", "=", "_", "(", "\"Print preview...\"", ")", ",", "triggered", "=", "self", ".", "print_preview", ")", "self", ".", "print_action", "=", "create_action", "(", "self", ",", "_", "(", "\"&Print...\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'print'", ")", ",", "tip", "=", "_", "(", "\"Print current file...\"", ")", ",", "triggered", "=", "self", ".", "print_file", ")", "# Shortcut for close_action is defined in widgets/editor.py\r", "self", ".", "close_action", "=", "create_action", "(", "self", ",", "_", "(", "\"&Close\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'fileclose'", ")", ",", "tip", "=", "_", "(", "\"Close current file\"", ")", ",", "triggered", "=", "self", ".", "close_file", ")", "self", ".", "close_all_action", "=", "create_action", "(", "self", ",", "_", "(", "\"C&lose all\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'filecloseall'", ")", ",", "tip", "=", "_", "(", "\"Close all opened files\"", ")", ",", "triggered", "=", "self", ".", "close_all_files", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "close_all_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Close all\"", ")", "# ---- Find menu and toolbar ----\r", "_text", "=", "_", "(", "\"&Find text\"", ")", "find_action", "=", "create_action", "(", "self", ",", "_text", ",", "icon", "=", "ima", ".", "icon", "(", "'find'", ")", ",", "tip", "=", "_text", ",", "triggered", "=", "self", ".", "find", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "find_action", ",", "context", "=", "\"_\"", ",", "name", "=", "\"Find text\"", ",", "add_sc_to_tip", "=", "True", ")", "find_next_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Find &next\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'findnext'", ")", ",", "triggered", "=", "self", ".", "find_next", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "find_next_action", ",", "context", "=", "\"_\"", ",", "name", "=", "\"Find next\"", ")", "find_previous_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Find &previous\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'findprevious'", ")", ",", "triggered", "=", "self", ".", "find_previous", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "find_previous_action", ",", "context", "=", "\"_\"", ",", "name", "=", "\"Find previous\"", ")", "_text", "=", "_", "(", "\"&Replace text\"", ")", "replace_action", "=", "create_action", "(", "self", ",", "_text", ",", "icon", "=", "ima", ".", "icon", "(", "'replace'", ")", ",", "tip", "=", "_text", ",", "triggered", "=", "self", ".", "replace", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "replace_action", ",", "context", "=", "\"_\"", ",", "name", "=", "\"Replace text\"", ")", "# ---- Debug menu and toolbar ----\r", "set_clear_breakpoint_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Set/Clear breakpoint\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'breakpoint_big'", ")", ",", "triggered", "=", "self", ".", "set_or_clear_breakpoint", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "set_clear_breakpoint_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Breakpoint\"", ")", "set_cond_breakpoint_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Set/Edit conditional breakpoint\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'breakpoint_cond_big'", ")", ",", "triggered", "=", "self", ".", "set_or_edit_conditional_breakpoint", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "set_cond_breakpoint_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Conditional breakpoint\"", ")", "clear_all_breakpoints_action", "=", "create_action", "(", "self", ",", "_", "(", "'Clear breakpoints in all files'", ")", ",", "triggered", "=", "self", ".", "clear_all_breakpoints", ")", "self", ".", "winpdb_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Debug with winpdb\"", ")", ",", "triggered", "=", "self", ".", "run_winpdb", ")", "self", ".", "winpdb_action", ".", "setEnabled", "(", "WINPDB_PATH", "is", "not", "None", "and", "PY2", ")", "# --- Debug toolbar ---\r", "debug_action", "=", "create_action", "(", "self", ",", "_", "(", "\"&Debug\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'debug'", ")", ",", "tip", "=", "_", "(", "\"Debug file\"", ")", ",", "triggered", "=", "self", ".", "debug_file", ")", "self", ".", "register_shortcut", "(", "debug_action", ",", "context", "=", "\"_\"", ",", "name", "=", "\"Debug\"", ",", "add_sc_to_tip", "=", "True", ")", "debug_next_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Step\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'arrow-step-over'", ")", ",", "tip", "=", "_", "(", "\"Run current line\"", ")", ",", "triggered", "=", "lambda", ":", "self", ".", "debug_command", "(", "\"next\"", ")", ")", "self", ".", "register_shortcut", "(", "debug_next_action", ",", "\"_\"", ",", "\"Debug Step Over\"", ",", "add_sc_to_tip", "=", "True", ")", "debug_continue_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Continue\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'arrow-continue'", ")", ",", "tip", "=", "_", "(", "\"Continue execution until next breakpoint\"", ")", ",", "triggered", "=", "lambda", ":", "self", ".", "debug_command", "(", "\"continue\"", ")", ")", "self", ".", "register_shortcut", "(", "debug_continue_action", ",", "\"_\"", ",", "\"Debug Continue\"", ",", "add_sc_to_tip", "=", "True", ")", "debug_step_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Step Into\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'arrow-step-in'", ")", ",", "tip", "=", "_", "(", "\"Step into function or method of current line\"", ")", ",", "triggered", "=", "lambda", ":", "self", ".", "debug_command", "(", "\"step\"", ")", ")", "self", ".", "register_shortcut", "(", "debug_step_action", ",", "\"_\"", ",", "\"Debug Step Into\"", ",", "add_sc_to_tip", "=", "True", ")", "debug_return_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Step Return\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'arrow-step-out'", ")", ",", "tip", "=", "_", "(", "\"Run until current function or method returns\"", ")", ",", "triggered", "=", "lambda", ":", "self", ".", "debug_command", "(", "\"return\"", ")", ")", "self", ".", "register_shortcut", "(", "debug_return_action", ",", "\"_\"", ",", "\"Debug Step Return\"", ",", "add_sc_to_tip", "=", "True", ")", "debug_exit_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Stop\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'stop_debug'", ")", ",", "tip", "=", "_", "(", "\"Stop debugging\"", ")", ",", "triggered", "=", "lambda", ":", "self", ".", "debug_command", "(", "\"exit\"", ")", ")", "self", ".", "register_shortcut", "(", "debug_exit_action", ",", "\"_\"", ",", "\"Debug Exit\"", ",", "add_sc_to_tip", "=", "True", ")", "# --- Run toolbar ---\r", "run_action", "=", "create_action", "(", "self", ",", "_", "(", "\"&Run\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'run'", ")", ",", "tip", "=", "_", "(", "\"Run file\"", ")", ",", "triggered", "=", "self", ".", "run_file", ")", "self", ".", "register_shortcut", "(", "run_action", ",", "context", "=", "\"_\"", ",", "name", "=", "\"Run\"", ",", "add_sc_to_tip", "=", "True", ")", "configure_action", "=", "create_action", "(", "self", ",", "_", "(", "\"&Configuration per file...\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'run_settings'", ")", ",", "tip", "=", "_", "(", "\"Run settings\"", ")", ",", "menurole", "=", "QAction", ".", "NoRole", ",", "triggered", "=", "self", ".", "edit_run_configurations", ")", "self", ".", "register_shortcut", "(", "configure_action", ",", "context", "=", "\"_\"", ",", "name", "=", "\"Configure\"", ",", "add_sc_to_tip", "=", "True", ")", "re_run_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Re-run &last script\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'run_again'", ")", ",", "tip", "=", "_", "(", "\"Run again last file\"", ")", ",", "triggered", "=", "self", ".", "re_run_file", ")", "self", ".", "register_shortcut", "(", "re_run_action", ",", "context", "=", "\"_\"", ",", "name", "=", "\"Re-run last script\"", ",", "add_sc_to_tip", "=", "True", ")", "run_selected_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Run &selection or \"", "\"current line\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'run_selection'", ")", ",", "tip", "=", "_", "(", "\"Run selection or \"", "\"current line\"", ")", ",", "triggered", "=", "self", ".", "run_selection", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "run_selected_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Run selection\"", ",", "add_sc_to_tip", "=", "True", ")", "run_cell_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Run cell\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'run_cell'", ")", ",", "shortcut", "=", "QKeySequence", "(", "RUN_CELL_SHORTCUT", ")", ",", "tip", "=", "_", "(", "\"Run current cell (Ctrl+Enter)\\n\"", "\"[Use #%% to create cells]\"", ")", ",", "triggered", "=", "self", ".", "run_cell", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "run_cell_advance_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Run cell and advance\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'run_cell_advance'", ")", ",", "shortcut", "=", "QKeySequence", "(", "RUN_CELL_AND_ADVANCE_SHORTCUT", ")", ",", "tip", "=", "_", "(", "\"Run current cell and go to the next one \"", "\"(Shift+Enter)\"", ")", ",", "triggered", "=", "self", ".", "run_cell_and_advance", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "re_run_last_cell_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Re-run last cell\"", ")", ",", "tip", "=", "_", "(", "\"Re run last cell \"", ")", ",", "triggered", "=", "self", ".", "re_run_last_cell", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "re_run_last_cell_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "'re-run last cell'", ",", "add_sc_to_tip", "=", "True", ")", "# --- Source code Toolbar ---\r", "self", ".", "todo_list_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Show todo list\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'todo_list'", ")", ",", "tip", "=", "_", "(", "\"Show comments list (TODO/FIXME/XXX/HINT/TIP/@todo/\"", "\"HACK/BUG/OPTIMIZE/!!!/???)\"", ")", ",", "triggered", "=", "self", ".", "go_to_next_todo", ")", "self", ".", "todo_menu", "=", "QMenu", "(", "self", ")", "self", ".", "todo_menu", ".", "setStyleSheet", "(", "\"QMenu {menu-scrollable: 1;}\"", ")", "self", ".", "todo_list_action", ".", "setMenu", "(", "self", ".", "todo_menu", ")", "self", ".", "todo_menu", ".", "aboutToShow", ".", "connect", "(", "self", ".", "update_todo_menu", ")", "self", ".", "warning_list_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Show warning/error list\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'wng_list'", ")", ",", "tip", "=", "_", "(", "\"Show code analysis warnings/errors\"", ")", ",", "triggered", "=", "self", ".", "go_to_next_warning", ")", "self", ".", "warning_menu", "=", "QMenu", "(", "self", ")", "self", ".", "warning_menu", ".", "setStyleSheet", "(", "\"QMenu {menu-scrollable: 1;}\"", ")", "self", ".", "warning_list_action", ".", "setMenu", "(", "self", ".", "warning_menu", ")", "self", ".", "warning_menu", ".", "aboutToShow", ".", "connect", "(", "self", ".", "update_warning_menu", ")", "self", ".", "previous_warning_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Previous warning/error\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'prev_wng'", ")", ",", "tip", "=", "_", "(", "\"Go to previous code analysis warning/error\"", ")", ",", "triggered", "=", "self", ".", "go_to_previous_warning", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "previous_warning_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Previous warning\"", ",", "add_sc_to_tip", "=", "True", ")", "self", ".", "next_warning_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Next warning/error\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'next_wng'", ")", ",", "tip", "=", "_", "(", "\"Go to next code analysis warning/error\"", ")", ",", "triggered", "=", "self", ".", "go_to_next_warning", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "next_warning_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Next warning\"", ",", "add_sc_to_tip", "=", "True", ")", "self", ".", "previous_edit_cursor_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Last edit location\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'last_edit_location'", ")", ",", "tip", "=", "_", "(", "\"Go to last edit location\"", ")", ",", "triggered", "=", "self", ".", "go_to_last_edit_location", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "previous_edit_cursor_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Last edit location\"", ",", "add_sc_to_tip", "=", "True", ")", "self", ".", "previous_cursor_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Previous cursor position\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'prev_cursor'", ")", ",", "tip", "=", "_", "(", "\"Go to previous cursor position\"", ")", ",", "triggered", "=", "self", ".", "go_to_previous_cursor_position", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "previous_cursor_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Previous cursor position\"", ",", "add_sc_to_tip", "=", "True", ")", "self", ".", "next_cursor_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Next cursor position\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'next_cursor'", ")", ",", "tip", "=", "_", "(", "\"Go to next cursor position\"", ")", ",", "triggered", "=", "self", ".", "go_to_next_cursor_position", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "next_cursor_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Next cursor position\"", ",", "add_sc_to_tip", "=", "True", ")", "# --- Edit Toolbar ---\r", "self", ".", "toggle_comment_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Comment\"", ")", "+", "\"/\"", "+", "_", "(", "\"Uncomment\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'comment'", ")", ",", "tip", "=", "_", "(", "\"Comment current line or selection\"", ")", ",", "triggered", "=", "self", ".", "toggle_comment", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "toggle_comment_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Toggle comment\"", ")", "blockcomment_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Add &block comment\"", ")", ",", "tip", "=", "_", "(", "\"Add block comment around \"", "\"current line or selection\"", ")", ",", "triggered", "=", "self", ".", "blockcomment", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "blockcomment_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Blockcomment\"", ")", "unblockcomment_action", "=", "create_action", "(", "self", ",", "_", "(", "\"R&emove block comment\"", ")", ",", "tip", "=", "_", "(", "\"Remove comment block around \"", "\"current line or selection\"", ")", ",", "triggered", "=", "self", ".", "unblockcomment", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "unblockcomment_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Unblockcomment\"", ")", "# ----------------------------------------------------------------------\r", "# The following action shortcuts are hard-coded in CodeEditor\r", "# keyPressEvent handler (the shortcut is here only to inform user):\r", "# (context=Qt.WidgetShortcut -> disable shortcut for other widgets)\r", "self", ".", "indent_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Indent\"", ")", ",", "\"Tab\"", ",", "icon", "=", "ima", ".", "icon", "(", "'indent'", ")", ",", "tip", "=", "_", "(", "\"Indent current line or selection\"", ")", ",", "triggered", "=", "self", ".", "indent", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "unindent_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Unindent\"", ")", ",", "\"Shift+Tab\"", ",", "icon", "=", "ima", ".", "icon", "(", "'unindent'", ")", ",", "tip", "=", "_", "(", "\"Unindent current line or selection\"", ")", ",", "triggered", "=", "self", ".", "unindent", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "text_uppercase_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Toggle Uppercase\"", ")", ",", "tip", "=", "_", "(", "\"Change to uppercase current line or selection\"", ")", ",", "triggered", "=", "self", ".", "text_uppercase", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "text_uppercase_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"transform to uppercase\"", ")", "self", ".", "text_lowercase_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Toggle Lowercase\"", ")", ",", "tip", "=", "_", "(", "\"Change to lowercase current line or selection\"", ")", ",", "triggered", "=", "self", ".", "text_lowercase", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "self", ".", "text_lowercase_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"transform to lowercase\"", ")", "# ----------------------------------------------------------------------\r", "self", ".", "win_eol_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Carriage return and line feed (Windows)\"", ")", ",", "toggled", "=", "lambda", "checked", ":", "self", ".", "toggle_eol_chars", "(", "'nt'", ",", "checked", ")", ")", "self", ".", "linux_eol_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Line feed (UNIX)\"", ")", ",", "toggled", "=", "lambda", "checked", ":", "self", ".", "toggle_eol_chars", "(", "'posix'", ",", "checked", ")", ")", "self", ".", "mac_eol_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Carriage return (Mac)\"", ")", ",", "toggled", "=", "lambda", "checked", ":", "self", ".", "toggle_eol_chars", "(", "'mac'", ",", "checked", ")", ")", "eol_action_group", "=", "QActionGroup", "(", "self", ")", "eol_actions", "=", "(", "self", ".", "win_eol_action", ",", "self", ".", "linux_eol_action", ",", "self", ".", "mac_eol_action", ")", "add_actions", "(", "eol_action_group", ",", "eol_actions", ")", "eol_menu", "=", "QMenu", "(", "_", "(", "\"Convert end-of-line characters\"", ")", ",", "self", ")", "add_actions", "(", "eol_menu", ",", "eol_actions", ")", "trailingspaces_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Remove trailing spaces\"", ")", ",", "triggered", "=", "self", ".", "remove_trailing_spaces", ")", "# Checkable actions\r", "showblanks_action", "=", "self", ".", "_create_checkable_action", "(", "_", "(", "\"Show blank spaces\"", ")", ",", "'blank_spaces'", ",", "'set_blanks_enabled'", ")", "scrollpastend_action", "=", "self", ".", "_create_checkable_action", "(", "_", "(", "\"Scroll past the end\"", ")", ",", "'scroll_past_end'", ",", "'set_scrollpastend_enabled'", ")", "showindentguides_action", "=", "self", ".", "_create_checkable_action", "(", "_", "(", "\"Show indent guides.\"", ")", ",", "'indent_guides'", ",", "'set_indent_guides'", ")", "show_classfunc_dropdown_action", "=", "self", ".", "_create_checkable_action", "(", "_", "(", "\"Show selector for classes and functions.\"", ")", ",", "'show_class_func_dropdown'", ",", "'set_classfunc_dropdown_visible'", ")", "showcode_analysis_pep8_action", "=", "self", ".", "_create_checkable_action", "(", "_", "(", "\"Show code style warnings (pep8)\"", ")", ",", "'code_analysis/pep8'", ",", "'set_pep8_enabled'", ")", "self", ".", "checkable_actions", "=", "{", "'blank_spaces'", ":", "showblanks_action", ",", "'scroll_past_end'", ":", "scrollpastend_action", ",", "'indent_guides'", ":", "showindentguides_action", ",", "'show_class_func_dropdown'", ":", "show_classfunc_dropdown_action", ",", "'code_analysis/pep8'", ":", "showcode_analysis_pep8_action", "}", "fixindentation_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Fix indentation\"", ")", ",", "tip", "=", "_", "(", "\"Replace tab characters by space characters\"", ")", ",", "triggered", "=", "self", ".", "fix_indentation", ")", "gotoline_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Go to line...\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'gotoline'", ")", ",", "triggered", "=", "self", ".", "go_to_line", ",", "context", "=", "Qt", ".", "WidgetShortcut", ")", "self", ".", "register_shortcut", "(", "gotoline_action", ",", "context", "=", "\"Editor\"", ",", "name", "=", "\"Go to line\"", ")", "workdir_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Set console working directory\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'DirOpenIcon'", ")", ",", "tip", "=", "_", "(", "\"Set current console (and file explorer) working \"", "\"directory to current script directory\"", ")", ",", "triggered", "=", "self", ".", "__set_workdir", ")", "self", ".", "max_recent_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Maximum number of recent files...\"", ")", ",", "triggered", "=", "self", ".", "change_max_recent_files", ")", "self", ".", "clear_recent_action", "=", "create_action", "(", "self", ",", "_", "(", "\"Clear this list\"", ")", ",", "tip", "=", "_", "(", "\"Clear recent files list\"", ")", ",", "triggered", "=", "self", ".", "clear_recent_files", ")", "# ---- File menu/toolbar construction ----\r", "self", ".", "recent_file_menu", "=", "QMenu", "(", "_", "(", "\"Open &recent\"", ")", ",", "self", ")", "self", ".", "recent_file_menu", ".", "aboutToShow", ".", "connect", "(", "self", ".", "update_recent_file_menu", ")", "file_menu_actions", "=", "[", "self", ".", "new_action", ",", "MENU_SEPARATOR", ",", "self", ".", "open_action", ",", "self", ".", "open_last_closed_action", ",", "self", ".", "recent_file_menu", ",", "MENU_SEPARATOR", ",", "MENU_SEPARATOR", ",", "self", ".", "save_action", ",", "self", ".", "save_all_action", ",", "save_as_action", ",", "save_copy_as_action", ",", "self", ".", "revert_action", ",", "MENU_SEPARATOR", ",", "print_preview_action", ",", "self", ".", "print_action", ",", "MENU_SEPARATOR", ",", "self", ".", "close_action", ",", "self", ".", "close_all_action", ",", "MENU_SEPARATOR", "]", "self", ".", "main", ".", "file_menu_actions", "+=", "file_menu_actions", "file_toolbar_actions", "=", "(", "[", "self", ".", "new_action", ",", "self", ".", "open_action", ",", "self", ".", "save_action", ",", "self", ".", "save_all_action", "]", "+", "self", ".", "main", ".", "file_toolbar_actions", ")", "self", ".", "main", ".", "file_toolbar_actions", "=", "file_toolbar_actions", "# ---- Find menu/toolbar construction ----\r", "self", ".", "main", ".", "search_menu_actions", "=", "[", "find_action", ",", "find_next_action", ",", "find_previous_action", ",", "replace_action", "]", "self", ".", "main", ".", "search_toolbar_actions", "=", "[", "find_action", ",", "find_next_action", ",", "replace_action", "]", "# ---- Edit menu/toolbar construction ----\r", "self", ".", "edit_menu_actions", "=", "[", "self", ".", "toggle_comment_action", ",", "blockcomment_action", ",", "unblockcomment_action", ",", "self", ".", "indent_action", ",", "self", ".", "unindent_action", ",", "self", ".", "text_uppercase_action", ",", "self", ".", "text_lowercase_action", "]", "self", ".", "main", ".", "edit_menu_actions", "+=", "[", "MENU_SEPARATOR", "]", "+", "self", ".", "edit_menu_actions", "edit_toolbar_actions", "=", "[", "self", ".", "toggle_comment_action", ",", "self", ".", "unindent_action", ",", "self", ".", "indent_action", "]", "self", ".", "main", ".", "edit_toolbar_actions", "+=", "edit_toolbar_actions", "# ---- Search menu/toolbar construction ----\r", "self", ".", "main", ".", "search_menu_actions", "+=", "[", "gotoline_action", "]", "self", ".", "main", ".", "search_toolbar_actions", "+=", "[", "gotoline_action", "]", "# ---- Run menu/toolbar construction ----\r", "run_menu_actions", "=", "[", "run_action", ",", "run_cell_action", ",", "run_cell_advance_action", ",", "re_run_last_cell_action", ",", "MENU_SEPARATOR", ",", "run_selected_action", ",", "re_run_action", ",", "configure_action", ",", "MENU_SEPARATOR", "]", "self", ".", "main", ".", "run_menu_actions", "+=", "run_menu_actions", "run_toolbar_actions", "=", "[", "run_action", ",", "run_cell_action", ",", "run_cell_advance_action", ",", "run_selected_action", ",", "re_run_action", "]", "self", ".", "main", ".", "run_toolbar_actions", "+=", "run_toolbar_actions", "# ---- Debug menu/toolbar construction ----\r", "# NOTE: 'list_breakpoints' is used by the breakpoints\r", "# plugin to add its \"List breakpoints\" action to this\r", "# menu\r", "debug_menu_actions", "=", "[", "debug_action", ",", "debug_next_action", ",", "debug_step_action", ",", "debug_return_action", ",", "debug_continue_action", ",", "debug_exit_action", ",", "MENU_SEPARATOR", ",", "set_clear_breakpoint_action", ",", "set_cond_breakpoint_action", ",", "clear_all_breakpoints_action", ",", "'list_breakpoints'", ",", "MENU_SEPARATOR", ",", "self", ".", "winpdb_action", "]", "self", ".", "main", ".", "debug_menu_actions", "+=", "debug_menu_actions", "debug_toolbar_actions", "=", "[", "debug_action", ",", "debug_next_action", ",", "debug_step_action", ",", "debug_return_action", ",", "debug_continue_action", ",", "debug_exit_action", "]", "self", ".", "main", ".", "debug_toolbar_actions", "+=", "debug_toolbar_actions", "# ---- Source menu/toolbar construction ----\r", "source_menu_actions", "=", "[", "eol_menu", ",", "showblanks_action", ",", "scrollpastend_action", ",", "showindentguides_action", ",", "show_classfunc_dropdown_action", ",", "showcode_analysis_pep8_action", ",", "trailingspaces_action", ",", "fixindentation_action", ",", "MENU_SEPARATOR", ",", "self", ".", "todo_list_action", ",", "self", ".", "warning_list_action", ",", "self", ".", "previous_warning_action", ",", "self", ".", "next_warning_action", ",", "MENU_SEPARATOR", ",", "self", ".", "previous_edit_cursor_action", ",", "self", ".", "previous_cursor_action", ",", "self", ".", "next_cursor_action", "]", "self", ".", "main", ".", "source_menu_actions", "+=", "source_menu_actions", "source_toolbar_actions", "=", "[", "self", ".", "todo_list_action", ",", "self", ".", "warning_list_action", ",", "self", ".", "previous_warning_action", ",", "self", ".", "next_warning_action", ",", "MENU_SEPARATOR", ",", "self", ".", "previous_edit_cursor_action", ",", "self", ".", "previous_cursor_action", ",", "self", ".", "next_cursor_action", "]", "self", ".", "main", ".", "source_toolbar_actions", "+=", "source_toolbar_actions", "# ---- Dock widget and file dependent actions ----\r", "self", ".", "dock_toolbar_actions", "=", "(", "file_toolbar_actions", "+", "[", "MENU_SEPARATOR", "]", "+", "source_toolbar_actions", "+", "[", "MENU_SEPARATOR", "]", "+", "run_toolbar_actions", "+", "[", "MENU_SEPARATOR", "]", "+", "debug_toolbar_actions", "+", "[", "MENU_SEPARATOR", "]", "+", "edit_toolbar_actions", ")", "self", ".", "pythonfile_dependent_actions", "=", "[", "run_action", ",", "configure_action", ",", "set_clear_breakpoint_action", ",", "set_cond_breakpoint_action", ",", "debug_action", ",", "run_selected_action", ",", "run_cell_action", ",", "run_cell_advance_action", ",", "re_run_last_cell_action", ",", "blockcomment_action", ",", "unblockcomment_action", ",", "self", ".", "winpdb_action", "]", "self", ".", "cythonfile_compatible_actions", "=", "[", "run_action", ",", "configure_action", "]", "self", ".", "file_dependent_actions", "=", "self", ".", "pythonfile_dependent_actions", "+", "[", "self", ".", "save_action", ",", "save_as_action", ",", "save_copy_as_action", ",", "print_preview_action", ",", "self", ".", "print_action", ",", "self", ".", "save_all_action", ",", "gotoline_action", ",", "workdir_action", ",", "self", ".", "close_action", ",", "self", ".", "close_all_action", ",", "self", ".", "toggle_comment_action", ",", "self", ".", "revert_action", ",", "self", ".", "indent_action", ",", "self", ".", "unindent_action", "]", "self", ".", "stack_menu_actions", "=", "[", "gotoline_action", ",", "workdir_action", "]", "return", "self", ".", "file_dependent_actions" ]
Return a list of actions related to plugin
[ "Return", "a", "list", "of", "actions", "related", "to", "plugin" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L384-L944
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.register_plugin
def register_plugin(self): """Register plugin in Spyder's main window""" self.main.restore_scrollbar_position.connect( self.restore_scrollbar_position) self.main.console.edit_goto.connect(self.load) self.exec_in_extconsole.connect(self.main.execute_in_external_console) self.redirect_stdio.connect(self.main.redirect_internalshell_stdio) self.open_dir.connect(self.main.workingdirectory.chdir) self.set_help(self.main.help) if self.main.outlineexplorer is not None: self.set_outlineexplorer(self.main.outlineexplorer) editorstack = self.get_current_editorstack() if not editorstack.data: self.__load_temp_file() self.main.add_dockwidget(self) self.main.add_to_fileswitcher(self, editorstack.tabs, editorstack.data, ima.icon('TextFileIcon'))
python
def register_plugin(self): """Register plugin in Spyder's main window""" self.main.restore_scrollbar_position.connect( self.restore_scrollbar_position) self.main.console.edit_goto.connect(self.load) self.exec_in_extconsole.connect(self.main.execute_in_external_console) self.redirect_stdio.connect(self.main.redirect_internalshell_stdio) self.open_dir.connect(self.main.workingdirectory.chdir) self.set_help(self.main.help) if self.main.outlineexplorer is not None: self.set_outlineexplorer(self.main.outlineexplorer) editorstack = self.get_current_editorstack() if not editorstack.data: self.__load_temp_file() self.main.add_dockwidget(self) self.main.add_to_fileswitcher(self, editorstack.tabs, editorstack.data, ima.icon('TextFileIcon'))
[ "def", "register_plugin", "(", "self", ")", ":", "self", ".", "main", ".", "restore_scrollbar_position", ".", "connect", "(", "self", ".", "restore_scrollbar_position", ")", "self", ".", "main", ".", "console", ".", "edit_goto", ".", "connect", "(", "self", ".", "load", ")", "self", ".", "exec_in_extconsole", ".", "connect", "(", "self", ".", "main", ".", "execute_in_external_console", ")", "self", ".", "redirect_stdio", ".", "connect", "(", "self", ".", "main", ".", "redirect_internalshell_stdio", ")", "self", ".", "open_dir", ".", "connect", "(", "self", ".", "main", ".", "workingdirectory", ".", "chdir", ")", "self", ".", "set_help", "(", "self", ".", "main", ".", "help", ")", "if", "self", ".", "main", ".", "outlineexplorer", "is", "not", "None", ":", "self", ".", "set_outlineexplorer", "(", "self", ".", "main", ".", "outlineexplorer", ")", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "not", "editorstack", ".", "data", ":", "self", ".", "__load_temp_file", "(", ")", "self", ".", "main", ".", "add_dockwidget", "(", "self", ")", "self", ".", "main", ".", "add_to_fileswitcher", "(", "self", ",", "editorstack", ".", "tabs", ",", "editorstack", ".", "data", ",", "ima", ".", "icon", "(", "'TextFileIcon'", ")", ")" ]
Register plugin in Spyder's main window
[ "Register", "plugin", "in", "Spyder", "s", "main", "window" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L946-L962
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.update_font
def update_font(self): """Update font from Preferences""" font = self.get_plugin_font() color_scheme = self.get_color_scheme() for editorstack in self.editorstacks: editorstack.set_default_font(font, color_scheme) completion_size = CONF.get('main', 'completion/size') for finfo in editorstack.data: comp_widget = finfo.editor.completion_widget comp_widget.setup_appearance(completion_size, font)
python
def update_font(self): """Update font from Preferences""" font = self.get_plugin_font() color_scheme = self.get_color_scheme() for editorstack in self.editorstacks: editorstack.set_default_font(font, color_scheme) completion_size = CONF.get('main', 'completion/size') for finfo in editorstack.data: comp_widget = finfo.editor.completion_widget comp_widget.setup_appearance(completion_size, font)
[ "def", "update_font", "(", "self", ")", ":", "font", "=", "self", ".", "get_plugin_font", "(", ")", "color_scheme", "=", "self", ".", "get_color_scheme", "(", ")", "for", "editorstack", "in", "self", ".", "editorstacks", ":", "editorstack", ".", "set_default_font", "(", "font", ",", "color_scheme", ")", "completion_size", "=", "CONF", ".", "get", "(", "'main'", ",", "'completion/size'", ")", "for", "finfo", "in", "editorstack", ".", "data", ":", "comp_widget", "=", "finfo", ".", "editor", ".", "completion_widget", "comp_widget", ".", "setup_appearance", "(", "completion_size", ",", "font", ")" ]
Update font from Preferences
[ "Update", "font", "from", "Preferences" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L964-L973
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor._create_checkable_action
def _create_checkable_action(self, text, conf_name, editorstack_method): """Helper function to create a checkable action. Args: text (str): Text to be displayed in the action. conf_name (str): configuration setting associated with the action editorstack_method (str): name of EditorStack class that will be used to update the changes in each editorstack. """ def toogle(checked): self.switch_to_plugin() self._toggle_checkable_action(checked, editorstack_method, conf_name) action = create_action(self, text, toggled=toogle) action.setChecked(CONF.get('editor', conf_name)) return action
python
def _create_checkable_action(self, text, conf_name, editorstack_method): """Helper function to create a checkable action. Args: text (str): Text to be displayed in the action. conf_name (str): configuration setting associated with the action editorstack_method (str): name of EditorStack class that will be used to update the changes in each editorstack. """ def toogle(checked): self.switch_to_plugin() self._toggle_checkable_action(checked, editorstack_method, conf_name) action = create_action(self, text, toggled=toogle) action.setChecked(CONF.get('editor', conf_name)) return action
[ "def", "_create_checkable_action", "(", "self", ",", "text", ",", "conf_name", ",", "editorstack_method", ")", ":", "def", "toogle", "(", "checked", ")", ":", "self", ".", "switch_to_plugin", "(", ")", "self", ".", "_toggle_checkable_action", "(", "checked", ",", "editorstack_method", ",", "conf_name", ")", "action", "=", "create_action", "(", "self", ",", "text", ",", "toggled", "=", "toogle", ")", "action", ".", "setChecked", "(", "CONF", ".", "get", "(", "'editor'", ",", "conf_name", ")", ")", "return", "action" ]
Helper function to create a checkable action. Args: text (str): Text to be displayed in the action. conf_name (str): configuration setting associated with the action editorstack_method (str): name of EditorStack class that will be used to update the changes in each editorstack.
[ "Helper", "function", "to", "create", "a", "checkable", "action", ".", "Args", ":", "text", "(", "str", ")", ":", "Text", "to", "be", "displayed", "in", "the", "action", ".", "conf_name", "(", "str", ")", ":", "configuration", "setting", "associated", "with", "the", "action", "editorstack_method", "(", "str", ")", ":", "name", "of", "EditorStack", "class", "that", "will", "be", "used", "to", "update", "the", "changes", "in", "each", "editorstack", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L975-L990
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor._toggle_checkable_action
def _toggle_checkable_action(self, checked, editorstack_method, conf_name): """Handle the toogle of a checkable action. Update editorstacks and the configuration. Args: checked (bool): State of the action. editorstack_method (str): name of EditorStack class that will be used to update the changes in each editorstack. conf_name (str): configuration setting associated with the action. """ if self.editorstacks: for editorstack in self.editorstacks: try: editorstack.__getattribute__(editorstack_method)(checked) except AttributeError as e: logger.error(e, exc_info=True) # Run code analysis when `set_pep8_enabled` is toggled if editorstack_method == 'set_pep8_enabled': # TODO: Connect this to the LSP #for finfo in editorstack.data: # finfo.run_code_analysis( # self.get_option('code_analysis/pyflakes'), # checked) pass CONF.set('editor', conf_name, checked)
python
def _toggle_checkable_action(self, checked, editorstack_method, conf_name): """Handle the toogle of a checkable action. Update editorstacks and the configuration. Args: checked (bool): State of the action. editorstack_method (str): name of EditorStack class that will be used to update the changes in each editorstack. conf_name (str): configuration setting associated with the action. """ if self.editorstacks: for editorstack in self.editorstacks: try: editorstack.__getattribute__(editorstack_method)(checked) except AttributeError as e: logger.error(e, exc_info=True) # Run code analysis when `set_pep8_enabled` is toggled if editorstack_method == 'set_pep8_enabled': # TODO: Connect this to the LSP #for finfo in editorstack.data: # finfo.run_code_analysis( # self.get_option('code_analysis/pyflakes'), # checked) pass CONF.set('editor', conf_name, checked)
[ "def", "_toggle_checkable_action", "(", "self", ",", "checked", ",", "editorstack_method", ",", "conf_name", ")", ":", "if", "self", ".", "editorstacks", ":", "for", "editorstack", "in", "self", ".", "editorstacks", ":", "try", ":", "editorstack", ".", "__getattribute__", "(", "editorstack_method", ")", "(", "checked", ")", "except", "AttributeError", "as", "e", ":", "logger", ".", "error", "(", "e", ",", "exc_info", "=", "True", ")", "# Run code analysis when `set_pep8_enabled` is toggled\r", "if", "editorstack_method", "==", "'set_pep8_enabled'", ":", "# TODO: Connect this to the LSP\r", "#for finfo in editorstack.data:\r", "# finfo.run_code_analysis(\r", "# self.get_option('code_analysis/pyflakes'),\r", "# checked)\r", "pass", "CONF", ".", "set", "(", "'editor'", ",", "conf_name", ",", "checked", ")" ]
Handle the toogle of a checkable action. Update editorstacks and the configuration. Args: checked (bool): State of the action. editorstack_method (str): name of EditorStack class that will be used to update the changes in each editorstack. conf_name (str): configuration setting associated with the action.
[ "Handle", "the", "toogle", "of", "a", "checkable", "action", ".", "Update", "editorstacks", "and", "the", "configuration", ".", "Args", ":", "checked", "(", "bool", ")", ":", "State", "of", "the", "action", ".", "editorstack_method", "(", "str", ")", ":", "name", "of", "EditorStack", "class", "that", "will", "be", "used", "to", "update", "the", "changes", "in", "each", "editorstack", ".", "conf_name", "(", "str", ")", ":", "configuration", "setting", "associated", "with", "the", "action", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L993-L1018
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.received_sig_option_changed
def received_sig_option_changed(self, option, value): """ Called when sig_option_changed is received. If option being changed is autosave_mapping, then synchronize new mapping with all editor stacks except the sender. """ if option == 'autosave_mapping': for editorstack in self.editorstacks: if editorstack != self.sender(): editorstack.autosave_mapping = value self.sig_option_changed.emit(option, value)
python
def received_sig_option_changed(self, option, value): """ Called when sig_option_changed is received. If option being changed is autosave_mapping, then synchronize new mapping with all editor stacks except the sender. """ if option == 'autosave_mapping': for editorstack in self.editorstacks: if editorstack != self.sender(): editorstack.autosave_mapping = value self.sig_option_changed.emit(option, value)
[ "def", "received_sig_option_changed", "(", "self", ",", "option", ",", "value", ")", ":", "if", "option", "==", "'autosave_mapping'", ":", "for", "editorstack", "in", "self", ".", "editorstacks", ":", "if", "editorstack", "!=", "self", ".", "sender", "(", ")", ":", "editorstack", ".", "autosave_mapping", "=", "value", "self", ".", "sig_option_changed", ".", "emit", "(", "option", ",", "value", ")" ]
Called when sig_option_changed is received. If option being changed is autosave_mapping, then synchronize new mapping with all editor stacks except the sender.
[ "Called", "when", "sig_option_changed", "is", "received", ".", "If", "option", "being", "changed", "is", "autosave_mapping", "then", "synchronize", "new", "mapping", "with", "all", "editor", "stacks", "except", "the", "sender", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1020-L1031
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.unregister_editorstack
def unregister_editorstack(self, editorstack): """Removing editorstack only if it's not the last remaining""" self.remove_last_focus_editorstack(editorstack) if len(self.editorstacks) > 1: index = self.editorstacks.index(editorstack) self.editorstacks.pop(index) return True else: # editorstack was not removed! return False
python
def unregister_editorstack(self, editorstack): """Removing editorstack only if it's not the last remaining""" self.remove_last_focus_editorstack(editorstack) if len(self.editorstacks) > 1: index = self.editorstacks.index(editorstack) self.editorstacks.pop(index) return True else: # editorstack was not removed! return False
[ "def", "unregister_editorstack", "(", "self", ",", "editorstack", ")", ":", "self", ".", "remove_last_focus_editorstack", "(", "editorstack", ")", "if", "len", "(", "self", ".", "editorstacks", ")", ">", "1", ":", "index", "=", "self", ".", "editorstacks", ".", "index", "(", "editorstack", ")", "self", ".", "editorstacks", ".", "pop", "(", "index", ")", "return", "True", "else", ":", "# editorstack was not removed!\r", "return", "False" ]
Removing editorstack only if it's not the last remaining
[ "Removing", "editorstack", "only", "if", "it", "s", "not", "the", "last", "remaining" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1202-L1211
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.setup_other_windows
def setup_other_windows(self): """Setup toolbars and menus for 'New window' instances""" self.toolbar_list = ((_("File toolbar"), "file_toolbar", self.main.file_toolbar_actions), (_("Search toolbar"), "search_toolbar", self.main.search_menu_actions), (_("Source toolbar"), "source_toolbar", self.main.source_toolbar_actions), (_("Run toolbar"), "run_toolbar", self.main.run_toolbar_actions), (_("Debug toolbar"), "debug_toolbar", self.main.debug_toolbar_actions), (_("Edit toolbar"), "edit_toolbar", self.main.edit_toolbar_actions)) self.menu_list = ((_("&File"), self.main.file_menu_actions), (_("&Edit"), self.main.edit_menu_actions), (_("&Search"), self.main.search_menu_actions), (_("Sour&ce"), self.main.source_menu_actions), (_("&Run"), self.main.run_menu_actions), (_("&Tools"), self.main.tools_menu_actions), (_("&View"), []), (_("&Help"), self.main.help_menu_actions)) # Create pending new windows: for layout_settings in self.editorwindows_to_be_created: win = self.create_new_window() win.set_layout_settings(layout_settings)
python
def setup_other_windows(self): """Setup toolbars and menus for 'New window' instances""" self.toolbar_list = ((_("File toolbar"), "file_toolbar", self.main.file_toolbar_actions), (_("Search toolbar"), "search_toolbar", self.main.search_menu_actions), (_("Source toolbar"), "source_toolbar", self.main.source_toolbar_actions), (_("Run toolbar"), "run_toolbar", self.main.run_toolbar_actions), (_("Debug toolbar"), "debug_toolbar", self.main.debug_toolbar_actions), (_("Edit toolbar"), "edit_toolbar", self.main.edit_toolbar_actions)) self.menu_list = ((_("&File"), self.main.file_menu_actions), (_("&Edit"), self.main.edit_menu_actions), (_("&Search"), self.main.search_menu_actions), (_("Sour&ce"), self.main.source_menu_actions), (_("&Run"), self.main.run_menu_actions), (_("&Tools"), self.main.tools_menu_actions), (_("&View"), []), (_("&Help"), self.main.help_menu_actions)) # Create pending new windows: for layout_settings in self.editorwindows_to_be_created: win = self.create_new_window() win.set_layout_settings(layout_settings)
[ "def", "setup_other_windows", "(", "self", ")", ":", "self", ".", "toolbar_list", "=", "(", "(", "_", "(", "\"File toolbar\"", ")", ",", "\"file_toolbar\"", ",", "self", ".", "main", ".", "file_toolbar_actions", ")", ",", "(", "_", "(", "\"Search toolbar\"", ")", ",", "\"search_toolbar\"", ",", "self", ".", "main", ".", "search_menu_actions", ")", ",", "(", "_", "(", "\"Source toolbar\"", ")", ",", "\"source_toolbar\"", ",", "self", ".", "main", ".", "source_toolbar_actions", ")", ",", "(", "_", "(", "\"Run toolbar\"", ")", ",", "\"run_toolbar\"", ",", "self", ".", "main", ".", "run_toolbar_actions", ")", ",", "(", "_", "(", "\"Debug toolbar\"", ")", ",", "\"debug_toolbar\"", ",", "self", ".", "main", ".", "debug_toolbar_actions", ")", ",", "(", "_", "(", "\"Edit toolbar\"", ")", ",", "\"edit_toolbar\"", ",", "self", ".", "main", ".", "edit_toolbar_actions", ")", ")", "self", ".", "menu_list", "=", "(", "(", "_", "(", "\"&File\"", ")", ",", "self", ".", "main", ".", "file_menu_actions", ")", ",", "(", "_", "(", "\"&Edit\"", ")", ",", "self", ".", "main", ".", "edit_menu_actions", ")", ",", "(", "_", "(", "\"&Search\"", ")", ",", "self", ".", "main", ".", "search_menu_actions", ")", ",", "(", "_", "(", "\"Sour&ce\"", ")", ",", "self", ".", "main", ".", "source_menu_actions", ")", ",", "(", "_", "(", "\"&Run\"", ")", ",", "self", ".", "main", ".", "run_menu_actions", ")", ",", "(", "_", "(", "\"&Tools\"", ")", ",", "self", ".", "main", ".", "tools_menu_actions", ")", ",", "(", "_", "(", "\"&View\"", ")", ",", "[", "]", ")", ",", "(", "_", "(", "\"&Help\"", ")", ",", "self", ".", "main", ".", "help_menu_actions", ")", ")", "# Create pending new windows:\r", "for", "layout_settings", "in", "self", ".", "editorwindows_to_be_created", ":", "win", "=", "self", ".", "create_new_window", "(", ")", "win", ".", "set_layout_settings", "(", "layout_settings", ")" ]
Setup toolbars and menus for 'New window' instances
[ "Setup", "toolbars", "and", "menus", "for", "New", "window", "instances" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1245-L1271
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.set_current_filename
def set_current_filename(self, filename, editorwindow=None, focus=True): """Set focus to *filename* if this file has been opened. Return the editor instance associated to *filename*. """ editorstack = self.get_current_editorstack(editorwindow) return editorstack.set_current_filename(filename, focus)
python
def set_current_filename(self, filename, editorwindow=None, focus=True): """Set focus to *filename* if this file has been opened. Return the editor instance associated to *filename*. """ editorstack = self.get_current_editorstack(editorwindow) return editorstack.set_current_filename(filename, focus)
[ "def", "set_current_filename", "(", "self", ",", "filename", ",", "editorwindow", "=", "None", ",", "focus", "=", "True", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", "editorwindow", ")", "return", "editorstack", ".", "set_current_filename", "(", "filename", ",", "focus", ")" ]
Set focus to *filename* if this file has been opened. Return the editor instance associated to *filename*.
[ "Set", "focus", "to", "*", "filename", "*", "if", "this", "file", "has", "been", "opened", ".", "Return", "the", "editor", "instance", "associated", "to", "*", "filename", "*", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1343-L1349
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.refresh_file_dependent_actions
def refresh_file_dependent_actions(self): """Enable/disable file dependent actions (only if dockwidget is visible)""" if self.dockwidget and self.dockwidget.isVisible(): enable = self.get_current_editor() is not None for action in self.file_dependent_actions: action.setEnabled(enable)
python
def refresh_file_dependent_actions(self): """Enable/disable file dependent actions (only if dockwidget is visible)""" if self.dockwidget and self.dockwidget.isVisible(): enable = self.get_current_editor() is not None for action in self.file_dependent_actions: action.setEnabled(enable)
[ "def", "refresh_file_dependent_actions", "(", "self", ")", ":", "if", "self", ".", "dockwidget", "and", "self", ".", "dockwidget", ".", "isVisible", "(", ")", ":", "enable", "=", "self", ".", "get_current_editor", "(", ")", "is", "not", "None", "for", "action", "in", "self", ".", "file_dependent_actions", ":", "action", ".", "setEnabled", "(", "enable", ")" ]
Enable/disable file dependent actions (only if dockwidget is visible)
[ "Enable", "/", "disable", "file", "dependent", "actions", "(", "only", "if", "dockwidget", "is", "visible", ")" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1365-L1371
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.refresh_save_all_action
def refresh_save_all_action(self): """Enable 'Save All' if there are files to be saved""" editorstack = self.get_current_editorstack() if editorstack: state = any(finfo.editor.document().isModified() or finfo.newly_created for finfo in editorstack.data) self.save_all_action.setEnabled(state)
python
def refresh_save_all_action(self): """Enable 'Save All' if there are files to be saved""" editorstack = self.get_current_editorstack() if editorstack: state = any(finfo.editor.document().isModified() or finfo.newly_created for finfo in editorstack.data) self.save_all_action.setEnabled(state)
[ "def", "refresh_save_all_action", "(", "self", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "editorstack", ":", "state", "=", "any", "(", "finfo", ".", "editor", ".", "document", "(", ")", ".", "isModified", "(", ")", "or", "finfo", ".", "newly_created", "for", "finfo", "in", "editorstack", ".", "data", ")", "self", ".", "save_all_action", ".", "setEnabled", "(", "state", ")" ]
Enable 'Save All' if there are files to be saved
[ "Enable", "Save", "All", "if", "there", "are", "files", "to", "be", "saved" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1373-L1379
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.update_warning_menu
def update_warning_menu(self): """Update warning list menu""" editor = self.get_current_editor() check_results = editor.get_current_warnings() self.warning_menu.clear() filename = self.get_current_filename() for message, line_number in check_results: error = 'syntax' in message text = message[:1].upper() + message[1:] icon = ima.icon('error') if error else ima.icon('warning') slot = lambda _checked, _l=line_number: self.load(filename, goto=_l) action = create_action(self, text=text, icon=icon, triggered=slot) self.warning_menu.addAction(action)
python
def update_warning_menu(self): """Update warning list menu""" editor = self.get_current_editor() check_results = editor.get_current_warnings() self.warning_menu.clear() filename = self.get_current_filename() for message, line_number in check_results: error = 'syntax' in message text = message[:1].upper() + message[1:] icon = ima.icon('error') if error else ima.icon('warning') slot = lambda _checked, _l=line_number: self.load(filename, goto=_l) action = create_action(self, text=text, icon=icon, triggered=slot) self.warning_menu.addAction(action)
[ "def", "update_warning_menu", "(", "self", ")", ":", "editor", "=", "self", ".", "get_current_editor", "(", ")", "check_results", "=", "editor", ".", "get_current_warnings", "(", ")", "self", ".", "warning_menu", ".", "clear", "(", ")", "filename", "=", "self", ".", "get_current_filename", "(", ")", "for", "message", ",", "line_number", "in", "check_results", ":", "error", "=", "'syntax'", "in", "message", "text", "=", "message", "[", ":", "1", "]", ".", "upper", "(", ")", "+", "message", "[", "1", ":", "]", "icon", "=", "ima", ".", "icon", "(", "'error'", ")", "if", "error", "else", "ima", ".", "icon", "(", "'warning'", ")", "slot", "=", "lambda", "_checked", ",", "_l", "=", "line_number", ":", "self", ".", "load", "(", "filename", ",", "goto", "=", "_l", ")", "action", "=", "create_action", "(", "self", ",", "text", "=", "text", ",", "icon", "=", "icon", ",", "triggered", "=", "slot", ")", "self", ".", "warning_menu", ".", "addAction", "(", "action", ")" ]
Update warning list menu
[ "Update", "warning", "list", "menu" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1381-L1393
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.update_todo_menu
def update_todo_menu(self): """Update todo list menu""" editorstack = self.get_current_editorstack() results = editorstack.get_todo_results() self.todo_menu.clear() filename = self.get_current_filename() for text, line0 in results: icon = ima.icon('todo') slot = lambda _checked, _l=line0: self.load(filename, goto=_l) action = create_action(self, text=text, icon=icon, triggered=slot) self.todo_menu.addAction(action) self.update_todo_actions()
python
def update_todo_menu(self): """Update todo list menu""" editorstack = self.get_current_editorstack() results = editorstack.get_todo_results() self.todo_menu.clear() filename = self.get_current_filename() for text, line0 in results: icon = ima.icon('todo') slot = lambda _checked, _l=line0: self.load(filename, goto=_l) action = create_action(self, text=text, icon=icon, triggered=slot) self.todo_menu.addAction(action) self.update_todo_actions()
[ "def", "update_todo_menu", "(", "self", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "results", "=", "editorstack", ".", "get_todo_results", "(", ")", "self", ".", "todo_menu", ".", "clear", "(", ")", "filename", "=", "self", ".", "get_current_filename", "(", ")", "for", "text", ",", "line0", "in", "results", ":", "icon", "=", "ima", ".", "icon", "(", "'todo'", ")", "slot", "=", "lambda", "_checked", ",", "_l", "=", "line0", ":", "self", ".", "load", "(", "filename", ",", "goto", "=", "_l", ")", "action", "=", "create_action", "(", "self", ",", "text", "=", "text", ",", "icon", "=", "icon", ",", "triggered", "=", "slot", ")", "self", ".", "todo_menu", ".", "addAction", "(", "action", ")", "self", ".", "update_todo_actions", "(", ")" ]
Update todo list menu
[ "Update", "todo", "list", "menu" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1395-L1406
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.todo_results_changed
def todo_results_changed(self): """ Synchronize todo results between editorstacks Refresh todo list navigation buttons """ editorstack = self.get_current_editorstack() results = editorstack.get_todo_results() index = editorstack.get_stack_index() if index != -1: filename = editorstack.data[index].filename for other_editorstack in self.editorstacks: if other_editorstack is not editorstack: other_editorstack.set_todo_results(filename, results) self.update_todo_actions()
python
def todo_results_changed(self): """ Synchronize todo results between editorstacks Refresh todo list navigation buttons """ editorstack = self.get_current_editorstack() results = editorstack.get_todo_results() index = editorstack.get_stack_index() if index != -1: filename = editorstack.data[index].filename for other_editorstack in self.editorstacks: if other_editorstack is not editorstack: other_editorstack.set_todo_results(filename, results) self.update_todo_actions()
[ "def", "todo_results_changed", "(", "self", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "results", "=", "editorstack", ".", "get_todo_results", "(", ")", "index", "=", "editorstack", ".", "get_stack_index", "(", ")", "if", "index", "!=", "-", "1", ":", "filename", "=", "editorstack", ".", "data", "[", "index", "]", ".", "filename", "for", "other_editorstack", "in", "self", ".", "editorstacks", ":", "if", "other_editorstack", "is", "not", "editorstack", ":", "other_editorstack", ".", "set_todo_results", "(", "filename", ",", "results", ")", "self", ".", "update_todo_actions", "(", ")" ]
Synchronize todo results between editorstacks Refresh todo list navigation buttons
[ "Synchronize", "todo", "results", "between", "editorstacks", "Refresh", "todo", "list", "navigation", "buttons" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1408-L1421
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.opened_files_list_changed
def opened_files_list_changed(self): """ Opened files list has changed: --> open/close file action --> modification ('*' added to title) --> current edited file has changed """ # Refresh Python file dependent actions: editor = self.get_current_editor() if editor: python_enable = editor.is_python() cython_enable = python_enable or ( programs.is_module_installed('Cython') and editor.is_cython()) for action in self.pythonfile_dependent_actions: if action in self.cythonfile_compatible_actions: enable = cython_enable else: enable = python_enable if action is self.winpdb_action: action.setEnabled(enable and WINPDB_PATH is not None) else: action.setEnabled(enable) self.open_file_update.emit(self.get_current_filename())
python
def opened_files_list_changed(self): """ Opened files list has changed: --> open/close file action --> modification ('*' added to title) --> current edited file has changed """ # Refresh Python file dependent actions: editor = self.get_current_editor() if editor: python_enable = editor.is_python() cython_enable = python_enable or ( programs.is_module_installed('Cython') and editor.is_cython()) for action in self.pythonfile_dependent_actions: if action in self.cythonfile_compatible_actions: enable = cython_enable else: enable = python_enable if action is self.winpdb_action: action.setEnabled(enable and WINPDB_PATH is not None) else: action.setEnabled(enable) self.open_file_update.emit(self.get_current_filename())
[ "def", "opened_files_list_changed", "(", "self", ")", ":", "# Refresh Python file dependent actions:\r", "editor", "=", "self", ".", "get_current_editor", "(", ")", "if", "editor", ":", "python_enable", "=", "editor", ".", "is_python", "(", ")", "cython_enable", "=", "python_enable", "or", "(", "programs", ".", "is_module_installed", "(", "'Cython'", ")", "and", "editor", ".", "is_cython", "(", ")", ")", "for", "action", "in", "self", ".", "pythonfile_dependent_actions", ":", "if", "action", "in", "self", ".", "cythonfile_compatible_actions", ":", "enable", "=", "cython_enable", "else", ":", "enable", "=", "python_enable", "if", "action", "is", "self", ".", "winpdb_action", ":", "action", ".", "setEnabled", "(", "enable", "and", "WINPDB_PATH", "is", "not", "None", ")", "else", ":", "action", ".", "setEnabled", "(", "enable", ")", "self", ".", "open_file_update", ".", "emit", "(", "self", ".", "get_current_filename", "(", ")", ")" ]
Opened files list has changed: --> open/close file action --> modification ('*' added to title) --> current edited file has changed
[ "Opened", "files", "list", "has", "changed", ":", "--", ">", "open", "/", "close", "file", "action", "--", ">", "modification", "(", "*", "added", "to", "title", ")", "--", ">", "current", "edited", "file", "has", "changed" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1436-L1458
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.update_code_analysis_actions
def update_code_analysis_actions(self): """Update actions in the warnings menu.""" editor = self.get_current_editor() # To fix an error at startup if editor is None: return results = editor.get_current_warnings() # Update code analysis buttons state = (self.get_option('code_analysis/pyflakes') \ or self.get_option('code_analysis/pep8')) \ and results is not None and len(results) for action in (self.warning_list_action, self.previous_warning_action, self.next_warning_action): if state is not None: action.setEnabled(state)
python
def update_code_analysis_actions(self): """Update actions in the warnings menu.""" editor = self.get_current_editor() # To fix an error at startup if editor is None: return results = editor.get_current_warnings() # Update code analysis buttons state = (self.get_option('code_analysis/pyflakes') \ or self.get_option('code_analysis/pep8')) \ and results is not None and len(results) for action in (self.warning_list_action, self.previous_warning_action, self.next_warning_action): if state is not None: action.setEnabled(state)
[ "def", "update_code_analysis_actions", "(", "self", ")", ":", "editor", "=", "self", ".", "get_current_editor", "(", ")", "# To fix an error at startup\r", "if", "editor", "is", "None", ":", "return", "results", "=", "editor", ".", "get_current_warnings", "(", ")", "# Update code analysis buttons\r", "state", "=", "(", "self", ".", "get_option", "(", "'code_analysis/pyflakes'", ")", "or", "self", ".", "get_option", "(", "'code_analysis/pep8'", ")", ")", "and", "results", "is", "not", "None", "and", "len", "(", "results", ")", "for", "action", "in", "(", "self", ".", "warning_list_action", ",", "self", ".", "previous_warning_action", ",", "self", ".", "next_warning_action", ")", ":", "if", "state", "is", "not", "None", ":", "action", ".", "setEnabled", "(", "state", ")" ]
Update actions in the warnings menu.
[ "Update", "actions", "in", "the", "warnings", "menu", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1460-L1474
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.save_bookmarks
def save_bookmarks(self, filename, bookmarks): """Receive bookmark changes and save them.""" filename = to_text_string(filename) bookmarks = to_text_string(bookmarks) filename = osp.normpath(osp.abspath(filename)) bookmarks = eval(bookmarks) save_bookmarks(filename, bookmarks)
python
def save_bookmarks(self, filename, bookmarks): """Receive bookmark changes and save them.""" filename = to_text_string(filename) bookmarks = to_text_string(bookmarks) filename = osp.normpath(osp.abspath(filename)) bookmarks = eval(bookmarks) save_bookmarks(filename, bookmarks)
[ "def", "save_bookmarks", "(", "self", ",", "filename", ",", "bookmarks", ")", ":", "filename", "=", "to_text_string", "(", "filename", ")", "bookmarks", "=", "to_text_string", "(", "bookmarks", ")", "filename", "=", "osp", ".", "normpath", "(", "osp", ".", "abspath", "(", "filename", ")", ")", "bookmarks", "=", "eval", "(", "bookmarks", ")", "save_bookmarks", "(", "filename", ",", "bookmarks", ")" ]
Receive bookmark changes and save them.
[ "Receive", "bookmark", "changes", "and", "save", "them", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1508-L1514
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.__load_temp_file
def __load_temp_file(self): """Load temporary file from a text file in user home directory""" if not osp.isfile(self.TEMPFILE_PATH): # Creating temporary file default = ['# -*- coding: utf-8 -*-', '"""', _("Spyder Editor"), '', _("This is a temporary script file."), '"""', '', ''] text = os.linesep.join([encoding.to_unicode(qstr) for qstr in default]) try: encoding.write(to_text_string(text), self.TEMPFILE_PATH, 'utf-8') except EnvironmentError: self.new() return self.load(self.TEMPFILE_PATH)
python
def __load_temp_file(self): """Load temporary file from a text file in user home directory""" if not osp.isfile(self.TEMPFILE_PATH): # Creating temporary file default = ['# -*- coding: utf-8 -*-', '"""', _("Spyder Editor"), '', _("This is a temporary script file."), '"""', '', ''] text = os.linesep.join([encoding.to_unicode(qstr) for qstr in default]) try: encoding.write(to_text_string(text), self.TEMPFILE_PATH, 'utf-8') except EnvironmentError: self.new() return self.load(self.TEMPFILE_PATH)
[ "def", "__load_temp_file", "(", "self", ")", ":", "if", "not", "osp", ".", "isfile", "(", "self", ".", "TEMPFILE_PATH", ")", ":", "# Creating temporary file\r", "default", "=", "[", "'# -*- coding: utf-8 -*-'", ",", "'\"\"\"'", ",", "_", "(", "\"Spyder Editor\"", ")", ",", "''", ",", "_", "(", "\"This is a temporary script file.\"", ")", ",", "'\"\"\"'", ",", "''", ",", "''", "]", "text", "=", "os", ".", "linesep", ".", "join", "(", "[", "encoding", ".", "to_unicode", "(", "qstr", ")", "for", "qstr", "in", "default", "]", ")", "try", ":", "encoding", ".", "write", "(", "to_text_string", "(", "text", ")", ",", "self", ".", "TEMPFILE_PATH", ",", "'utf-8'", ")", "except", "EnvironmentError", ":", "self", ".", "new", "(", ")", "return", "self", ".", "load", "(", "self", ".", "TEMPFILE_PATH", ")" ]
Load temporary file from a text file in user home directory
[ "Load", "temporary", "file", "from", "a", "text", "file", "in", "user", "home", "directory" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1517-L1534
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.__set_workdir
def __set_workdir(self): """Set current script directory as working directory""" fname = self.get_current_filename() if fname is not None: directory = osp.dirname(osp.abspath(fname)) self.open_dir.emit(directory)
python
def __set_workdir(self): """Set current script directory as working directory""" fname = self.get_current_filename() if fname is not None: directory = osp.dirname(osp.abspath(fname)) self.open_dir.emit(directory)
[ "def", "__set_workdir", "(", "self", ")", ":", "fname", "=", "self", ".", "get_current_filename", "(", ")", "if", "fname", "is", "not", "None", ":", "directory", "=", "osp", ".", "dirname", "(", "osp", ".", "abspath", "(", "fname", ")", ")", "self", ".", "open_dir", ".", "emit", "(", "directory", ")" ]
Set current script directory as working directory
[ "Set", "current", "script", "directory", "as", "working", "directory" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1537-L1542
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.__add_recent_file
def __add_recent_file(self, fname): """Add to recent file list""" if fname is None: return if fname in self.recent_files: self.recent_files.remove(fname) self.recent_files.insert(0, fname) if len(self.recent_files) > self.get_option('max_recent_files'): self.recent_files.pop(-1)
python
def __add_recent_file(self, fname): """Add to recent file list""" if fname is None: return if fname in self.recent_files: self.recent_files.remove(fname) self.recent_files.insert(0, fname) if len(self.recent_files) > self.get_option('max_recent_files'): self.recent_files.pop(-1)
[ "def", "__add_recent_file", "(", "self", ",", "fname", ")", ":", "if", "fname", "is", "None", ":", "return", "if", "fname", "in", "self", ".", "recent_files", ":", "self", ".", "recent_files", ".", "remove", "(", "fname", ")", "self", ".", "recent_files", ".", "insert", "(", "0", ",", "fname", ")", "if", "len", "(", "self", ".", "recent_files", ")", ">", "self", ".", "get_option", "(", "'max_recent_files'", ")", ":", "self", ".", "recent_files", ".", "pop", "(", "-", "1", ")" ]
Add to recent file list
[ "Add", "to", "recent", "file", "list" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1544-L1552
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor._clone_file_everywhere
def _clone_file_everywhere(self, finfo): """Clone file (*src_editor* widget) in all editorstacks Cloning from the first editorstack in which every single new editor is created (when loading or creating a new file)""" for editorstack in self.editorstacks[1:]: editor = editorstack.clone_editor_from(finfo, set_current=False) self.register_widget_shortcuts(editor)
python
def _clone_file_everywhere(self, finfo): """Clone file (*src_editor* widget) in all editorstacks Cloning from the first editorstack in which every single new editor is created (when loading or creating a new file)""" for editorstack in self.editorstacks[1:]: editor = editorstack.clone_editor_from(finfo, set_current=False) self.register_widget_shortcuts(editor)
[ "def", "_clone_file_everywhere", "(", "self", ",", "finfo", ")", ":", "for", "editorstack", "in", "self", ".", "editorstacks", "[", "1", ":", "]", ":", "editor", "=", "editorstack", ".", "clone_editor_from", "(", "finfo", ",", "set_current", "=", "False", ")", "self", ".", "register_widget_shortcuts", "(", "editor", ")" ]
Clone file (*src_editor* widget) in all editorstacks Cloning from the first editorstack in which every single new editor is created (when loading or creating a new file)
[ "Clone", "file", "(", "*", "src_editor", "*", "widget", ")", "in", "all", "editorstacks", "Cloning", "from", "the", "first", "editorstack", "in", "which", "every", "single", "new", "editor", "is", "created", "(", "when", "loading", "or", "creating", "a", "new", "file", ")" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1554-L1560
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.new
def new(self, fname=None, editorstack=None, text=None): """ Create a new file - Untitled fname=None --> fname will be 'untitledXX.py' but do not create file fname=<basestring> --> create file """ # If no text is provided, create default content empty = False try: if text is None: default_content = True text, enc = encoding.read(self.TEMPLATE_PATH) enc_match = re.search(r'-*- coding: ?([a-z0-9A-Z\-]*) -*-', text) if enc_match: enc = enc_match.group(1) # Initialize template variables # Windows username = encoding.to_unicode_from_fs( os.environ.get('USERNAME', '')) # Linux, Mac OS X if not username: username = encoding.to_unicode_from_fs( os.environ.get('USER', '-')) VARS = { 'date': time.ctime(), 'username': username, } try: text = text % VARS except Exception: pass else: default_content = False enc = encoding.read(self.TEMPLATE_PATH)[1] except (IOError, OSError): text = '' enc = 'utf-8' default_content = True empty = True create_fname = lambda n: to_text_string(_("untitled")) + ("%d.py" % n) # Creating editor widget if editorstack is None: current_es = self.get_current_editorstack() else: current_es = editorstack created_from_here = fname is None if created_from_here: while True: fname = create_fname(self.untitled_num) self.untitled_num += 1 if not osp.isfile(fname): break basedir = getcwd_or_home() if self.main.projects.get_active_project() is not None: basedir = self.main.projects.get_active_project_path() else: c_fname = self.get_current_filename() if c_fname is not None and c_fname != self.TEMPFILE_PATH: basedir = osp.dirname(c_fname) fname = osp.abspath(osp.join(basedir, fname)) else: # QString when triggered by a Qt signal fname = osp.abspath(to_text_string(fname)) index = current_es.has_filename(fname) if index is not None and not current_es.close_file(index): return # Creating the editor widget in the first editorstack (the one that # can't be destroyed), then cloning this editor widget in all other # editorstacks: finfo = self.editorstacks[0].new(fname, enc, text, default_content, empty) finfo.path = self.main.get_spyder_pythonpath() self._clone_file_everywhere(finfo) current_editor = current_es.set_current_filename(finfo.filename) self.register_widget_shortcuts(current_editor) if not created_from_here: self.save(force=True)
python
def new(self, fname=None, editorstack=None, text=None): """ Create a new file - Untitled fname=None --> fname will be 'untitledXX.py' but do not create file fname=<basestring> --> create file """ # If no text is provided, create default content empty = False try: if text is None: default_content = True text, enc = encoding.read(self.TEMPLATE_PATH) enc_match = re.search(r'-*- coding: ?([a-z0-9A-Z\-]*) -*-', text) if enc_match: enc = enc_match.group(1) # Initialize template variables # Windows username = encoding.to_unicode_from_fs( os.environ.get('USERNAME', '')) # Linux, Mac OS X if not username: username = encoding.to_unicode_from_fs( os.environ.get('USER', '-')) VARS = { 'date': time.ctime(), 'username': username, } try: text = text % VARS except Exception: pass else: default_content = False enc = encoding.read(self.TEMPLATE_PATH)[1] except (IOError, OSError): text = '' enc = 'utf-8' default_content = True empty = True create_fname = lambda n: to_text_string(_("untitled")) + ("%d.py" % n) # Creating editor widget if editorstack is None: current_es = self.get_current_editorstack() else: current_es = editorstack created_from_here = fname is None if created_from_here: while True: fname = create_fname(self.untitled_num) self.untitled_num += 1 if not osp.isfile(fname): break basedir = getcwd_or_home() if self.main.projects.get_active_project() is not None: basedir = self.main.projects.get_active_project_path() else: c_fname = self.get_current_filename() if c_fname is not None and c_fname != self.TEMPFILE_PATH: basedir = osp.dirname(c_fname) fname = osp.abspath(osp.join(basedir, fname)) else: # QString when triggered by a Qt signal fname = osp.abspath(to_text_string(fname)) index = current_es.has_filename(fname) if index is not None and not current_es.close_file(index): return # Creating the editor widget in the first editorstack (the one that # can't be destroyed), then cloning this editor widget in all other # editorstacks: finfo = self.editorstacks[0].new(fname, enc, text, default_content, empty) finfo.path = self.main.get_spyder_pythonpath() self._clone_file_everywhere(finfo) current_editor = current_es.set_current_filename(finfo.filename) self.register_widget_shortcuts(current_editor) if not created_from_here: self.save(force=True)
[ "def", "new", "(", "self", ",", "fname", "=", "None", ",", "editorstack", "=", "None", ",", "text", "=", "None", ")", ":", "# If no text is provided, create default content\r", "empty", "=", "False", "try", ":", "if", "text", "is", "None", ":", "default_content", "=", "True", "text", ",", "enc", "=", "encoding", ".", "read", "(", "self", ".", "TEMPLATE_PATH", ")", "enc_match", "=", "re", ".", "search", "(", "r'-*- coding: ?([a-z0-9A-Z\\-]*) -*-'", ",", "text", ")", "if", "enc_match", ":", "enc", "=", "enc_match", ".", "group", "(", "1", ")", "# Initialize template variables\r", "# Windows\r", "username", "=", "encoding", ".", "to_unicode_from_fs", "(", "os", ".", "environ", ".", "get", "(", "'USERNAME'", ",", "''", ")", ")", "# Linux, Mac OS X\r", "if", "not", "username", ":", "username", "=", "encoding", ".", "to_unicode_from_fs", "(", "os", ".", "environ", ".", "get", "(", "'USER'", ",", "'-'", ")", ")", "VARS", "=", "{", "'date'", ":", "time", ".", "ctime", "(", ")", ",", "'username'", ":", "username", ",", "}", "try", ":", "text", "=", "text", "%", "VARS", "except", "Exception", ":", "pass", "else", ":", "default_content", "=", "False", "enc", "=", "encoding", ".", "read", "(", "self", ".", "TEMPLATE_PATH", ")", "[", "1", "]", "except", "(", "IOError", ",", "OSError", ")", ":", "text", "=", "''", "enc", "=", "'utf-8'", "default_content", "=", "True", "empty", "=", "True", "create_fname", "=", "lambda", "n", ":", "to_text_string", "(", "_", "(", "\"untitled\"", ")", ")", "+", "(", "\"%d.py\"", "%", "n", ")", "# Creating editor widget\r", "if", "editorstack", "is", "None", ":", "current_es", "=", "self", ".", "get_current_editorstack", "(", ")", "else", ":", "current_es", "=", "editorstack", "created_from_here", "=", "fname", "is", "None", "if", "created_from_here", ":", "while", "True", ":", "fname", "=", "create_fname", "(", "self", ".", "untitled_num", ")", "self", ".", "untitled_num", "+=", "1", "if", "not", "osp", ".", "isfile", "(", "fname", ")", ":", "break", "basedir", "=", "getcwd_or_home", "(", ")", "if", "self", ".", "main", ".", "projects", ".", "get_active_project", "(", ")", "is", "not", "None", ":", "basedir", "=", "self", ".", "main", ".", "projects", ".", "get_active_project_path", "(", ")", "else", ":", "c_fname", "=", "self", ".", "get_current_filename", "(", ")", "if", "c_fname", "is", "not", "None", "and", "c_fname", "!=", "self", ".", "TEMPFILE_PATH", ":", "basedir", "=", "osp", ".", "dirname", "(", "c_fname", ")", "fname", "=", "osp", ".", "abspath", "(", "osp", ".", "join", "(", "basedir", ",", "fname", ")", ")", "else", ":", "# QString when triggered by a Qt signal\r", "fname", "=", "osp", ".", "abspath", "(", "to_text_string", "(", "fname", ")", ")", "index", "=", "current_es", ".", "has_filename", "(", "fname", ")", "if", "index", "is", "not", "None", "and", "not", "current_es", ".", "close_file", "(", "index", ")", ":", "return", "# Creating the editor widget in the first editorstack (the one that\r", "# can't be destroyed), then cloning this editor widget in all other\r", "# editorstacks:\r", "finfo", "=", "self", ".", "editorstacks", "[", "0", "]", ".", "new", "(", "fname", ",", "enc", ",", "text", ",", "default_content", ",", "empty", ")", "finfo", ".", "path", "=", "self", ".", "main", ".", "get_spyder_pythonpath", "(", ")", "self", ".", "_clone_file_everywhere", "(", "finfo", ")", "current_editor", "=", "current_es", ".", "set_current_filename", "(", "finfo", ".", "filename", ")", "self", ".", "register_widget_shortcuts", "(", "current_editor", ")", "if", "not", "created_from_here", ":", "self", ".", "save", "(", "force", "=", "True", ")" ]
Create a new file - Untitled fname=None --> fname will be 'untitledXX.py' but do not create file fname=<basestring> --> create file
[ "Create", "a", "new", "file", "-", "Untitled", "fname", "=", "None", "--", ">", "fname", "will", "be", "untitledXX", ".", "py", "but", "do", "not", "create", "file", "fname", "=", "<basestring", ">", "--", ">", "create", "file" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1565-L1646
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.update_recent_file_menu
def update_recent_file_menu(self): """Update recent file menu""" recent_files = [] for fname in self.recent_files: if self.is_file_opened(fname) is None and osp.isfile(fname): recent_files.append(fname) self.recent_file_menu.clear() if recent_files: for fname in recent_files: action = create_action(self, fname, icon=ima.icon('FileIcon'), triggered=self.load) action.setData(to_qvariant(fname)) self.recent_file_menu.addAction(action) self.clear_recent_action.setEnabled(len(recent_files) > 0) add_actions(self.recent_file_menu, (None, self.max_recent_action, self.clear_recent_action))
python
def update_recent_file_menu(self): """Update recent file menu""" recent_files = [] for fname in self.recent_files: if self.is_file_opened(fname) is None and osp.isfile(fname): recent_files.append(fname) self.recent_file_menu.clear() if recent_files: for fname in recent_files: action = create_action(self, fname, icon=ima.icon('FileIcon'), triggered=self.load) action.setData(to_qvariant(fname)) self.recent_file_menu.addAction(action) self.clear_recent_action.setEnabled(len(recent_files) > 0) add_actions(self.recent_file_menu, (None, self.max_recent_action, self.clear_recent_action))
[ "def", "update_recent_file_menu", "(", "self", ")", ":", "recent_files", "=", "[", "]", "for", "fname", "in", "self", ".", "recent_files", ":", "if", "self", ".", "is_file_opened", "(", "fname", ")", "is", "None", "and", "osp", ".", "isfile", "(", "fname", ")", ":", "recent_files", ".", "append", "(", "fname", ")", "self", ".", "recent_file_menu", ".", "clear", "(", ")", "if", "recent_files", ":", "for", "fname", "in", "recent_files", ":", "action", "=", "create_action", "(", "self", ",", "fname", ",", "icon", "=", "ima", ".", "icon", "(", "'FileIcon'", ")", ",", "triggered", "=", "self", ".", "load", ")", "action", ".", "setData", "(", "to_qvariant", "(", "fname", ")", ")", "self", ".", "recent_file_menu", ".", "addAction", "(", "action", ")", "self", ".", "clear_recent_action", ".", "setEnabled", "(", "len", "(", "recent_files", ")", ">", "0", ")", "add_actions", "(", "self", ".", "recent_file_menu", ",", "(", "None", ",", "self", ".", "max_recent_action", ",", "self", ".", "clear_recent_action", ")", ")" ]
Update recent file menu
[ "Update", "recent", "file", "menu" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1652-L1668
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.load
def load(self, filenames=None, goto=None, word='', editorwindow=None, processevents=True, start_column=None, set_focus=True, add_where='end'): """ Load a text file editorwindow: load in this editorwindow (useful when clicking on outline explorer with multiple editor windows) processevents: determines if processEvents() should be called at the end of this method (set to False to prevent keyboard events from creeping through to the editor during debugging) """ # Switch to editor before trying to load a file try: self.switch_to_plugin() except AttributeError: pass editor0 = self.get_current_editor() if editor0 is not None: position0 = editor0.get_position('cursor') filename0 = self.get_current_filename() else: position0, filename0 = None, None if not filenames: # Recent files action action = self.sender() if isinstance(action, QAction): filenames = from_qvariant(action.data(), to_text_string) if not filenames: basedir = getcwd_or_home() if self.edit_filetypes is None: self.edit_filetypes = get_edit_filetypes() if self.edit_filters is None: self.edit_filters = get_edit_filters() c_fname = self.get_current_filename() if c_fname is not None and c_fname != self.TEMPFILE_PATH: basedir = osp.dirname(c_fname) self.redirect_stdio.emit(False) parent_widget = self.get_current_editorstack() if filename0 is not None: selectedfilter = get_filter(self.edit_filetypes, osp.splitext(filename0)[1]) else: selectedfilter = '' if not running_under_pytest(): filenames, _sf = getopenfilenames( parent_widget, _("Open file"), basedir, self.edit_filters, selectedfilter=selectedfilter, options=QFileDialog.HideNameFilterDetails) else: # Use a Qt (i.e. scriptable) dialog for pytest dialog = QFileDialog(parent_widget, _("Open file"), options=QFileDialog.DontUseNativeDialog) if dialog.exec_(): filenames = dialog.selectedFiles() self.redirect_stdio.emit(True) if filenames: filenames = [osp.normpath(fname) for fname in filenames] else: return focus_widget = QApplication.focusWidget() if self.editorwindows and not self.dockwidget.isVisible(): # We override the editorwindow variable to force a focus on # the editor window instead of the hidden editor dockwidget. # See PR #5742. if editorwindow not in self.editorwindows: editorwindow = self.editorwindows[0] editorwindow.setFocus() editorwindow.raise_() elif (self.dockwidget and not self.ismaximized and not self.dockwidget.isAncestorOf(focus_widget) and not isinstance(focus_widget, CodeEditor)): self.dockwidget.setVisible(True) self.dockwidget.setFocus() self.dockwidget.raise_() def _convert(fname): fname = osp.abspath(encoding.to_unicode_from_fs(fname)) if os.name == 'nt' and len(fname) >= 2 and fname[1] == ':': fname = fname[0].upper()+fname[1:] return fname if hasattr(filenames, 'replaceInStrings'): # This is a QStringList instance (PyQt API #1), converting to list: filenames = list(filenames) if not isinstance(filenames, list): filenames = [_convert(filenames)] else: filenames = [_convert(fname) for fname in list(filenames)] if isinstance(goto, int): goto = [goto] elif goto is not None and len(goto) != len(filenames): goto = None for index, filename in enumerate(filenames): # -- Do not open an already opened file focus = set_focus and index == 0 current_editor = self.set_current_filename(filename, editorwindow, focus=focus) if current_editor is None: # -- Not a valid filename: if not osp.isfile(filename): continue # -- current_es = self.get_current_editorstack(editorwindow) # Creating the editor widget in the first editorstack # (the one that can't be destroyed), then cloning this # editor widget in all other editorstacks: finfo = self.editorstacks[0].load( filename, set_current=False, add_where=add_where) finfo.path = self.main.get_spyder_pythonpath() self._clone_file_everywhere(finfo) current_editor = current_es.set_current_filename(filename, focus=focus) current_editor.debugger.load_breakpoints() current_editor.set_bookmarks(load_bookmarks(filename)) self.register_widget_shortcuts(current_editor) current_es.analyze_script() self.__add_recent_file(filename) if goto is not None: # 'word' is assumed to be None as well current_editor.go_to_line(goto[index], word=word, start_column=start_column) position = current_editor.get_position('cursor') self.cursor_moved(filename0, position0, filename, position) current_editor.clearFocus() current_editor.setFocus() current_editor.window().raise_() if processevents: QApplication.processEvents() else: # processevents is false only when calling from debugging current_editor.sig_debug_stop.emit(goto[index]) current_sw = self.main.ipyconsole.get_current_shellwidget() current_sw.sig_prompt_ready.connect( current_editor.sig_debug_stop[()].emit)
python
def load(self, filenames=None, goto=None, word='', editorwindow=None, processevents=True, start_column=None, set_focus=True, add_where='end'): """ Load a text file editorwindow: load in this editorwindow (useful when clicking on outline explorer with multiple editor windows) processevents: determines if processEvents() should be called at the end of this method (set to False to prevent keyboard events from creeping through to the editor during debugging) """ # Switch to editor before trying to load a file try: self.switch_to_plugin() except AttributeError: pass editor0 = self.get_current_editor() if editor0 is not None: position0 = editor0.get_position('cursor') filename0 = self.get_current_filename() else: position0, filename0 = None, None if not filenames: # Recent files action action = self.sender() if isinstance(action, QAction): filenames = from_qvariant(action.data(), to_text_string) if not filenames: basedir = getcwd_or_home() if self.edit_filetypes is None: self.edit_filetypes = get_edit_filetypes() if self.edit_filters is None: self.edit_filters = get_edit_filters() c_fname = self.get_current_filename() if c_fname is not None and c_fname != self.TEMPFILE_PATH: basedir = osp.dirname(c_fname) self.redirect_stdio.emit(False) parent_widget = self.get_current_editorstack() if filename0 is not None: selectedfilter = get_filter(self.edit_filetypes, osp.splitext(filename0)[1]) else: selectedfilter = '' if not running_under_pytest(): filenames, _sf = getopenfilenames( parent_widget, _("Open file"), basedir, self.edit_filters, selectedfilter=selectedfilter, options=QFileDialog.HideNameFilterDetails) else: # Use a Qt (i.e. scriptable) dialog for pytest dialog = QFileDialog(parent_widget, _("Open file"), options=QFileDialog.DontUseNativeDialog) if dialog.exec_(): filenames = dialog.selectedFiles() self.redirect_stdio.emit(True) if filenames: filenames = [osp.normpath(fname) for fname in filenames] else: return focus_widget = QApplication.focusWidget() if self.editorwindows and not self.dockwidget.isVisible(): # We override the editorwindow variable to force a focus on # the editor window instead of the hidden editor dockwidget. # See PR #5742. if editorwindow not in self.editorwindows: editorwindow = self.editorwindows[0] editorwindow.setFocus() editorwindow.raise_() elif (self.dockwidget and not self.ismaximized and not self.dockwidget.isAncestorOf(focus_widget) and not isinstance(focus_widget, CodeEditor)): self.dockwidget.setVisible(True) self.dockwidget.setFocus() self.dockwidget.raise_() def _convert(fname): fname = osp.abspath(encoding.to_unicode_from_fs(fname)) if os.name == 'nt' and len(fname) >= 2 and fname[1] == ':': fname = fname[0].upper()+fname[1:] return fname if hasattr(filenames, 'replaceInStrings'): # This is a QStringList instance (PyQt API #1), converting to list: filenames = list(filenames) if not isinstance(filenames, list): filenames = [_convert(filenames)] else: filenames = [_convert(fname) for fname in list(filenames)] if isinstance(goto, int): goto = [goto] elif goto is not None and len(goto) != len(filenames): goto = None for index, filename in enumerate(filenames): # -- Do not open an already opened file focus = set_focus and index == 0 current_editor = self.set_current_filename(filename, editorwindow, focus=focus) if current_editor is None: # -- Not a valid filename: if not osp.isfile(filename): continue # -- current_es = self.get_current_editorstack(editorwindow) # Creating the editor widget in the first editorstack # (the one that can't be destroyed), then cloning this # editor widget in all other editorstacks: finfo = self.editorstacks[0].load( filename, set_current=False, add_where=add_where) finfo.path = self.main.get_spyder_pythonpath() self._clone_file_everywhere(finfo) current_editor = current_es.set_current_filename(filename, focus=focus) current_editor.debugger.load_breakpoints() current_editor.set_bookmarks(load_bookmarks(filename)) self.register_widget_shortcuts(current_editor) current_es.analyze_script() self.__add_recent_file(filename) if goto is not None: # 'word' is assumed to be None as well current_editor.go_to_line(goto[index], word=word, start_column=start_column) position = current_editor.get_position('cursor') self.cursor_moved(filename0, position0, filename, position) current_editor.clearFocus() current_editor.setFocus() current_editor.window().raise_() if processevents: QApplication.processEvents() else: # processevents is false only when calling from debugging current_editor.sig_debug_stop.emit(goto[index]) current_sw = self.main.ipyconsole.get_current_shellwidget() current_sw.sig_prompt_ready.connect( current_editor.sig_debug_stop[()].emit)
[ "def", "load", "(", "self", ",", "filenames", "=", "None", ",", "goto", "=", "None", ",", "word", "=", "''", ",", "editorwindow", "=", "None", ",", "processevents", "=", "True", ",", "start_column", "=", "None", ",", "set_focus", "=", "True", ",", "add_where", "=", "'end'", ")", ":", "# Switch to editor before trying to load a file\r", "try", ":", "self", ".", "switch_to_plugin", "(", ")", "except", "AttributeError", ":", "pass", "editor0", "=", "self", ".", "get_current_editor", "(", ")", "if", "editor0", "is", "not", "None", ":", "position0", "=", "editor0", ".", "get_position", "(", "'cursor'", ")", "filename0", "=", "self", ".", "get_current_filename", "(", ")", "else", ":", "position0", ",", "filename0", "=", "None", ",", "None", "if", "not", "filenames", ":", "# Recent files action\r", "action", "=", "self", ".", "sender", "(", ")", "if", "isinstance", "(", "action", ",", "QAction", ")", ":", "filenames", "=", "from_qvariant", "(", "action", ".", "data", "(", ")", ",", "to_text_string", ")", "if", "not", "filenames", ":", "basedir", "=", "getcwd_or_home", "(", ")", "if", "self", ".", "edit_filetypes", "is", "None", ":", "self", ".", "edit_filetypes", "=", "get_edit_filetypes", "(", ")", "if", "self", ".", "edit_filters", "is", "None", ":", "self", ".", "edit_filters", "=", "get_edit_filters", "(", ")", "c_fname", "=", "self", ".", "get_current_filename", "(", ")", "if", "c_fname", "is", "not", "None", "and", "c_fname", "!=", "self", ".", "TEMPFILE_PATH", ":", "basedir", "=", "osp", ".", "dirname", "(", "c_fname", ")", "self", ".", "redirect_stdio", ".", "emit", "(", "False", ")", "parent_widget", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "filename0", "is", "not", "None", ":", "selectedfilter", "=", "get_filter", "(", "self", ".", "edit_filetypes", ",", "osp", ".", "splitext", "(", "filename0", ")", "[", "1", "]", ")", "else", ":", "selectedfilter", "=", "''", "if", "not", "running_under_pytest", "(", ")", ":", "filenames", ",", "_sf", "=", "getopenfilenames", "(", "parent_widget", ",", "_", "(", "\"Open file\"", ")", ",", "basedir", ",", "self", ".", "edit_filters", ",", "selectedfilter", "=", "selectedfilter", ",", "options", "=", "QFileDialog", ".", "HideNameFilterDetails", ")", "else", ":", "# Use a Qt (i.e. scriptable) dialog for pytest\r", "dialog", "=", "QFileDialog", "(", "parent_widget", ",", "_", "(", "\"Open file\"", ")", ",", "options", "=", "QFileDialog", ".", "DontUseNativeDialog", ")", "if", "dialog", ".", "exec_", "(", ")", ":", "filenames", "=", "dialog", ".", "selectedFiles", "(", ")", "self", ".", "redirect_stdio", ".", "emit", "(", "True", ")", "if", "filenames", ":", "filenames", "=", "[", "osp", ".", "normpath", "(", "fname", ")", "for", "fname", "in", "filenames", "]", "else", ":", "return", "focus_widget", "=", "QApplication", ".", "focusWidget", "(", ")", "if", "self", ".", "editorwindows", "and", "not", "self", ".", "dockwidget", ".", "isVisible", "(", ")", ":", "# We override the editorwindow variable to force a focus on\r", "# the editor window instead of the hidden editor dockwidget.\r", "# See PR #5742.\r", "if", "editorwindow", "not", "in", "self", ".", "editorwindows", ":", "editorwindow", "=", "self", ".", "editorwindows", "[", "0", "]", "editorwindow", ".", "setFocus", "(", ")", "editorwindow", ".", "raise_", "(", ")", "elif", "(", "self", ".", "dockwidget", "and", "not", "self", ".", "ismaximized", "and", "not", "self", ".", "dockwidget", ".", "isAncestorOf", "(", "focus_widget", ")", "and", "not", "isinstance", "(", "focus_widget", ",", "CodeEditor", ")", ")", ":", "self", ".", "dockwidget", ".", "setVisible", "(", "True", ")", "self", ".", "dockwidget", ".", "setFocus", "(", ")", "self", ".", "dockwidget", ".", "raise_", "(", ")", "def", "_convert", "(", "fname", ")", ":", "fname", "=", "osp", ".", "abspath", "(", "encoding", ".", "to_unicode_from_fs", "(", "fname", ")", ")", "if", "os", ".", "name", "==", "'nt'", "and", "len", "(", "fname", ")", ">=", "2", "and", "fname", "[", "1", "]", "==", "':'", ":", "fname", "=", "fname", "[", "0", "]", ".", "upper", "(", ")", "+", "fname", "[", "1", ":", "]", "return", "fname", "if", "hasattr", "(", "filenames", ",", "'replaceInStrings'", ")", ":", "# This is a QStringList instance (PyQt API #1), converting to list:\r", "filenames", "=", "list", "(", "filenames", ")", "if", "not", "isinstance", "(", "filenames", ",", "list", ")", ":", "filenames", "=", "[", "_convert", "(", "filenames", ")", "]", "else", ":", "filenames", "=", "[", "_convert", "(", "fname", ")", "for", "fname", "in", "list", "(", "filenames", ")", "]", "if", "isinstance", "(", "goto", ",", "int", ")", ":", "goto", "=", "[", "goto", "]", "elif", "goto", "is", "not", "None", "and", "len", "(", "goto", ")", "!=", "len", "(", "filenames", ")", ":", "goto", "=", "None", "for", "index", ",", "filename", "in", "enumerate", "(", "filenames", ")", ":", "# -- Do not open an already opened file\r", "focus", "=", "set_focus", "and", "index", "==", "0", "current_editor", "=", "self", ".", "set_current_filename", "(", "filename", ",", "editorwindow", ",", "focus", "=", "focus", ")", "if", "current_editor", "is", "None", ":", "# -- Not a valid filename:\r", "if", "not", "osp", ".", "isfile", "(", "filename", ")", ":", "continue", "# --\r", "current_es", "=", "self", ".", "get_current_editorstack", "(", "editorwindow", ")", "# Creating the editor widget in the first editorstack\r", "# (the one that can't be destroyed), then cloning this\r", "# editor widget in all other editorstacks:\r", "finfo", "=", "self", ".", "editorstacks", "[", "0", "]", ".", "load", "(", "filename", ",", "set_current", "=", "False", ",", "add_where", "=", "add_where", ")", "finfo", ".", "path", "=", "self", ".", "main", ".", "get_spyder_pythonpath", "(", ")", "self", ".", "_clone_file_everywhere", "(", "finfo", ")", "current_editor", "=", "current_es", ".", "set_current_filename", "(", "filename", ",", "focus", "=", "focus", ")", "current_editor", ".", "debugger", ".", "load_breakpoints", "(", ")", "current_editor", ".", "set_bookmarks", "(", "load_bookmarks", "(", "filename", ")", ")", "self", ".", "register_widget_shortcuts", "(", "current_editor", ")", "current_es", ".", "analyze_script", "(", ")", "self", ".", "__add_recent_file", "(", "filename", ")", "if", "goto", "is", "not", "None", ":", "# 'word' is assumed to be None as well\r", "current_editor", ".", "go_to_line", "(", "goto", "[", "index", "]", ",", "word", "=", "word", ",", "start_column", "=", "start_column", ")", "position", "=", "current_editor", ".", "get_position", "(", "'cursor'", ")", "self", ".", "cursor_moved", "(", "filename0", ",", "position0", ",", "filename", ",", "position", ")", "current_editor", ".", "clearFocus", "(", ")", "current_editor", ".", "setFocus", "(", ")", "current_editor", ".", "window", "(", ")", ".", "raise_", "(", ")", "if", "processevents", ":", "QApplication", ".", "processEvents", "(", ")", "else", ":", "# processevents is false only when calling from debugging\r", "current_editor", ".", "sig_debug_stop", ".", "emit", "(", "goto", "[", "index", "]", ")", "current_sw", "=", "self", ".", "main", ".", "ipyconsole", ".", "get_current_shellwidget", "(", ")", "current_sw", ".", "sig_prompt_ready", ".", "connect", "(", "current_editor", ".", "sig_debug_stop", "[", "(", ")", "]", ".", "emit", ")" ]
Load a text file editorwindow: load in this editorwindow (useful when clicking on outline explorer with multiple editor windows) processevents: determines if processEvents() should be called at the end of this method (set to False to prevent keyboard events from creeping through to the editor during debugging)
[ "Load", "a", "text", "file", "editorwindow", ":", "load", "in", "this", "editorwindow", "(", "useful", "when", "clicking", "on", "outline", "explorer", "with", "multiple", "editor", "windows", ")", "processevents", ":", "determines", "if", "processEvents", "()", "should", "be", "called", "at", "the", "end", "of", "this", "method", "(", "set", "to", "False", "to", "prevent", "keyboard", "events", "from", "creeping", "through", "to", "the", "editor", "during", "debugging", ")" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1689-L1828
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.print_file
def print_file(self): """Print current file""" editor = self.get_current_editor() filename = self.get_current_filename() printer = Printer(mode=QPrinter.HighResolution, header_font=self.get_plugin_font('printer_header')) printDialog = QPrintDialog(printer, editor) if editor.has_selected_text(): printDialog.setOption(QAbstractPrintDialog.PrintSelection, True) self.redirect_stdio.emit(False) answer = printDialog.exec_() self.redirect_stdio.emit(True) if answer == QDialog.Accepted: self.starting_long_process(_("Printing...")) printer.setDocName(filename) editor.print_(printer) self.ending_long_process()
python
def print_file(self): """Print current file""" editor = self.get_current_editor() filename = self.get_current_filename() printer = Printer(mode=QPrinter.HighResolution, header_font=self.get_plugin_font('printer_header')) printDialog = QPrintDialog(printer, editor) if editor.has_selected_text(): printDialog.setOption(QAbstractPrintDialog.PrintSelection, True) self.redirect_stdio.emit(False) answer = printDialog.exec_() self.redirect_stdio.emit(True) if answer == QDialog.Accepted: self.starting_long_process(_("Printing...")) printer.setDocName(filename) editor.print_(printer) self.ending_long_process()
[ "def", "print_file", "(", "self", ")", ":", "editor", "=", "self", ".", "get_current_editor", "(", ")", "filename", "=", "self", ".", "get_current_filename", "(", ")", "printer", "=", "Printer", "(", "mode", "=", "QPrinter", ".", "HighResolution", ",", "header_font", "=", "self", ".", "get_plugin_font", "(", "'printer_header'", ")", ")", "printDialog", "=", "QPrintDialog", "(", "printer", ",", "editor", ")", "if", "editor", ".", "has_selected_text", "(", ")", ":", "printDialog", ".", "setOption", "(", "QAbstractPrintDialog", ".", "PrintSelection", ",", "True", ")", "self", ".", "redirect_stdio", ".", "emit", "(", "False", ")", "answer", "=", "printDialog", ".", "exec_", "(", ")", "self", ".", "redirect_stdio", ".", "emit", "(", "True", ")", "if", "answer", "==", "QDialog", ".", "Accepted", ":", "self", ".", "starting_long_process", "(", "_", "(", "\"Printing...\"", ")", ")", "printer", ".", "setDocName", "(", "filename", ")", "editor", ".", "print_", "(", "printer", ")", "self", ".", "ending_long_process", "(", ")" ]
Print current file
[ "Print", "current", "file" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1831-L1847
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.print_preview
def print_preview(self): """Print preview for current file""" from qtpy.QtPrintSupport import QPrintPreviewDialog editor = self.get_current_editor() printer = Printer(mode=QPrinter.HighResolution, header_font=self.get_plugin_font('printer_header')) preview = QPrintPreviewDialog(printer, self) preview.setWindowFlags(Qt.Window) preview.paintRequested.connect(lambda printer: editor.print_(printer)) self.redirect_stdio.emit(False) preview.exec_() self.redirect_stdio.emit(True)
python
def print_preview(self): """Print preview for current file""" from qtpy.QtPrintSupport import QPrintPreviewDialog editor = self.get_current_editor() printer = Printer(mode=QPrinter.HighResolution, header_font=self.get_plugin_font('printer_header')) preview = QPrintPreviewDialog(printer, self) preview.setWindowFlags(Qt.Window) preview.paintRequested.connect(lambda printer: editor.print_(printer)) self.redirect_stdio.emit(False) preview.exec_() self.redirect_stdio.emit(True)
[ "def", "print_preview", "(", "self", ")", ":", "from", "qtpy", ".", "QtPrintSupport", "import", "QPrintPreviewDialog", "editor", "=", "self", ".", "get_current_editor", "(", ")", "printer", "=", "Printer", "(", "mode", "=", "QPrinter", ".", "HighResolution", ",", "header_font", "=", "self", ".", "get_plugin_font", "(", "'printer_header'", ")", ")", "preview", "=", "QPrintPreviewDialog", "(", "printer", ",", "self", ")", "preview", ".", "setWindowFlags", "(", "Qt", ".", "Window", ")", "preview", ".", "paintRequested", ".", "connect", "(", "lambda", "printer", ":", "editor", ".", "print_", "(", "printer", ")", ")", "self", ".", "redirect_stdio", ".", "emit", "(", "False", ")", "preview", ".", "exec_", "(", ")", "self", ".", "redirect_stdio", ".", "emit", "(", "True", ")" ]
Print preview for current file
[ "Print", "preview", "for", "current", "file" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1850-L1862
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.save
def save(self, index=None, force=False): """Save file""" editorstack = self.get_current_editorstack() return editorstack.save(index=index, force=force)
python
def save(self, index=None, force=False): """Save file""" editorstack = self.get_current_editorstack() return editorstack.save(index=index, force=force)
[ "def", "save", "(", "self", ",", "index", "=", "None", ",", "force", "=", "False", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "return", "editorstack", ".", "save", "(", "index", "=", "index", ",", "force", "=", "force", ")" ]
Save file
[ "Save", "file" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1875-L1878
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.save_as
def save_as(self): """Save *as* the currently edited file""" editorstack = self.get_current_editorstack() if editorstack.save_as(): fname = editorstack.get_current_filename() self.__add_recent_file(fname)
python
def save_as(self): """Save *as* the currently edited file""" editorstack = self.get_current_editorstack() if editorstack.save_as(): fname = editorstack.get_current_filename() self.__add_recent_file(fname)
[ "def", "save_as", "(", "self", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "editorstack", ".", "save_as", "(", ")", ":", "fname", "=", "editorstack", ".", "get_current_filename", "(", ")", "self", ".", "__add_recent_file", "(", "fname", ")" ]
Save *as* the currently edited file
[ "Save", "*", "as", "*", "the", "currently", "edited", "file" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1881-L1886
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.find
def find(self): """Find slot""" editorstack = self.get_current_editorstack() editorstack.find_widget.show() editorstack.find_widget.search_text.setFocus()
python
def find(self): """Find slot""" editorstack = self.get_current_editorstack() editorstack.find_widget.show() editorstack.find_widget.search_text.setFocus()
[ "def", "find", "(", "self", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "editorstack", ".", "find_widget", ".", "show", "(", ")", "editorstack", ".", "find_widget", ".", "search_text", ".", "setFocus", "(", ")" ]
Find slot
[ "Find", "slot" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1906-L1910
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.open_last_closed
def open_last_closed(self): """ Reopens the last closed tab.""" editorstack = self.get_current_editorstack() last_closed_files = editorstack.get_last_closed_files() if (len(last_closed_files) > 0): file_to_open = last_closed_files[0] last_closed_files.remove(file_to_open) editorstack.set_last_closed_files(last_closed_files) self.load(file_to_open)
python
def open_last_closed(self): """ Reopens the last closed tab.""" editorstack = self.get_current_editorstack() last_closed_files = editorstack.get_last_closed_files() if (len(last_closed_files) > 0): file_to_open = last_closed_files[0] last_closed_files.remove(file_to_open) editorstack.set_last_closed_files(last_closed_files) self.load(file_to_open)
[ "def", "open_last_closed", "(", "self", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "last_closed_files", "=", "editorstack", ".", "get_last_closed_files", "(", ")", "if", "(", "len", "(", "last_closed_files", ")", ">", "0", ")", ":", "file_to_open", "=", "last_closed_files", "[", "0", "]", "last_closed_files", ".", "remove", "(", "file_to_open", ")", "editorstack", ".", "set_last_closed_files", "(", "last_closed_files", ")", "self", ".", "load", "(", "file_to_open", ")" ]
Reopens the last closed tab.
[ "Reopens", "the", "last", "closed", "tab", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1930-L1938
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.close_file_from_name
def close_file_from_name(self, filename): """Close file from its name""" filename = osp.abspath(to_text_string(filename)) index = self.editorstacks[0].has_filename(filename) if index is not None: self.editorstacks[0].close_file(index)
python
def close_file_from_name(self, filename): """Close file from its name""" filename = osp.abspath(to_text_string(filename)) index = self.editorstacks[0].has_filename(filename) if index is not None: self.editorstacks[0].close_file(index)
[ "def", "close_file_from_name", "(", "self", ",", "filename", ")", ":", "filename", "=", "osp", ".", "abspath", "(", "to_text_string", "(", "filename", ")", ")", "index", "=", "self", ".", "editorstacks", "[", "0", "]", ".", "has_filename", "(", "filename", ")", "if", "index", "is", "not", "None", ":", "self", ".", "editorstacks", "[", "0", "]", ".", "close_file", "(", "index", ")" ]
Close file from its name
[ "Close", "file", "from", "its", "name" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1941-L1946
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.removed_tree
def removed_tree(self, dirname): """Directory was removed in project explorer widget""" dirname = osp.abspath(to_text_string(dirname)) for fname in self.get_filenames(): if osp.abspath(fname).startswith(dirname): self.close_file_from_name(fname)
python
def removed_tree(self, dirname): """Directory was removed in project explorer widget""" dirname = osp.abspath(to_text_string(dirname)) for fname in self.get_filenames(): if osp.abspath(fname).startswith(dirname): self.close_file_from_name(fname)
[ "def", "removed_tree", "(", "self", ",", "dirname", ")", ":", "dirname", "=", "osp", ".", "abspath", "(", "to_text_string", "(", "dirname", ")", ")", "for", "fname", "in", "self", ".", "get_filenames", "(", ")", ":", "if", "osp", ".", "abspath", "(", "fname", ")", ".", "startswith", "(", "dirname", ")", ":", "self", ".", "close_file_from_name", "(", "fname", ")" ]
Directory was removed in project explorer widget
[ "Directory", "was", "removed", "in", "project", "explorer", "widget" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1952-L1957
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.renamed
def renamed(self, source, dest): """File was renamed in file explorer widget or in project explorer""" filename = osp.abspath(to_text_string(source)) index = self.editorstacks[0].has_filename(filename) if index is not None: for editorstack in self.editorstacks: editorstack.rename_in_data(filename, new_filename=to_text_string(dest))
python
def renamed(self, source, dest): """File was renamed in file explorer widget or in project explorer""" filename = osp.abspath(to_text_string(source)) index = self.editorstacks[0].has_filename(filename) if index is not None: for editorstack in self.editorstacks: editorstack.rename_in_data(filename, new_filename=to_text_string(dest))
[ "def", "renamed", "(", "self", ",", "source", ",", "dest", ")", ":", "filename", "=", "osp", ".", "abspath", "(", "to_text_string", "(", "source", ")", ")", "index", "=", "self", ".", "editorstacks", "[", "0", "]", ".", "has_filename", "(", "filename", ")", "if", "index", "is", "not", "None", ":", "for", "editorstack", "in", "self", ".", "editorstacks", ":", "editorstack", ".", "rename_in_data", "(", "filename", ",", "new_filename", "=", "to_text_string", "(", "dest", ")", ")" ]
File was renamed in file explorer widget or in project explorer
[ "File", "was", "renamed", "in", "file", "explorer", "widget", "or", "in", "project", "explorer" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1959-L1966
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.renamed_tree
def renamed_tree(self, source, dest): """Directory was renamed in file explorer or in project explorer.""" dirname = osp.abspath(to_text_string(source)) tofile = to_text_string(dest) for fname in self.get_filenames(): if osp.abspath(fname).startswith(dirname): new_filename = fname.replace(dirname, tofile) self.renamed(source=fname, dest=new_filename)
python
def renamed_tree(self, source, dest): """Directory was renamed in file explorer or in project explorer.""" dirname = osp.abspath(to_text_string(source)) tofile = to_text_string(dest) for fname in self.get_filenames(): if osp.abspath(fname).startswith(dirname): new_filename = fname.replace(dirname, tofile) self.renamed(source=fname, dest=new_filename)
[ "def", "renamed_tree", "(", "self", ",", "source", ",", "dest", ")", ":", "dirname", "=", "osp", ".", "abspath", "(", "to_text_string", "(", "source", ")", ")", "tofile", "=", "to_text_string", "(", "dest", ")", "for", "fname", "in", "self", ".", "get_filenames", "(", ")", ":", "if", "osp", ".", "abspath", "(", "fname", ")", ".", "startswith", "(", "dirname", ")", ":", "new_filename", "=", "fname", ".", "replace", "(", "dirname", ",", "tofile", ")", "self", ".", "renamed", "(", "source", "=", "fname", ",", "dest", "=", "new_filename", ")" ]
Directory was renamed in file explorer or in project explorer.
[ "Directory", "was", "renamed", "in", "file", "explorer", "or", "in", "project", "explorer", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1968-L1975
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.run_winpdb
def run_winpdb(self): """Run winpdb to debug current file""" if self.save(): fname = self.get_current_filename() runconf = get_run_configuration(fname) if runconf is None: args = [] wdir = None else: args = runconf.get_arguments().split() wdir = runconf.get_working_directory() # Handle the case where wdir comes back as an empty string # when the working directory dialog checkbox is unchecked. # (subprocess "cwd" default is None, so empty str # must be changed to None in this case.) programs.run_program(WINPDB_PATH, [fname] + args, cwd=wdir or None)
python
def run_winpdb(self): """Run winpdb to debug current file""" if self.save(): fname = self.get_current_filename() runconf = get_run_configuration(fname) if runconf is None: args = [] wdir = None else: args = runconf.get_arguments().split() wdir = runconf.get_working_directory() # Handle the case where wdir comes back as an empty string # when the working directory dialog checkbox is unchecked. # (subprocess "cwd" default is None, so empty str # must be changed to None in this case.) programs.run_program(WINPDB_PATH, [fname] + args, cwd=wdir or None)
[ "def", "run_winpdb", "(", "self", ")", ":", "if", "self", ".", "save", "(", ")", ":", "fname", "=", "self", ".", "get_current_filename", "(", ")", "runconf", "=", "get_run_configuration", "(", "fname", ")", "if", "runconf", "is", "None", ":", "args", "=", "[", "]", "wdir", "=", "None", "else", ":", "args", "=", "runconf", ".", "get_arguments", "(", ")", ".", "split", "(", ")", "wdir", "=", "runconf", ".", "get_working_directory", "(", ")", "# Handle the case where wdir comes back as an empty string\r", "# when the working directory dialog checkbox is unchecked.\r", "# (subprocess \"cwd\" default is None, so empty str\r", "# must be changed to None in this case.)\r", "programs", ".", "run_program", "(", "WINPDB_PATH", ",", "[", "fname", "]", "+", "args", ",", "cwd", "=", "wdir", "or", "None", ")" ]
Run winpdb to debug current file
[ "Run", "winpdb", "to", "debug", "current", "file" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2051-L2066
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.cursor_moved
def cursor_moved(self, filename0, position0, filename1, position1): """Cursor was just moved: 'go to'""" if position0 is not None: self.add_cursor_position_to_history(filename0, position0) self.add_cursor_position_to_history(filename1, position1)
python
def cursor_moved(self, filename0, position0, filename1, position1): """Cursor was just moved: 'go to'""" if position0 is not None: self.add_cursor_position_to_history(filename0, position0) self.add_cursor_position_to_history(filename1, position1)
[ "def", "cursor_moved", "(", "self", ",", "filename0", ",", "position0", ",", "filename1", ",", "position1", ")", ":", "if", "position0", "is", "not", "None", ":", "self", ".", "add_cursor_position_to_history", "(", "filename0", ",", "position0", ")", "self", ".", "add_cursor_position_to_history", "(", "filename1", ",", "position1", ")" ]
Cursor was just moved: 'go to
[ "Cursor", "was", "just", "moved", ":", "go", "to" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2119-L2123
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.go_to_line
def go_to_line(self, line=None): """Open 'go to line' dialog""" editorstack = self.get_current_editorstack() if editorstack is not None: editorstack.go_to_line(line)
python
def go_to_line(self, line=None): """Open 'go to line' dialog""" editorstack = self.get_current_editorstack() if editorstack is not None: editorstack.go_to_line(line)
[ "def", "go_to_line", "(", "self", ",", "line", "=", "None", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "editorstack", "is", "not", "None", ":", "editorstack", ".", "go_to_line", "(", "line", ")" ]
Open 'go to line' dialog
[ "Open", "go", "to", "line", "dialog" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2182-L2186
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.set_or_clear_breakpoint
def set_or_clear_breakpoint(self): """Set/Clear breakpoint""" editorstack = self.get_current_editorstack() if editorstack is not None: self.switch_to_plugin() editorstack.set_or_clear_breakpoint()
python
def set_or_clear_breakpoint(self): """Set/Clear breakpoint""" editorstack = self.get_current_editorstack() if editorstack is not None: self.switch_to_plugin() editorstack.set_or_clear_breakpoint()
[ "def", "set_or_clear_breakpoint", "(", "self", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "editorstack", "is", "not", "None", ":", "self", ".", "switch_to_plugin", "(", ")", "editorstack", ".", "set_or_clear_breakpoint", "(", ")" ]
Set/Clear breakpoint
[ "Set", "/", "Clear", "breakpoint" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2189-L2194
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.set_or_edit_conditional_breakpoint
def set_or_edit_conditional_breakpoint(self): """Set/Edit conditional breakpoint""" editorstack = self.get_current_editorstack() if editorstack is not None: self.switch_to_plugin() editorstack.set_or_edit_conditional_breakpoint()
python
def set_or_edit_conditional_breakpoint(self): """Set/Edit conditional breakpoint""" editorstack = self.get_current_editorstack() if editorstack is not None: self.switch_to_plugin() editorstack.set_or_edit_conditional_breakpoint()
[ "def", "set_or_edit_conditional_breakpoint", "(", "self", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "editorstack", "is", "not", "None", ":", "self", ".", "switch_to_plugin", "(", ")", "editorstack", ".", "set_or_edit_conditional_breakpoint", "(", ")" ]
Set/Edit conditional breakpoint
[ "Set", "/", "Edit", "conditional", "breakpoint" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2197-L2202
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.clear_all_breakpoints
def clear_all_breakpoints(self): """Clear breakpoints in all files""" self.switch_to_plugin() clear_all_breakpoints() self.breakpoints_saved.emit() editorstack = self.get_current_editorstack() if editorstack is not None: for data in editorstack.data: data.editor.debugger.clear_breakpoints() self.refresh_plugin()
python
def clear_all_breakpoints(self): """Clear breakpoints in all files""" self.switch_to_plugin() clear_all_breakpoints() self.breakpoints_saved.emit() editorstack = self.get_current_editorstack() if editorstack is not None: for data in editorstack.data: data.editor.debugger.clear_breakpoints() self.refresh_plugin()
[ "def", "clear_all_breakpoints", "(", "self", ")", ":", "self", ".", "switch_to_plugin", "(", ")", "clear_all_breakpoints", "(", ")", "self", ".", "breakpoints_saved", ".", "emit", "(", ")", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "editorstack", "is", "not", "None", ":", "for", "data", "in", "editorstack", ".", "data", ":", "data", ".", "editor", ".", "debugger", ".", "clear_breakpoints", "(", ")", "self", ".", "refresh_plugin", "(", ")" ]
Clear breakpoints in all files
[ "Clear", "breakpoints", "in", "all", "files" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2205-L2214
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.clear_breakpoint
def clear_breakpoint(self, filename, lineno): """Remove a single breakpoint""" clear_breakpoint(filename, lineno) self.breakpoints_saved.emit() editorstack = self.get_current_editorstack() if editorstack is not None: index = self.is_file_opened(filename) if index is not None: editorstack.data[index].editor.debugger.toogle_breakpoint( lineno)
python
def clear_breakpoint(self, filename, lineno): """Remove a single breakpoint""" clear_breakpoint(filename, lineno) self.breakpoints_saved.emit() editorstack = self.get_current_editorstack() if editorstack is not None: index = self.is_file_opened(filename) if index is not None: editorstack.data[index].editor.debugger.toogle_breakpoint( lineno)
[ "def", "clear_breakpoint", "(", "self", ",", "filename", ",", "lineno", ")", ":", "clear_breakpoint", "(", "filename", ",", "lineno", ")", "self", ".", "breakpoints_saved", ".", "emit", "(", ")", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "editorstack", "is", "not", "None", ":", "index", "=", "self", ".", "is_file_opened", "(", "filename", ")", "if", "index", "is", "not", "None", ":", "editorstack", ".", "data", "[", "index", "]", ".", "editor", ".", "debugger", ".", "toogle_breakpoint", "(", "lineno", ")" ]
Remove a single breakpoint
[ "Remove", "a", "single", "breakpoint" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2216-L2225
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.debug_command
def debug_command(self, command): """Debug actions""" self.switch_to_plugin() self.main.ipyconsole.write_to_stdin(command) focus_widget = self.main.ipyconsole.get_focus_widget() if focus_widget: focus_widget.setFocus()
python
def debug_command(self, command): """Debug actions""" self.switch_to_plugin() self.main.ipyconsole.write_to_stdin(command) focus_widget = self.main.ipyconsole.get_focus_widget() if focus_widget: focus_widget.setFocus()
[ "def", "debug_command", "(", "self", ",", "command", ")", ":", "self", ".", "switch_to_plugin", "(", ")", "self", ".", "main", ".", "ipyconsole", ".", "write_to_stdin", "(", "command", ")", "focus_widget", "=", "self", ".", "main", ".", "ipyconsole", ".", "get_focus_widget", "(", ")", "if", "focus_widget", ":", "focus_widget", ".", "setFocus", "(", ")" ]
Debug actions
[ "Debug", "actions" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2227-L2233
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.run_file
def run_file(self, debug=False): """Run script inside current interpreter or in a new one""" editorstack = self.get_current_editorstack() if editorstack.save(): editor = self.get_current_editor() fname = osp.abspath(self.get_current_filename()) # Get fname's dirname before we escape the single and double # quotes (Fixes Issue #6771) dirname = osp.dirname(fname) # Escape single and double quotes in fname and dirname # (Fixes Issue #2158) fname = fname.replace("'", r"\'").replace('"', r'\"') dirname = dirname.replace("'", r"\'").replace('"', r'\"') runconf = get_run_configuration(fname) if runconf is None: dialog = RunConfigOneDialog(self) dialog.size_change.connect(lambda s: self.set_dialog_size(s)) if self.dialog_size is not None: dialog.resize(self.dialog_size) dialog.setup(fname) if CONF.get('run', 'open_at_least_once', not running_under_pytest()): # Open Run Config dialog at least once: the first time # a script is ever run in Spyder, so that the user may # see it at least once and be conscious that it exists show_dlg = True CONF.set('run', 'open_at_least_once', False) else: # Open Run Config dialog only # if ALWAYS_OPEN_FIRST_RUN_OPTION option is enabled show_dlg = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION) if show_dlg and not dialog.exec_(): return runconf = dialog.get_configuration() args = runconf.get_arguments() python_args = runconf.get_python_arguments() interact = runconf.interact post_mortem = runconf.post_mortem current = runconf.current systerm = runconf.systerm clear_namespace = runconf.clear_namespace if runconf.file_dir: wdir = dirname elif runconf.cw_dir: wdir = '' elif osp.isdir(runconf.dir): wdir = runconf.dir else: wdir = '' python = True # Note: in the future, it may be useful to run # something in a terminal instead of a Python interp. self.__last_ec_exec = (fname, wdir, args, interact, debug, python, python_args, current, systerm, post_mortem, clear_namespace) self.re_run_file() if not interact and not debug: # If external console dockwidget is hidden, it will be # raised in top-level and so focus will be given to the # current external shell automatically # (see SpyderPluginWidget.visibility_changed method) editor.setFocus()
python
def run_file(self, debug=False): """Run script inside current interpreter or in a new one""" editorstack = self.get_current_editorstack() if editorstack.save(): editor = self.get_current_editor() fname = osp.abspath(self.get_current_filename()) # Get fname's dirname before we escape the single and double # quotes (Fixes Issue #6771) dirname = osp.dirname(fname) # Escape single and double quotes in fname and dirname # (Fixes Issue #2158) fname = fname.replace("'", r"\'").replace('"', r'\"') dirname = dirname.replace("'", r"\'").replace('"', r'\"') runconf = get_run_configuration(fname) if runconf is None: dialog = RunConfigOneDialog(self) dialog.size_change.connect(lambda s: self.set_dialog_size(s)) if self.dialog_size is not None: dialog.resize(self.dialog_size) dialog.setup(fname) if CONF.get('run', 'open_at_least_once', not running_under_pytest()): # Open Run Config dialog at least once: the first time # a script is ever run in Spyder, so that the user may # see it at least once and be conscious that it exists show_dlg = True CONF.set('run', 'open_at_least_once', False) else: # Open Run Config dialog only # if ALWAYS_OPEN_FIRST_RUN_OPTION option is enabled show_dlg = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION) if show_dlg and not dialog.exec_(): return runconf = dialog.get_configuration() args = runconf.get_arguments() python_args = runconf.get_python_arguments() interact = runconf.interact post_mortem = runconf.post_mortem current = runconf.current systerm = runconf.systerm clear_namespace = runconf.clear_namespace if runconf.file_dir: wdir = dirname elif runconf.cw_dir: wdir = '' elif osp.isdir(runconf.dir): wdir = runconf.dir else: wdir = '' python = True # Note: in the future, it may be useful to run # something in a terminal instead of a Python interp. self.__last_ec_exec = (fname, wdir, args, interact, debug, python, python_args, current, systerm, post_mortem, clear_namespace) self.re_run_file() if not interact and not debug: # If external console dockwidget is hidden, it will be # raised in top-level and so focus will be given to the # current external shell automatically # (see SpyderPluginWidget.visibility_changed method) editor.setFocus()
[ "def", "run_file", "(", "self", ",", "debug", "=", "False", ")", ":", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "editorstack", ".", "save", "(", ")", ":", "editor", "=", "self", ".", "get_current_editor", "(", ")", "fname", "=", "osp", ".", "abspath", "(", "self", ".", "get_current_filename", "(", ")", ")", "# Get fname's dirname before we escape the single and double\r", "# quotes (Fixes Issue #6771)\r", "dirname", "=", "osp", ".", "dirname", "(", "fname", ")", "# Escape single and double quotes in fname and dirname\r", "# (Fixes Issue #2158)\r", "fname", "=", "fname", ".", "replace", "(", "\"'\"", ",", "r\"\\'\"", ")", ".", "replace", "(", "'\"'", ",", "r'\\\"'", ")", "dirname", "=", "dirname", ".", "replace", "(", "\"'\"", ",", "r\"\\'\"", ")", ".", "replace", "(", "'\"'", ",", "r'\\\"'", ")", "runconf", "=", "get_run_configuration", "(", "fname", ")", "if", "runconf", "is", "None", ":", "dialog", "=", "RunConfigOneDialog", "(", "self", ")", "dialog", ".", "size_change", ".", "connect", "(", "lambda", "s", ":", "self", ".", "set_dialog_size", "(", "s", ")", ")", "if", "self", ".", "dialog_size", "is", "not", "None", ":", "dialog", ".", "resize", "(", "self", ".", "dialog_size", ")", "dialog", ".", "setup", "(", "fname", ")", "if", "CONF", ".", "get", "(", "'run'", ",", "'open_at_least_once'", ",", "not", "running_under_pytest", "(", ")", ")", ":", "# Open Run Config dialog at least once: the first time\r", "# a script is ever run in Spyder, so that the user may\r", "# see it at least once and be conscious that it exists\r", "show_dlg", "=", "True", "CONF", ".", "set", "(", "'run'", ",", "'open_at_least_once'", ",", "False", ")", "else", ":", "# Open Run Config dialog only\r", "# if ALWAYS_OPEN_FIRST_RUN_OPTION option is enabled\r", "show_dlg", "=", "CONF", ".", "get", "(", "'run'", ",", "ALWAYS_OPEN_FIRST_RUN_OPTION", ")", "if", "show_dlg", "and", "not", "dialog", ".", "exec_", "(", ")", ":", "return", "runconf", "=", "dialog", ".", "get_configuration", "(", ")", "args", "=", "runconf", ".", "get_arguments", "(", ")", "python_args", "=", "runconf", ".", "get_python_arguments", "(", ")", "interact", "=", "runconf", ".", "interact", "post_mortem", "=", "runconf", ".", "post_mortem", "current", "=", "runconf", ".", "current", "systerm", "=", "runconf", ".", "systerm", "clear_namespace", "=", "runconf", ".", "clear_namespace", "if", "runconf", ".", "file_dir", ":", "wdir", "=", "dirname", "elif", "runconf", ".", "cw_dir", ":", "wdir", "=", "''", "elif", "osp", ".", "isdir", "(", "runconf", ".", "dir", ")", ":", "wdir", "=", "runconf", ".", "dir", "else", ":", "wdir", "=", "''", "python", "=", "True", "# Note: in the future, it may be useful to run\r", "# something in a terminal instead of a Python interp.\r", "self", ".", "__last_ec_exec", "=", "(", "fname", ",", "wdir", ",", "args", ",", "interact", ",", "debug", ",", "python", ",", "python_args", ",", "current", ",", "systerm", ",", "post_mortem", ",", "clear_namespace", ")", "self", ".", "re_run_file", "(", ")", "if", "not", "interact", "and", "not", "debug", ":", "# If external console dockwidget is hidden, it will be\r", "# raised in top-level and so focus will be given to the\r", "# current external shell automatically\r", "# (see SpyderPluginWidget.visibility_changed method)\r", "editor", ".", "setFocus", "(", ")" ]
Run script inside current interpreter or in a new one
[ "Run", "script", "inside", "current", "interpreter", "or", "in", "a", "new", "one" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2251-L2317
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.debug_file
def debug_file(self): """Debug current script""" self.switch_to_plugin() current_editor = self.get_current_editor() if current_editor is not None: current_editor.sig_debug_start.emit() self.run_file(debug=True)
python
def debug_file(self): """Debug current script""" self.switch_to_plugin() current_editor = self.get_current_editor() if current_editor is not None: current_editor.sig_debug_start.emit() self.run_file(debug=True)
[ "def", "debug_file", "(", "self", ")", ":", "self", ".", "switch_to_plugin", "(", ")", "current_editor", "=", "self", ".", "get_current_editor", "(", ")", "if", "current_editor", "is", "not", "None", ":", "current_editor", ".", "sig_debug_start", ".", "emit", "(", ")", "self", ".", "run_file", "(", "debug", "=", "True", ")" ]
Debug current script
[ "Debug", "current", "script" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2323-L2329
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.re_run_file
def re_run_file(self): """Re-run last script""" if self.get_option('save_all_before_run'): self.save_all() if self.__last_ec_exec is None: return (fname, wdir, args, interact, debug, python, python_args, current, systerm, post_mortem, clear_namespace) = self.__last_ec_exec if not systerm: self.run_in_current_ipyclient.emit(fname, wdir, args, debug, post_mortem, current, clear_namespace) else: self.main.open_external_console(fname, wdir, args, interact, debug, python, python_args, systerm, post_mortem)
python
def re_run_file(self): """Re-run last script""" if self.get_option('save_all_before_run'): self.save_all() if self.__last_ec_exec is None: return (fname, wdir, args, interact, debug, python, python_args, current, systerm, post_mortem, clear_namespace) = self.__last_ec_exec if not systerm: self.run_in_current_ipyclient.emit(fname, wdir, args, debug, post_mortem, current, clear_namespace) else: self.main.open_external_console(fname, wdir, args, interact, debug, python, python_args, systerm, post_mortem)
[ "def", "re_run_file", "(", "self", ")", ":", "if", "self", ".", "get_option", "(", "'save_all_before_run'", ")", ":", "self", ".", "save_all", "(", ")", "if", "self", ".", "__last_ec_exec", "is", "None", ":", "return", "(", "fname", ",", "wdir", ",", "args", ",", "interact", ",", "debug", ",", "python", ",", "python_args", ",", "current", ",", "systerm", ",", "post_mortem", ",", "clear_namespace", ")", "=", "self", ".", "__last_ec_exec", "if", "not", "systerm", ":", "self", ".", "run_in_current_ipyclient", ".", "emit", "(", "fname", ",", "wdir", ",", "args", ",", "debug", ",", "post_mortem", ",", "current", ",", "clear_namespace", ")", "else", ":", "self", ".", "main", ".", "open_external_console", "(", "fname", ",", "wdir", ",", "args", ",", "interact", ",", "debug", ",", "python", ",", "python_args", ",", "systerm", ",", "post_mortem", ")" ]
Re-run last script
[ "Re", "-", "run", "last", "script" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2332-L2348
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.save_bookmark
def save_bookmark(self, slot_num): """Save current line and position as bookmark.""" bookmarks = CONF.get('editor', 'bookmarks') editorstack = self.get_current_editorstack() if slot_num in bookmarks: filename, line_num, column = bookmarks[slot_num] if osp.isfile(filename): index = editorstack.has_filename(filename) if index is not None: block = (editorstack.tabs.widget(index).document() .findBlockByNumber(line_num)) block.userData().bookmarks.remove((slot_num, column)) if editorstack is not None: self.switch_to_plugin() editorstack.set_bookmark(slot_num)
python
def save_bookmark(self, slot_num): """Save current line and position as bookmark.""" bookmarks = CONF.get('editor', 'bookmarks') editorstack = self.get_current_editorstack() if slot_num in bookmarks: filename, line_num, column = bookmarks[slot_num] if osp.isfile(filename): index = editorstack.has_filename(filename) if index is not None: block = (editorstack.tabs.widget(index).document() .findBlockByNumber(line_num)) block.userData().bookmarks.remove((slot_num, column)) if editorstack is not None: self.switch_to_plugin() editorstack.set_bookmark(slot_num)
[ "def", "save_bookmark", "(", "self", ",", "slot_num", ")", ":", "bookmarks", "=", "CONF", ".", "get", "(", "'editor'", ",", "'bookmarks'", ")", "editorstack", "=", "self", ".", "get_current_editorstack", "(", ")", "if", "slot_num", "in", "bookmarks", ":", "filename", ",", "line_num", ",", "column", "=", "bookmarks", "[", "slot_num", "]", "if", "osp", ".", "isfile", "(", "filename", ")", ":", "index", "=", "editorstack", ".", "has_filename", "(", "filename", ")", "if", "index", "is", "not", "None", ":", "block", "=", "(", "editorstack", ".", "tabs", ".", "widget", "(", "index", ")", ".", "document", "(", ")", ".", "findBlockByNumber", "(", "line_num", ")", ")", "block", ".", "userData", "(", ")", ".", "bookmarks", ".", "remove", "(", "(", "slot_num", ",", "column", ")", ")", "if", "editorstack", "is", "not", "None", ":", "self", ".", "switch_to_plugin", "(", ")", "editorstack", ".", "set_bookmark", "(", "slot_num", ")" ]
Save current line and position as bookmark.
[ "Save", "current", "line", "and", "position", "as", "bookmark", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2376-L2390
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.load_bookmark
def load_bookmark(self, slot_num): """Set cursor to bookmarked file and position.""" bookmarks = CONF.get('editor', 'bookmarks') if slot_num in bookmarks: filename, line_num, column = bookmarks[slot_num] else: return if not osp.isfile(filename): self.last_edit_cursor_pos = None return self.load(filename) editor = self.get_current_editor() if line_num < editor.document().lineCount(): linelength = len(editor.document() .findBlockByNumber(line_num).text()) if column <= linelength: editor.go_to_line(line_num + 1, column) else: # Last column editor.go_to_line(line_num + 1, linelength)
python
def load_bookmark(self, slot_num): """Set cursor to bookmarked file and position.""" bookmarks = CONF.get('editor', 'bookmarks') if slot_num in bookmarks: filename, line_num, column = bookmarks[slot_num] else: return if not osp.isfile(filename): self.last_edit_cursor_pos = None return self.load(filename) editor = self.get_current_editor() if line_num < editor.document().lineCount(): linelength = len(editor.document() .findBlockByNumber(line_num).text()) if column <= linelength: editor.go_to_line(line_num + 1, column) else: # Last column editor.go_to_line(line_num + 1, linelength)
[ "def", "load_bookmark", "(", "self", ",", "slot_num", ")", ":", "bookmarks", "=", "CONF", ".", "get", "(", "'editor'", ",", "'bookmarks'", ")", "if", "slot_num", "in", "bookmarks", ":", "filename", ",", "line_num", ",", "column", "=", "bookmarks", "[", "slot_num", "]", "else", ":", "return", "if", "not", "osp", ".", "isfile", "(", "filename", ")", ":", "self", ".", "last_edit_cursor_pos", "=", "None", "return", "self", ".", "load", "(", "filename", ")", "editor", "=", "self", ".", "get_current_editor", "(", ")", "if", "line_num", "<", "editor", ".", "document", "(", ")", ".", "lineCount", "(", ")", ":", "linelength", "=", "len", "(", "editor", ".", "document", "(", ")", ".", "findBlockByNumber", "(", "line_num", ")", ".", "text", "(", ")", ")", "if", "column", "<=", "linelength", ":", "editor", ".", "go_to_line", "(", "line_num", "+", "1", ",", "column", ")", "else", ":", "# Last column\r", "editor", ".", "go_to_line", "(", "line_num", "+", "1", ",", "linelength", ")" ]
Set cursor to bookmarked file and position.
[ "Set", "cursor", "to", "bookmarked", "file", "and", "position", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2393-L2412
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.zoom
def zoom(self, factor): """Zoom in/out/reset""" editor = self.get_current_editorstack().get_current_editor() if factor == 0: font = self.get_plugin_font() editor.set_font(font) else: font = editor.font() size = font.pointSize() + factor if size > 0: font.setPointSize(size) editor.set_font(font) editor.update_tab_stop_width_spaces()
python
def zoom(self, factor): """Zoom in/out/reset""" editor = self.get_current_editorstack().get_current_editor() if factor == 0: font = self.get_plugin_font() editor.set_font(font) else: font = editor.font() size = font.pointSize() + factor if size > 0: font.setPointSize(size) editor.set_font(font) editor.update_tab_stop_width_spaces()
[ "def", "zoom", "(", "self", ",", "factor", ")", ":", "editor", "=", "self", ".", "get_current_editorstack", "(", ")", ".", "get_current_editor", "(", ")", "if", "factor", "==", "0", ":", "font", "=", "self", ".", "get_plugin_font", "(", ")", "editor", ".", "set_font", "(", "font", ")", "else", ":", "font", "=", "editor", ".", "font", "(", ")", "size", "=", "font", ".", "pointSize", "(", ")", "+", "factor", "if", "size", ">", "0", ":", "font", ".", "setPointSize", "(", "size", ")", "editor", ".", "set_font", "(", "font", ")", "editor", ".", "update_tab_stop_width_spaces", "(", ")" ]
Zoom in/out/reset
[ "Zoom", "in", "/", "out", "/", "reset" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2415-L2427
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.apply_plugin_settings
def apply_plugin_settings(self, options): """Apply configuration file's plugin settings""" if self.editorstacks is not None: # --- syntax highlight and text rendering settings color_scheme_n = 'color_scheme_name' color_scheme_o = self.get_color_scheme() currentline_n = 'highlight_current_line' currentline_o = self.get_option(currentline_n) currentcell_n = 'highlight_current_cell' currentcell_o = self.get_option(currentcell_n) occurrence_n = 'occurrence_highlighting' occurrence_o = self.get_option(occurrence_n) occurrence_timeout_n = 'occurrence_highlighting/timeout' occurrence_timeout_o = self.get_option(occurrence_timeout_n) focus_to_editor_n = 'focus_to_editor' focus_to_editor_o = self.get_option(focus_to_editor_n) for editorstack in self.editorstacks: if color_scheme_n in options: editorstack.set_color_scheme(color_scheme_o) if currentline_n in options: editorstack.set_highlight_current_line_enabled( currentline_o) if currentcell_n in options: editorstack.set_highlight_current_cell_enabled( currentcell_o) if occurrence_n in options: editorstack.set_occurrence_highlighting_enabled(occurrence_o) if occurrence_timeout_n in options: editorstack.set_occurrence_highlighting_timeout( occurrence_timeout_o) if focus_to_editor_n in options: editorstack.set_focus_to_editor(focus_to_editor_o) # --- everything else tabbar_n = 'show_tab_bar' tabbar_o = self.get_option(tabbar_n) classfuncdropdown_n = 'show_class_func_dropdown' classfuncdropdown_o = self.get_option(classfuncdropdown_n) linenb_n = 'line_numbers' linenb_o = self.get_option(linenb_n) blanks_n = 'blank_spaces' blanks_o = self.get_option(blanks_n) scrollpastend_n = 'scroll_past_end' scrollpastend_o = self.get_option(scrollpastend_n) edgeline_n = 'edge_line' edgeline_o = self.get_option(edgeline_n) edgelinecols_n = 'edge_line_columns' edgelinecols_o = self.get_option(edgelinecols_n) wrap_n = 'wrap' wrap_o = self.get_option(wrap_n) indentguides_n = 'indent_guides' indentguides_o = self.get_option(indentguides_n) tabindent_n = 'tab_always_indent' tabindent_o = self.get_option(tabindent_n) ibackspace_n = 'intelligent_backspace' ibackspace_o = self.get_option(ibackspace_n) removetrail_n = 'always_remove_trailing_spaces' removetrail_o = self.get_option(removetrail_n) converteol_n = 'convert_eol_on_save' converteol_o = self.get_option(converteol_n) converteolto_n = 'convert_eol_on_save_to' converteolto_o = self.get_option(converteolto_n) runcellcopy_n = 'run_cell_copy' runcellcopy_o = self.get_option(runcellcopy_n) closepar_n = 'close_parentheses' closepar_o = self.get_option(closepar_n) close_quotes_n = 'close_quotes' close_quotes_o = self.get_option(close_quotes_n) add_colons_n = 'add_colons' add_colons_o = self.get_option(add_colons_n) autounindent_n = 'auto_unindent' autounindent_o = self.get_option(autounindent_n) indent_chars_n = 'indent_chars' indent_chars_o = self.get_option(indent_chars_n) tab_stop_width_spaces_n = 'tab_stop_width_spaces' tab_stop_width_spaces_o = self.get_option(tab_stop_width_spaces_n) help_n = 'connect_to_oi' help_o = CONF.get('help', 'connect/editor') todo_n = 'todo_list' todo_o = self.get_option(todo_n) finfo = self.get_current_finfo() for editorstack in self.editorstacks: if tabbar_n in options: editorstack.set_tabbar_visible(tabbar_o) if linenb_n in options: editorstack.set_linenumbers_enabled(linenb_o, current_finfo=finfo) if edgeline_n in options: editorstack.set_edgeline_enabled(edgeline_o) if edgelinecols_n in options: editorstack.set_edgeline_columns(edgelinecols_o) if wrap_n in options: editorstack.set_wrap_enabled(wrap_o) if tabindent_n in options: editorstack.set_tabmode_enabled(tabindent_o) if ibackspace_n in options: editorstack.set_intelligent_backspace_enabled(ibackspace_o) if removetrail_n in options: editorstack.set_always_remove_trailing_spaces(removetrail_o) if converteol_n in options: editorstack.set_convert_eol_on_save(converteol_o) if converteolto_n in options: editorstack.set_convert_eol_on_save_to(converteolto_o) if runcellcopy_n in options: editorstack.set_run_cell_copy(runcellcopy_o) if closepar_n in options: editorstack.set_close_parentheses_enabled(closepar_o) if close_quotes_n in options: editorstack.set_close_quotes_enabled(close_quotes_o) if add_colons_n in options: editorstack.set_add_colons_enabled(add_colons_o) if autounindent_n in options: editorstack.set_auto_unindent_enabled(autounindent_o) if indent_chars_n in options: editorstack.set_indent_chars(indent_chars_o) if tab_stop_width_spaces_n in options: editorstack.set_tab_stop_width_spaces(tab_stop_width_spaces_o) if help_n in options: editorstack.set_help_enabled(help_o) if todo_n in options: editorstack.set_todolist_enabled(todo_o, current_finfo=finfo) for name, action in self.checkable_actions.items(): if name in options: state = self.get_option(name) action.setChecked(state) action.trigger() # Multiply by 1000 to convert seconds to milliseconds self.autosave.interval = ( self.get_option('autosave_interval') * 1000) self.autosave.enabled = self.get_option('autosave_enabled') # We must update the current editor after the others: # (otherwise, code analysis buttons state would correspond to the # last editor instead of showing the one of the current editor) if finfo is not None: # TODO: Connect this to the LSP if todo_n in options and todo_o: finfo.run_todo_finder()
python
def apply_plugin_settings(self, options): """Apply configuration file's plugin settings""" if self.editorstacks is not None: # --- syntax highlight and text rendering settings color_scheme_n = 'color_scheme_name' color_scheme_o = self.get_color_scheme() currentline_n = 'highlight_current_line' currentline_o = self.get_option(currentline_n) currentcell_n = 'highlight_current_cell' currentcell_o = self.get_option(currentcell_n) occurrence_n = 'occurrence_highlighting' occurrence_o = self.get_option(occurrence_n) occurrence_timeout_n = 'occurrence_highlighting/timeout' occurrence_timeout_o = self.get_option(occurrence_timeout_n) focus_to_editor_n = 'focus_to_editor' focus_to_editor_o = self.get_option(focus_to_editor_n) for editorstack in self.editorstacks: if color_scheme_n in options: editorstack.set_color_scheme(color_scheme_o) if currentline_n in options: editorstack.set_highlight_current_line_enabled( currentline_o) if currentcell_n in options: editorstack.set_highlight_current_cell_enabled( currentcell_o) if occurrence_n in options: editorstack.set_occurrence_highlighting_enabled(occurrence_o) if occurrence_timeout_n in options: editorstack.set_occurrence_highlighting_timeout( occurrence_timeout_o) if focus_to_editor_n in options: editorstack.set_focus_to_editor(focus_to_editor_o) # --- everything else tabbar_n = 'show_tab_bar' tabbar_o = self.get_option(tabbar_n) classfuncdropdown_n = 'show_class_func_dropdown' classfuncdropdown_o = self.get_option(classfuncdropdown_n) linenb_n = 'line_numbers' linenb_o = self.get_option(linenb_n) blanks_n = 'blank_spaces' blanks_o = self.get_option(blanks_n) scrollpastend_n = 'scroll_past_end' scrollpastend_o = self.get_option(scrollpastend_n) edgeline_n = 'edge_line' edgeline_o = self.get_option(edgeline_n) edgelinecols_n = 'edge_line_columns' edgelinecols_o = self.get_option(edgelinecols_n) wrap_n = 'wrap' wrap_o = self.get_option(wrap_n) indentguides_n = 'indent_guides' indentguides_o = self.get_option(indentguides_n) tabindent_n = 'tab_always_indent' tabindent_o = self.get_option(tabindent_n) ibackspace_n = 'intelligent_backspace' ibackspace_o = self.get_option(ibackspace_n) removetrail_n = 'always_remove_trailing_spaces' removetrail_o = self.get_option(removetrail_n) converteol_n = 'convert_eol_on_save' converteol_o = self.get_option(converteol_n) converteolto_n = 'convert_eol_on_save_to' converteolto_o = self.get_option(converteolto_n) runcellcopy_n = 'run_cell_copy' runcellcopy_o = self.get_option(runcellcopy_n) closepar_n = 'close_parentheses' closepar_o = self.get_option(closepar_n) close_quotes_n = 'close_quotes' close_quotes_o = self.get_option(close_quotes_n) add_colons_n = 'add_colons' add_colons_o = self.get_option(add_colons_n) autounindent_n = 'auto_unindent' autounindent_o = self.get_option(autounindent_n) indent_chars_n = 'indent_chars' indent_chars_o = self.get_option(indent_chars_n) tab_stop_width_spaces_n = 'tab_stop_width_spaces' tab_stop_width_spaces_o = self.get_option(tab_stop_width_spaces_n) help_n = 'connect_to_oi' help_o = CONF.get('help', 'connect/editor') todo_n = 'todo_list' todo_o = self.get_option(todo_n) finfo = self.get_current_finfo() for editorstack in self.editorstacks: if tabbar_n in options: editorstack.set_tabbar_visible(tabbar_o) if linenb_n in options: editorstack.set_linenumbers_enabled(linenb_o, current_finfo=finfo) if edgeline_n in options: editorstack.set_edgeline_enabled(edgeline_o) if edgelinecols_n in options: editorstack.set_edgeline_columns(edgelinecols_o) if wrap_n in options: editorstack.set_wrap_enabled(wrap_o) if tabindent_n in options: editorstack.set_tabmode_enabled(tabindent_o) if ibackspace_n in options: editorstack.set_intelligent_backspace_enabled(ibackspace_o) if removetrail_n in options: editorstack.set_always_remove_trailing_spaces(removetrail_o) if converteol_n in options: editorstack.set_convert_eol_on_save(converteol_o) if converteolto_n in options: editorstack.set_convert_eol_on_save_to(converteolto_o) if runcellcopy_n in options: editorstack.set_run_cell_copy(runcellcopy_o) if closepar_n in options: editorstack.set_close_parentheses_enabled(closepar_o) if close_quotes_n in options: editorstack.set_close_quotes_enabled(close_quotes_o) if add_colons_n in options: editorstack.set_add_colons_enabled(add_colons_o) if autounindent_n in options: editorstack.set_auto_unindent_enabled(autounindent_o) if indent_chars_n in options: editorstack.set_indent_chars(indent_chars_o) if tab_stop_width_spaces_n in options: editorstack.set_tab_stop_width_spaces(tab_stop_width_spaces_o) if help_n in options: editorstack.set_help_enabled(help_o) if todo_n in options: editorstack.set_todolist_enabled(todo_o, current_finfo=finfo) for name, action in self.checkable_actions.items(): if name in options: state = self.get_option(name) action.setChecked(state) action.trigger() # Multiply by 1000 to convert seconds to milliseconds self.autosave.interval = ( self.get_option('autosave_interval') * 1000) self.autosave.enabled = self.get_option('autosave_enabled') # We must update the current editor after the others: # (otherwise, code analysis buttons state would correspond to the # last editor instead of showing the one of the current editor) if finfo is not None: # TODO: Connect this to the LSP if todo_n in options and todo_o: finfo.run_todo_finder()
[ "def", "apply_plugin_settings", "(", "self", ",", "options", ")", ":", "if", "self", ".", "editorstacks", "is", "not", "None", ":", "# --- syntax highlight and text rendering settings\r", "color_scheme_n", "=", "'color_scheme_name'", "color_scheme_o", "=", "self", ".", "get_color_scheme", "(", ")", "currentline_n", "=", "'highlight_current_line'", "currentline_o", "=", "self", ".", "get_option", "(", "currentline_n", ")", "currentcell_n", "=", "'highlight_current_cell'", "currentcell_o", "=", "self", ".", "get_option", "(", "currentcell_n", ")", "occurrence_n", "=", "'occurrence_highlighting'", "occurrence_o", "=", "self", ".", "get_option", "(", "occurrence_n", ")", "occurrence_timeout_n", "=", "'occurrence_highlighting/timeout'", "occurrence_timeout_o", "=", "self", ".", "get_option", "(", "occurrence_timeout_n", ")", "focus_to_editor_n", "=", "'focus_to_editor'", "focus_to_editor_o", "=", "self", ".", "get_option", "(", "focus_to_editor_n", ")", "for", "editorstack", "in", "self", ".", "editorstacks", ":", "if", "color_scheme_n", "in", "options", ":", "editorstack", ".", "set_color_scheme", "(", "color_scheme_o", ")", "if", "currentline_n", "in", "options", ":", "editorstack", ".", "set_highlight_current_line_enabled", "(", "currentline_o", ")", "if", "currentcell_n", "in", "options", ":", "editorstack", ".", "set_highlight_current_cell_enabled", "(", "currentcell_o", ")", "if", "occurrence_n", "in", "options", ":", "editorstack", ".", "set_occurrence_highlighting_enabled", "(", "occurrence_o", ")", "if", "occurrence_timeout_n", "in", "options", ":", "editorstack", ".", "set_occurrence_highlighting_timeout", "(", "occurrence_timeout_o", ")", "if", "focus_to_editor_n", "in", "options", ":", "editorstack", ".", "set_focus_to_editor", "(", "focus_to_editor_o", ")", "# --- everything else\r", "tabbar_n", "=", "'show_tab_bar'", "tabbar_o", "=", "self", ".", "get_option", "(", "tabbar_n", ")", "classfuncdropdown_n", "=", "'show_class_func_dropdown'", "classfuncdropdown_o", "=", "self", ".", "get_option", "(", "classfuncdropdown_n", ")", "linenb_n", "=", "'line_numbers'", "linenb_o", "=", "self", ".", "get_option", "(", "linenb_n", ")", "blanks_n", "=", "'blank_spaces'", "blanks_o", "=", "self", ".", "get_option", "(", "blanks_n", ")", "scrollpastend_n", "=", "'scroll_past_end'", "scrollpastend_o", "=", "self", ".", "get_option", "(", "scrollpastend_n", ")", "edgeline_n", "=", "'edge_line'", "edgeline_o", "=", "self", ".", "get_option", "(", "edgeline_n", ")", "edgelinecols_n", "=", "'edge_line_columns'", "edgelinecols_o", "=", "self", ".", "get_option", "(", "edgelinecols_n", ")", "wrap_n", "=", "'wrap'", "wrap_o", "=", "self", ".", "get_option", "(", "wrap_n", ")", "indentguides_n", "=", "'indent_guides'", "indentguides_o", "=", "self", ".", "get_option", "(", "indentguides_n", ")", "tabindent_n", "=", "'tab_always_indent'", "tabindent_o", "=", "self", ".", "get_option", "(", "tabindent_n", ")", "ibackspace_n", "=", "'intelligent_backspace'", "ibackspace_o", "=", "self", ".", "get_option", "(", "ibackspace_n", ")", "removetrail_n", "=", "'always_remove_trailing_spaces'", "removetrail_o", "=", "self", ".", "get_option", "(", "removetrail_n", ")", "converteol_n", "=", "'convert_eol_on_save'", "converteol_o", "=", "self", ".", "get_option", "(", "converteol_n", ")", "converteolto_n", "=", "'convert_eol_on_save_to'", "converteolto_o", "=", "self", ".", "get_option", "(", "converteolto_n", ")", "runcellcopy_n", "=", "'run_cell_copy'", "runcellcopy_o", "=", "self", ".", "get_option", "(", "runcellcopy_n", ")", "closepar_n", "=", "'close_parentheses'", "closepar_o", "=", "self", ".", "get_option", "(", "closepar_n", ")", "close_quotes_n", "=", "'close_quotes'", "close_quotes_o", "=", "self", ".", "get_option", "(", "close_quotes_n", ")", "add_colons_n", "=", "'add_colons'", "add_colons_o", "=", "self", ".", "get_option", "(", "add_colons_n", ")", "autounindent_n", "=", "'auto_unindent'", "autounindent_o", "=", "self", ".", "get_option", "(", "autounindent_n", ")", "indent_chars_n", "=", "'indent_chars'", "indent_chars_o", "=", "self", ".", "get_option", "(", "indent_chars_n", ")", "tab_stop_width_spaces_n", "=", "'tab_stop_width_spaces'", "tab_stop_width_spaces_o", "=", "self", ".", "get_option", "(", "tab_stop_width_spaces_n", ")", "help_n", "=", "'connect_to_oi'", "help_o", "=", "CONF", ".", "get", "(", "'help'", ",", "'connect/editor'", ")", "todo_n", "=", "'todo_list'", "todo_o", "=", "self", ".", "get_option", "(", "todo_n", ")", "finfo", "=", "self", ".", "get_current_finfo", "(", ")", "for", "editorstack", "in", "self", ".", "editorstacks", ":", "if", "tabbar_n", "in", "options", ":", "editorstack", ".", "set_tabbar_visible", "(", "tabbar_o", ")", "if", "linenb_n", "in", "options", ":", "editorstack", ".", "set_linenumbers_enabled", "(", "linenb_o", ",", "current_finfo", "=", "finfo", ")", "if", "edgeline_n", "in", "options", ":", "editorstack", ".", "set_edgeline_enabled", "(", "edgeline_o", ")", "if", "edgelinecols_n", "in", "options", ":", "editorstack", ".", "set_edgeline_columns", "(", "edgelinecols_o", ")", "if", "wrap_n", "in", "options", ":", "editorstack", ".", "set_wrap_enabled", "(", "wrap_o", ")", "if", "tabindent_n", "in", "options", ":", "editorstack", ".", "set_tabmode_enabled", "(", "tabindent_o", ")", "if", "ibackspace_n", "in", "options", ":", "editorstack", ".", "set_intelligent_backspace_enabled", "(", "ibackspace_o", ")", "if", "removetrail_n", "in", "options", ":", "editorstack", ".", "set_always_remove_trailing_spaces", "(", "removetrail_o", ")", "if", "converteol_n", "in", "options", ":", "editorstack", ".", "set_convert_eol_on_save", "(", "converteol_o", ")", "if", "converteolto_n", "in", "options", ":", "editorstack", ".", "set_convert_eol_on_save_to", "(", "converteolto_o", ")", "if", "runcellcopy_n", "in", "options", ":", "editorstack", ".", "set_run_cell_copy", "(", "runcellcopy_o", ")", "if", "closepar_n", "in", "options", ":", "editorstack", ".", "set_close_parentheses_enabled", "(", "closepar_o", ")", "if", "close_quotes_n", "in", "options", ":", "editorstack", ".", "set_close_quotes_enabled", "(", "close_quotes_o", ")", "if", "add_colons_n", "in", "options", ":", "editorstack", ".", "set_add_colons_enabled", "(", "add_colons_o", ")", "if", "autounindent_n", "in", "options", ":", "editorstack", ".", "set_auto_unindent_enabled", "(", "autounindent_o", ")", "if", "indent_chars_n", "in", "options", ":", "editorstack", ".", "set_indent_chars", "(", "indent_chars_o", ")", "if", "tab_stop_width_spaces_n", "in", "options", ":", "editorstack", ".", "set_tab_stop_width_spaces", "(", "tab_stop_width_spaces_o", ")", "if", "help_n", "in", "options", ":", "editorstack", ".", "set_help_enabled", "(", "help_o", ")", "if", "todo_n", "in", "options", ":", "editorstack", ".", "set_todolist_enabled", "(", "todo_o", ",", "current_finfo", "=", "finfo", ")", "for", "name", ",", "action", "in", "self", ".", "checkable_actions", ".", "items", "(", ")", ":", "if", "name", "in", "options", ":", "state", "=", "self", ".", "get_option", "(", "name", ")", "action", ".", "setChecked", "(", "state", ")", "action", ".", "trigger", "(", ")", "# Multiply by 1000 to convert seconds to milliseconds\r", "self", ".", "autosave", ".", "interval", "=", "(", "self", ".", "get_option", "(", "'autosave_interval'", ")", "*", "1000", ")", "self", ".", "autosave", ".", "enabled", "=", "self", ".", "get_option", "(", "'autosave_enabled'", ")", "# We must update the current editor after the others:\r", "# (otherwise, code analysis buttons state would correspond to the\r", "# last editor instead of showing the one of the current editor)\r", "if", "finfo", "is", "not", "None", ":", "# TODO: Connect this to the LSP\r", "if", "todo_n", "in", "options", "and", "todo_o", ":", "finfo", ".", "run_todo_finder", "(", ")" ]
Apply configuration file's plugin settings
[ "Apply", "configuration", "file", "s", "plugin", "settings" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2430-L2574
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.get_open_filenames
def get_open_filenames(self): """Get the list of open files in the current stack""" editorstack = self.editorstacks[0] filenames = [] filenames += [finfo.filename for finfo in editorstack.data] return filenames
python
def get_open_filenames(self): """Get the list of open files in the current stack""" editorstack = self.editorstacks[0] filenames = [] filenames += [finfo.filename for finfo in editorstack.data] return filenames
[ "def", "get_open_filenames", "(", "self", ")", ":", "editorstack", "=", "self", ".", "editorstacks", "[", "0", "]", "filenames", "=", "[", "]", "filenames", "+=", "[", "finfo", ".", "filename", "for", "finfo", "in", "editorstack", ".", "data", "]", "return", "filenames" ]
Get the list of open files in the current stack
[ "Get", "the", "list", "of", "open", "files", "in", "the", "current", "stack" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2577-L2582
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.set_open_filenames
def set_open_filenames(self): """ Set the recent opened files on editor based on active project. If no project is active, then editor filenames are saved, otherwise the opened filenames are stored in the project config info. """ if self.projects is not None: if not self.projects.get_active_project(): filenames = self.get_open_filenames() self.set_option('filenames', filenames)
python
def set_open_filenames(self): """ Set the recent opened files on editor based on active project. If no project is active, then editor filenames are saved, otherwise the opened filenames are stored in the project config info. """ if self.projects is not None: if not self.projects.get_active_project(): filenames = self.get_open_filenames() self.set_option('filenames', filenames)
[ "def", "set_open_filenames", "(", "self", ")", ":", "if", "self", ".", "projects", "is", "not", "None", ":", "if", "not", "self", ".", "projects", ".", "get_active_project", "(", ")", ":", "filenames", "=", "self", ".", "get_open_filenames", "(", ")", "self", ".", "set_option", "(", "'filenames'", ",", "filenames", ")" ]
Set the recent opened files on editor based on active project. If no project is active, then editor filenames are saved, otherwise the opened filenames are stored in the project config info.
[ "Set", "the", "recent", "opened", "files", "on", "editor", "based", "on", "active", "project", ".", "If", "no", "project", "is", "active", "then", "editor", "filenames", "are", "saved", "otherwise", "the", "opened", "filenames", "are", "stored", "in", "the", "project", "config", "info", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2584-L2594
train
spyder-ide/spyder
spyder/plugins/editor/plugin.py
Editor.setup_open_files
def setup_open_files(self): """ Open the list of saved files per project. Also open any files that the user selected in the recovery dialog. """ self.set_create_new_file_if_empty(False) active_project_path = None if self.projects is not None: active_project_path = self.projects.get_active_project_path() if active_project_path: filenames = self.projects.get_project_filenames() else: filenames = self.get_option('filenames', default=[]) self.close_all_files() all_filenames = self.autosave.recover_files_to_open + filenames if all_filenames and any([osp.isfile(f) for f in all_filenames]): layout = self.get_option('layout_settings', None) # Check if no saved layout settings exist, e.g. clean prefs file # If not, load with default focus/layout, to fix issue #8458 . if layout: is_vertical, cfname, clines = layout.get('splitsettings')[0] if cfname in filenames: index = filenames.index(cfname) # First we load the last focused file. self.load(filenames[index], goto=clines[index], set_focus=True) # Then we load the files located to the left of the last # focused file in the tabbar, while keeping the focus on # the last focused file. if index > 0: self.load(filenames[index::-1], goto=clines[index::-1], set_focus=False, add_where='start') # Then we load the files located to the right of the last # focused file in the tabbar, while keeping the focus on # the last focused file. if index < (len(filenames) - 1): self.load(filenames[index+1:], goto=clines[index:], set_focus=False, add_where='end') # Finally we load any recovered files at the end of the tabbar, # while keeping focus on the last focused file. if self.autosave.recover_files_to_open: self.load(self.autosave.recover_files_to_open, set_focus=False, add_where='end') else: if filenames: self.load(filenames, goto=clines) if self.autosave.recover_files_to_open: self.load(self.autosave.recover_files_to_open) else: if filenames: self.load(filenames) if self.autosave.recover_files_to_open: self.load(self.autosave.recover_files_to_open) if self.__first_open_files_setup: self.__first_open_files_setup = False if layout is not None: self.editorsplitter.set_layout_settings( layout, dont_goto=filenames[0]) win_layout = self.get_option('windows_layout_settings', []) if win_layout: for layout_settings in win_layout: self.editorwindows_to_be_created.append( layout_settings) self.set_last_focus_editorstack(self, self.editorstacks[0]) else: self.__load_temp_file() self.set_create_new_file_if_empty(True)
python
def setup_open_files(self): """ Open the list of saved files per project. Also open any files that the user selected in the recovery dialog. """ self.set_create_new_file_if_empty(False) active_project_path = None if self.projects is not None: active_project_path = self.projects.get_active_project_path() if active_project_path: filenames = self.projects.get_project_filenames() else: filenames = self.get_option('filenames', default=[]) self.close_all_files() all_filenames = self.autosave.recover_files_to_open + filenames if all_filenames and any([osp.isfile(f) for f in all_filenames]): layout = self.get_option('layout_settings', None) # Check if no saved layout settings exist, e.g. clean prefs file # If not, load with default focus/layout, to fix issue #8458 . if layout: is_vertical, cfname, clines = layout.get('splitsettings')[0] if cfname in filenames: index = filenames.index(cfname) # First we load the last focused file. self.load(filenames[index], goto=clines[index], set_focus=True) # Then we load the files located to the left of the last # focused file in the tabbar, while keeping the focus on # the last focused file. if index > 0: self.load(filenames[index::-1], goto=clines[index::-1], set_focus=False, add_where='start') # Then we load the files located to the right of the last # focused file in the tabbar, while keeping the focus on # the last focused file. if index < (len(filenames) - 1): self.load(filenames[index+1:], goto=clines[index:], set_focus=False, add_where='end') # Finally we load any recovered files at the end of the tabbar, # while keeping focus on the last focused file. if self.autosave.recover_files_to_open: self.load(self.autosave.recover_files_to_open, set_focus=False, add_where='end') else: if filenames: self.load(filenames, goto=clines) if self.autosave.recover_files_to_open: self.load(self.autosave.recover_files_to_open) else: if filenames: self.load(filenames) if self.autosave.recover_files_to_open: self.load(self.autosave.recover_files_to_open) if self.__first_open_files_setup: self.__first_open_files_setup = False if layout is not None: self.editorsplitter.set_layout_settings( layout, dont_goto=filenames[0]) win_layout = self.get_option('windows_layout_settings', []) if win_layout: for layout_settings in win_layout: self.editorwindows_to_be_created.append( layout_settings) self.set_last_focus_editorstack(self, self.editorstacks[0]) else: self.__load_temp_file() self.set_create_new_file_if_empty(True)
[ "def", "setup_open_files", "(", "self", ")", ":", "self", ".", "set_create_new_file_if_empty", "(", "False", ")", "active_project_path", "=", "None", "if", "self", ".", "projects", "is", "not", "None", ":", "active_project_path", "=", "self", ".", "projects", ".", "get_active_project_path", "(", ")", "if", "active_project_path", ":", "filenames", "=", "self", ".", "projects", ".", "get_project_filenames", "(", ")", "else", ":", "filenames", "=", "self", ".", "get_option", "(", "'filenames'", ",", "default", "=", "[", "]", ")", "self", ".", "close_all_files", "(", ")", "all_filenames", "=", "self", ".", "autosave", ".", "recover_files_to_open", "+", "filenames", "if", "all_filenames", "and", "any", "(", "[", "osp", ".", "isfile", "(", "f", ")", "for", "f", "in", "all_filenames", "]", ")", ":", "layout", "=", "self", ".", "get_option", "(", "'layout_settings'", ",", "None", ")", "# Check if no saved layout settings exist, e.g. clean prefs file\r", "# If not, load with default focus/layout, to fix issue #8458 .\r", "if", "layout", ":", "is_vertical", ",", "cfname", ",", "clines", "=", "layout", ".", "get", "(", "'splitsettings'", ")", "[", "0", "]", "if", "cfname", "in", "filenames", ":", "index", "=", "filenames", ".", "index", "(", "cfname", ")", "# First we load the last focused file.\r", "self", ".", "load", "(", "filenames", "[", "index", "]", ",", "goto", "=", "clines", "[", "index", "]", ",", "set_focus", "=", "True", ")", "# Then we load the files located to the left of the last\r", "# focused file in the tabbar, while keeping the focus on\r", "# the last focused file.\r", "if", "index", ">", "0", ":", "self", ".", "load", "(", "filenames", "[", "index", ":", ":", "-", "1", "]", ",", "goto", "=", "clines", "[", "index", ":", ":", "-", "1", "]", ",", "set_focus", "=", "False", ",", "add_where", "=", "'start'", ")", "# Then we load the files located to the right of the last\r", "# focused file in the tabbar, while keeping the focus on\r", "# the last focused file.\r", "if", "index", "<", "(", "len", "(", "filenames", ")", "-", "1", ")", ":", "self", ".", "load", "(", "filenames", "[", "index", "+", "1", ":", "]", ",", "goto", "=", "clines", "[", "index", ":", "]", ",", "set_focus", "=", "False", ",", "add_where", "=", "'end'", ")", "# Finally we load any recovered files at the end of the tabbar,\r", "# while keeping focus on the last focused file.\r", "if", "self", ".", "autosave", ".", "recover_files_to_open", ":", "self", ".", "load", "(", "self", ".", "autosave", ".", "recover_files_to_open", ",", "set_focus", "=", "False", ",", "add_where", "=", "'end'", ")", "else", ":", "if", "filenames", ":", "self", ".", "load", "(", "filenames", ",", "goto", "=", "clines", ")", "if", "self", ".", "autosave", ".", "recover_files_to_open", ":", "self", ".", "load", "(", "self", ".", "autosave", ".", "recover_files_to_open", ")", "else", ":", "if", "filenames", ":", "self", ".", "load", "(", "filenames", ")", "if", "self", ".", "autosave", ".", "recover_files_to_open", ":", "self", ".", "load", "(", "self", ".", "autosave", ".", "recover_files_to_open", ")", "if", "self", ".", "__first_open_files_setup", ":", "self", ".", "__first_open_files_setup", "=", "False", "if", "layout", "is", "not", "None", ":", "self", ".", "editorsplitter", ".", "set_layout_settings", "(", "layout", ",", "dont_goto", "=", "filenames", "[", "0", "]", ")", "win_layout", "=", "self", ".", "get_option", "(", "'windows_layout_settings'", ",", "[", "]", ")", "if", "win_layout", ":", "for", "layout_settings", "in", "win_layout", ":", "self", ".", "editorwindows_to_be_created", ".", "append", "(", "layout_settings", ")", "self", ".", "set_last_focus_editorstack", "(", "self", ",", "self", ".", "editorstacks", "[", "0", "]", ")", "else", ":", "self", ".", "__load_temp_file", "(", ")", "self", ".", "set_create_new_file_if_empty", "(", "True", ")" ]
Open the list of saved files per project. Also open any files that the user selected in the recovery dialog.
[ "Open", "the", "list", "of", "saved", "files", "per", "project", ".", "Also", "open", "any", "files", "that", "the", "user", "selected", "in", "the", "recovery", "dialog", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2596-L2666
train
spyder-ide/spyder
spyder/plugins/console/utils/interpreter.py
guess_filename
def guess_filename(filename): """Guess filename""" if osp.isfile(filename): return filename if not filename.endswith('.py'): filename += '.py' for path in [getcwd_or_home()] + sys.path: fname = osp.join(path, filename) if osp.isfile(fname): return fname elif osp.isfile(fname+'.py'): return fname+'.py' elif osp.isfile(fname+'.pyw'): return fname+'.pyw' return filename
python
def guess_filename(filename): """Guess filename""" if osp.isfile(filename): return filename if not filename.endswith('.py'): filename += '.py' for path in [getcwd_or_home()] + sys.path: fname = osp.join(path, filename) if osp.isfile(fname): return fname elif osp.isfile(fname+'.py'): return fname+'.py' elif osp.isfile(fname+'.pyw'): return fname+'.pyw' return filename
[ "def", "guess_filename", "(", "filename", ")", ":", "if", "osp", ".", "isfile", "(", "filename", ")", ":", "return", "filename", "if", "not", "filename", ".", "endswith", "(", "'.py'", ")", ":", "filename", "+=", "'.py'", "for", "path", "in", "[", "getcwd_or_home", "(", ")", "]", "+", "sys", ".", "path", ":", "fname", "=", "osp", ".", "join", "(", "path", ",", "filename", ")", "if", "osp", ".", "isfile", "(", "fname", ")", ":", "return", "fname", "elif", "osp", ".", "isfile", "(", "fname", "+", "'.py'", ")", ":", "return", "fname", "+", "'.py'", "elif", "osp", ".", "isfile", "(", "fname", "+", "'.pyw'", ")", ":", "return", "fname", "+", "'.pyw'", "return", "filename" ]
Guess filename
[ "Guess", "filename" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L32-L46
train
spyder-ide/spyder
spyder/plugins/console/utils/interpreter.py
Interpreter.redirect_stds
def redirect_stds(self): """Redirects stds""" if not self.debug: sys.stdout = self.stdout_write sys.stderr = self.stderr_write sys.stdin = self.stdin_read
python
def redirect_stds(self): """Redirects stds""" if not self.debug: sys.stdout = self.stdout_write sys.stderr = self.stderr_write sys.stdin = self.stdin_read
[ "def", "redirect_stds", "(", "self", ")", ":", "if", "not", "self", ".", "debug", ":", "sys", ".", "stdout", "=", "self", ".", "stdout_write", "sys", ".", "stderr", "=", "self", ".", "stderr_write", "sys", ".", "stdin", "=", "self", ".", "stdin_read" ]
Redirects stds
[ "Redirects", "stds" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L98-L103
train
spyder-ide/spyder
spyder/plugins/console/utils/interpreter.py
Interpreter.restore_stds
def restore_stds(self): """Restore stds""" if not self.debug: sys.stdout = self.initial_stdout sys.stderr = self.initial_stderr sys.stdin = self.initial_stdin
python
def restore_stds(self): """Restore stds""" if not self.debug: sys.stdout = self.initial_stdout sys.stderr = self.initial_stderr sys.stdin = self.initial_stdin
[ "def", "restore_stds", "(", "self", ")", ":", "if", "not", "self", ".", "debug", ":", "sys", ".", "stdout", "=", "self", ".", "initial_stdout", "sys", ".", "stderr", "=", "self", ".", "initial_stderr", "sys", ".", "stdin", "=", "self", ".", "initial_stdin" ]
Restore stds
[ "Restore", "stds" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L105-L110
train
spyder-ide/spyder
spyder/plugins/console/utils/interpreter.py
Interpreter.raw_input_replacement
def raw_input_replacement(self, prompt=''): """For raw_input builtin function emulation""" self.widget_proxy.wait_input(prompt) self.input_condition.acquire() while not self.widget_proxy.data_available(): self.input_condition.wait() inp = self.widget_proxy.input_data self.input_condition.release() return inp
python
def raw_input_replacement(self, prompt=''): """For raw_input builtin function emulation""" self.widget_proxy.wait_input(prompt) self.input_condition.acquire() while not self.widget_proxy.data_available(): self.input_condition.wait() inp = self.widget_proxy.input_data self.input_condition.release() return inp
[ "def", "raw_input_replacement", "(", "self", ",", "prompt", "=", "''", ")", ":", "self", ".", "widget_proxy", ".", "wait_input", "(", "prompt", ")", "self", ".", "input_condition", ".", "acquire", "(", ")", "while", "not", "self", ".", "widget_proxy", ".", "data_available", "(", ")", ":", "self", ".", "input_condition", ".", "wait", "(", ")", "inp", "=", "self", ".", "widget_proxy", ".", "input_data", "self", ".", "input_condition", ".", "release", "(", ")", "return", "inp" ]
For raw_input builtin function emulation
[ "For", "raw_input", "builtin", "function", "emulation" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L112-L120
train
spyder-ide/spyder
spyder/plugins/console/utils/interpreter.py
Interpreter.help_replacement
def help_replacement(self, text=None, interactive=False): """For help builtin function emulation""" if text is not None and not interactive: return pydoc.help(text) elif text is None: pyver = "%d.%d" % (sys.version_info[0], sys.version_info[1]) self.write(""" Welcome to Python %s! This is the online help utility. If this is your first time using Python, you should definitely check out the tutorial on the Internet at https://www.python.org/about/gettingstarted/ Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, or topics, type "modules", "keywords", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam". """ % pyver) else: text = text.strip() try: eval("pydoc.help(%s)" % text) except (NameError, SyntaxError): print("no Python documentation found for '%r'" % text) # spyder: test-skip self.write(os.linesep) self.widget_proxy.new_prompt("help> ") inp = self.raw_input_replacement() if inp.strip(): self.help_replacement(inp, interactive=True) else: self.write(""" You are now leaving help and returning to the Python interpreter. If you want to ask for help on a particular object directly from the interpreter, you can type "help(object)". Executing "help('string')" has the same effect as typing a particular string at the help> prompt. """)
python
def help_replacement(self, text=None, interactive=False): """For help builtin function emulation""" if text is not None and not interactive: return pydoc.help(text) elif text is None: pyver = "%d.%d" % (sys.version_info[0], sys.version_info[1]) self.write(""" Welcome to Python %s! This is the online help utility. If this is your first time using Python, you should definitely check out the tutorial on the Internet at https://www.python.org/about/gettingstarted/ Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, or topics, type "modules", "keywords", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam". """ % pyver) else: text = text.strip() try: eval("pydoc.help(%s)" % text) except (NameError, SyntaxError): print("no Python documentation found for '%r'" % text) # spyder: test-skip self.write(os.linesep) self.widget_proxy.new_prompt("help> ") inp = self.raw_input_replacement() if inp.strip(): self.help_replacement(inp, interactive=True) else: self.write(""" You are now leaving help and returning to the Python interpreter. If you want to ask for help on a particular object directly from the interpreter, you can type "help(object)". Executing "help('string')" has the same effect as typing a particular string at the help> prompt. """)
[ "def", "help_replacement", "(", "self", ",", "text", "=", "None", ",", "interactive", "=", "False", ")", ":", "if", "text", "is", "not", "None", "and", "not", "interactive", ":", "return", "pydoc", ".", "help", "(", "text", ")", "elif", "text", "is", "None", ":", "pyver", "=", "\"%d.%d\"", "%", "(", "sys", ".", "version_info", "[", "0", "]", ",", "sys", ".", "version_info", "[", "1", "]", ")", "self", ".", "write", "(", "\"\"\"\r\nWelcome to Python %s! This is the online help utility.\r\n\r\nIf this is your first time using Python, you should definitely check out\r\nthe tutorial on the Internet at https://www.python.org/about/gettingstarted/\r\n\r\nEnter the name of any module, keyword, or topic to get help on writing\r\nPython programs and using Python modules. To quit this help utility and\r\nreturn to the interpreter, just type \"quit\".\r\n\r\nTo get a list of available modules, keywords, or topics, type \"modules\",\r\n\"keywords\", or \"topics\". Each module also comes with a one-line summary\r\nof what it does; to list the modules whose summaries contain a given word\r\nsuch as \"spam\", type \"modules spam\".\r\n\"\"\"", "%", "pyver", ")", "else", ":", "text", "=", "text", ".", "strip", "(", ")", "try", ":", "eval", "(", "\"pydoc.help(%s)\"", "%", "text", ")", "except", "(", "NameError", ",", "SyntaxError", ")", ":", "print", "(", "\"no Python documentation found for '%r'\"", "%", "text", ")", "# spyder: test-skip\r", "self", ".", "write", "(", "os", ".", "linesep", ")", "self", ".", "widget_proxy", ".", "new_prompt", "(", "\"help> \"", ")", "inp", "=", "self", ".", "raw_input_replacement", "(", ")", "if", "inp", ".", "strip", "(", ")", ":", "self", ".", "help_replacement", "(", "inp", ",", "interactive", "=", "True", ")", "else", ":", "self", ".", "write", "(", "\"\"\"\r\nYou are now leaving help and returning to the Python interpreter.\r\nIf you want to ask for help on a particular object directly from the\r\ninterpreter, you can type \"help(object)\". Executing \"help('string')\"\r\nhas the same effect as typing a particular string at the help> prompt.\r\n\"\"\"", ")" ]
For help builtin function emulation
[ "For", "help", "builtin", "function", "emulation" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L122-L160
train
spyder-ide/spyder
spyder/plugins/console/utils/interpreter.py
Interpreter.run_command
def run_command(self, cmd, new_prompt=True): """Run command in interpreter""" if cmd == 'exit()': self.exit_flag = True self.write('\n') return # -- Special commands type I # (transformed into commands executed in the interpreter) # ? command special_pattern = r"^%s (?:r\')?(?:u\')?\"?\'?([a-zA-Z0-9_\.]+)" run_match = re.match(special_pattern % 'run', cmd) help_match = re.match(r'^([a-zA-Z0-9_\.]+)\?$', cmd) cd_match = re.match(r"^\!cd \"?\'?([a-zA-Z0-9_ \.]+)", cmd) if help_match: cmd = 'help(%s)' % help_match.group(1) # run command elif run_match: filename = guess_filename(run_match.groups()[0]) cmd = "runfile('%s', args=None)" % remove_backslashes(filename) # !cd system command elif cd_match: cmd = 'import os; os.chdir(r"%s")' % cd_match.groups()[0].strip() # -- End of Special commands type I # -- Special commands type II # (don't need code execution in interpreter) xedit_match = re.match(special_pattern % 'xedit', cmd) edit_match = re.match(special_pattern % 'edit', cmd) clear_match = re.match(r"^clear ([a-zA-Z0-9_, ]+)", cmd) # (external) edit command if xedit_match: filename = guess_filename(xedit_match.groups()[0]) self.widget_proxy.edit(filename, external_editor=True) # local edit command elif edit_match: filename = guess_filename(edit_match.groups()[0]) if osp.isfile(filename): self.widget_proxy.edit(filename) else: self.stderr_write.write( "No such file or directory: %s\n" % filename) # remove reference (equivalent to MATLAB's clear command) elif clear_match: varnames = clear_match.groups()[0].replace(' ', '').split(',') for varname in varnames: try: self.namespace.pop(varname) except KeyError: pass # Execute command elif cmd.startswith('!'): # System ! command pipe = programs.run_shell_command(cmd[1:]) txt_out = encoding.transcode( pipe.stdout.read().decode() ) txt_err = encoding.transcode( pipe.stderr.read().decode().rstrip() ) if txt_err: self.stderr_write.write(txt_err) if txt_out: self.stdout_write.write(txt_out) self.stdout_write.write('\n') self.more = False # -- End of Special commands type II else: # Command executed in the interpreter # self.widget_proxy.set_readonly(True) self.more = self.push(cmd) # self.widget_proxy.set_readonly(False) if new_prompt: self.widget_proxy.new_prompt(self.p2 if self.more else self.p1) if not self.more: self.resetbuffer()
python
def run_command(self, cmd, new_prompt=True): """Run command in interpreter""" if cmd == 'exit()': self.exit_flag = True self.write('\n') return # -- Special commands type I # (transformed into commands executed in the interpreter) # ? command special_pattern = r"^%s (?:r\')?(?:u\')?\"?\'?([a-zA-Z0-9_\.]+)" run_match = re.match(special_pattern % 'run', cmd) help_match = re.match(r'^([a-zA-Z0-9_\.]+)\?$', cmd) cd_match = re.match(r"^\!cd \"?\'?([a-zA-Z0-9_ \.]+)", cmd) if help_match: cmd = 'help(%s)' % help_match.group(1) # run command elif run_match: filename = guess_filename(run_match.groups()[0]) cmd = "runfile('%s', args=None)" % remove_backslashes(filename) # !cd system command elif cd_match: cmd = 'import os; os.chdir(r"%s")' % cd_match.groups()[0].strip() # -- End of Special commands type I # -- Special commands type II # (don't need code execution in interpreter) xedit_match = re.match(special_pattern % 'xedit', cmd) edit_match = re.match(special_pattern % 'edit', cmd) clear_match = re.match(r"^clear ([a-zA-Z0-9_, ]+)", cmd) # (external) edit command if xedit_match: filename = guess_filename(xedit_match.groups()[0]) self.widget_proxy.edit(filename, external_editor=True) # local edit command elif edit_match: filename = guess_filename(edit_match.groups()[0]) if osp.isfile(filename): self.widget_proxy.edit(filename) else: self.stderr_write.write( "No such file or directory: %s\n" % filename) # remove reference (equivalent to MATLAB's clear command) elif clear_match: varnames = clear_match.groups()[0].replace(' ', '').split(',') for varname in varnames: try: self.namespace.pop(varname) except KeyError: pass # Execute command elif cmd.startswith('!'): # System ! command pipe = programs.run_shell_command(cmd[1:]) txt_out = encoding.transcode( pipe.stdout.read().decode() ) txt_err = encoding.transcode( pipe.stderr.read().decode().rstrip() ) if txt_err: self.stderr_write.write(txt_err) if txt_out: self.stdout_write.write(txt_out) self.stdout_write.write('\n') self.more = False # -- End of Special commands type II else: # Command executed in the interpreter # self.widget_proxy.set_readonly(True) self.more = self.push(cmd) # self.widget_proxy.set_readonly(False) if new_prompt: self.widget_proxy.new_prompt(self.p2 if self.more else self.p1) if not self.more: self.resetbuffer()
[ "def", "run_command", "(", "self", ",", "cmd", ",", "new_prompt", "=", "True", ")", ":", "if", "cmd", "==", "'exit()'", ":", "self", ".", "exit_flag", "=", "True", "self", ".", "write", "(", "'\\n'", ")", "return", "# -- Special commands type I\r", "# (transformed into commands executed in the interpreter)\r", "# ? command\r", "special_pattern", "=", "r\"^%s (?:r\\')?(?:u\\')?\\\"?\\'?([a-zA-Z0-9_\\.]+)\"", "run_match", "=", "re", ".", "match", "(", "special_pattern", "%", "'run'", ",", "cmd", ")", "help_match", "=", "re", ".", "match", "(", "r'^([a-zA-Z0-9_\\.]+)\\?$'", ",", "cmd", ")", "cd_match", "=", "re", ".", "match", "(", "r\"^\\!cd \\\"?\\'?([a-zA-Z0-9_ \\.]+)\"", ",", "cmd", ")", "if", "help_match", ":", "cmd", "=", "'help(%s)'", "%", "help_match", ".", "group", "(", "1", ")", "# run command\r", "elif", "run_match", ":", "filename", "=", "guess_filename", "(", "run_match", ".", "groups", "(", ")", "[", "0", "]", ")", "cmd", "=", "\"runfile('%s', args=None)\"", "%", "remove_backslashes", "(", "filename", ")", "# !cd system command\r", "elif", "cd_match", ":", "cmd", "=", "'import os; os.chdir(r\"%s\")'", "%", "cd_match", ".", "groups", "(", ")", "[", "0", "]", ".", "strip", "(", ")", "# -- End of Special commands type I\r", "# -- Special commands type II\r", "# (don't need code execution in interpreter)\r", "xedit_match", "=", "re", ".", "match", "(", "special_pattern", "%", "'xedit'", ",", "cmd", ")", "edit_match", "=", "re", ".", "match", "(", "special_pattern", "%", "'edit'", ",", "cmd", ")", "clear_match", "=", "re", ".", "match", "(", "r\"^clear ([a-zA-Z0-9_, ]+)\"", ",", "cmd", ")", "# (external) edit command\r", "if", "xedit_match", ":", "filename", "=", "guess_filename", "(", "xedit_match", ".", "groups", "(", ")", "[", "0", "]", ")", "self", ".", "widget_proxy", ".", "edit", "(", "filename", ",", "external_editor", "=", "True", ")", "# local edit command\r", "elif", "edit_match", ":", "filename", "=", "guess_filename", "(", "edit_match", ".", "groups", "(", ")", "[", "0", "]", ")", "if", "osp", ".", "isfile", "(", "filename", ")", ":", "self", ".", "widget_proxy", ".", "edit", "(", "filename", ")", "else", ":", "self", ".", "stderr_write", ".", "write", "(", "\"No such file or directory: %s\\n\"", "%", "filename", ")", "# remove reference (equivalent to MATLAB's clear command)\r", "elif", "clear_match", ":", "varnames", "=", "clear_match", ".", "groups", "(", ")", "[", "0", "]", ".", "replace", "(", "' '", ",", "''", ")", ".", "split", "(", "','", ")", "for", "varname", "in", "varnames", ":", "try", ":", "self", ".", "namespace", ".", "pop", "(", "varname", ")", "except", "KeyError", ":", "pass", "# Execute command\r", "elif", "cmd", ".", "startswith", "(", "'!'", ")", ":", "# System ! command\r", "pipe", "=", "programs", ".", "run_shell_command", "(", "cmd", "[", "1", ":", "]", ")", "txt_out", "=", "encoding", ".", "transcode", "(", "pipe", ".", "stdout", ".", "read", "(", ")", ".", "decode", "(", ")", ")", "txt_err", "=", "encoding", ".", "transcode", "(", "pipe", ".", "stderr", ".", "read", "(", ")", ".", "decode", "(", ")", ".", "rstrip", "(", ")", ")", "if", "txt_err", ":", "self", ".", "stderr_write", ".", "write", "(", "txt_err", ")", "if", "txt_out", ":", "self", ".", "stdout_write", ".", "write", "(", "txt_out", ")", "self", ".", "stdout_write", ".", "write", "(", "'\\n'", ")", "self", ".", "more", "=", "False", "# -- End of Special commands type II\r", "else", ":", "# Command executed in the interpreter\r", "# self.widget_proxy.set_readonly(True)\r", "self", ".", "more", "=", "self", ".", "push", "(", "cmd", ")", "# self.widget_proxy.set_readonly(False)\r", "if", "new_prompt", ":", "self", ".", "widget_proxy", ".", "new_prompt", "(", "self", ".", "p2", "if", "self", ".", "more", "else", "self", ".", "p1", ")", "if", "not", "self", ".", "more", ":", "self", ".", "resetbuffer", "(", ")" ]
Run command in interpreter
[ "Run", "command", "in", "interpreter" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L162-L233
train
spyder-ide/spyder
spyder/plugins/console/utils/interpreter.py
Interpreter.get_thread_id
def get_thread_id(self): """Return thread id""" if self._id is None: for thread_id, obj in list(threading._active.items()): if obj is self: self._id = thread_id return self._id
python
def get_thread_id(self): """Return thread id""" if self._id is None: for thread_id, obj in list(threading._active.items()): if obj is self: self._id = thread_id return self._id
[ "def", "get_thread_id", "(", "self", ")", ":", "if", "self", ".", "_id", "is", "None", ":", "for", "thread_id", ",", "obj", "in", "list", "(", "threading", ".", "_active", ".", "items", "(", ")", ")", ":", "if", "obj", "is", "self", ":", "self", ".", "_id", "=", "thread_id", "return", "self", ".", "_id" ]
Return thread id
[ "Return", "thread", "id" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L247-L253
train
spyder-ide/spyder
spyder/plugins/console/utils/interpreter.py
Interpreter.execfile
def execfile(self, filename): """Exec filename""" source = open(filename, 'r').read() try: try: name = filename.encode('ascii') except UnicodeEncodeError: name = '<executed_script>' code = compile(source, name, "exec") except (OverflowError, SyntaxError): InteractiveConsole.showsyntaxerror(self, filename) else: self.runcode(code)
python
def execfile(self, filename): """Exec filename""" source = open(filename, 'r').read() try: try: name = filename.encode('ascii') except UnicodeEncodeError: name = '<executed_script>' code = compile(source, name, "exec") except (OverflowError, SyntaxError): InteractiveConsole.showsyntaxerror(self, filename) else: self.runcode(code)
[ "def", "execfile", "(", "self", ",", "filename", ")", ":", "source", "=", "open", "(", "filename", ",", "'r'", ")", ".", "read", "(", ")", "try", ":", "try", ":", "name", "=", "filename", ".", "encode", "(", "'ascii'", ")", "except", "UnicodeEncodeError", ":", "name", "=", "'<executed_script>'", "code", "=", "compile", "(", "source", ",", "name", ",", "\"exec\"", ")", "except", "(", "OverflowError", ",", "SyntaxError", ")", ":", "InteractiveConsole", ".", "showsyntaxerror", "(", "self", ",", "filename", ")", "else", ":", "self", ".", "runcode", "(", "code", ")" ]
Exec filename
[ "Exec", "filename" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L268-L280
train
spyder-ide/spyder
spyder/plugins/console/utils/interpreter.py
Interpreter.runfile
def runfile(self, filename, args=None): """ Run filename args: command line arguments (string) """ if args is not None and not is_text_string(args): raise TypeError("expected a character buffer object") self.namespace['__file__'] = filename sys.argv = [filename] if args is not None: for arg in args.split(): sys.argv.append(arg) self.execfile(filename) sys.argv = [''] self.namespace.pop('__file__')
python
def runfile(self, filename, args=None): """ Run filename args: command line arguments (string) """ if args is not None and not is_text_string(args): raise TypeError("expected a character buffer object") self.namespace['__file__'] = filename sys.argv = [filename] if args is not None: for arg in args.split(): sys.argv.append(arg) self.execfile(filename) sys.argv = [''] self.namespace.pop('__file__')
[ "def", "runfile", "(", "self", ",", "filename", ",", "args", "=", "None", ")", ":", "if", "args", "is", "not", "None", "and", "not", "is_text_string", "(", "args", ")", ":", "raise", "TypeError", "(", "\"expected a character buffer object\"", ")", "self", ".", "namespace", "[", "'__file__'", "]", "=", "filename", "sys", ".", "argv", "=", "[", "filename", "]", "if", "args", "is", "not", "None", ":", "for", "arg", "in", "args", ".", "split", "(", ")", ":", "sys", ".", "argv", ".", "append", "(", "arg", ")", "self", ".", "execfile", "(", "filename", ")", "sys", ".", "argv", "=", "[", "''", "]", "self", ".", "namespace", ".", "pop", "(", "'__file__'", ")" ]
Run filename args: command line arguments (string)
[ "Run", "filename", "args", ":", "command", "line", "arguments", "(", "string", ")" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L282-L296
train
spyder-ide/spyder
spyder/plugins/console/utils/interpreter.py
Interpreter.eval
def eval(self, text): """ Evaluate text and return (obj, valid) where *obj* is the object represented by *text* and *valid* is True if object evaluation did not raise any exception """ assert is_text_string(text) try: return eval(text, self.locals), True except: return None, False
python
def eval(self, text): """ Evaluate text and return (obj, valid) where *obj* is the object represented by *text* and *valid* is True if object evaluation did not raise any exception """ assert is_text_string(text) try: return eval(text, self.locals), True except: return None, False
[ "def", "eval", "(", "self", ",", "text", ")", ":", "assert", "is_text_string", "(", "text", ")", "try", ":", "return", "eval", "(", "text", ",", "self", ".", "locals", ")", ",", "True", "except", ":", "return", "None", ",", "False" ]
Evaluate text and return (obj, valid) where *obj* is the object represented by *text* and *valid* is True if object evaluation did not raise any exception
[ "Evaluate", "text", "and", "return", "(", "obj", "valid", ")", "where", "*", "obj", "*", "is", "the", "object", "represented", "by", "*", "text", "*", "and", "*", "valid", "*", "is", "True", "if", "object", "evaluation", "did", "not", "raise", "any", "exception" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L298-L308
train
spyder-ide/spyder
spyder/plugins/console/utils/interpreter.py
Interpreter.is_defined
def is_defined(self, objtxt, force_import=False): """Return True if object is defined""" return isdefined(objtxt, force_import=force_import, namespace=self.locals)
python
def is_defined(self, objtxt, force_import=False): """Return True if object is defined""" return isdefined(objtxt, force_import=force_import, namespace=self.locals)
[ "def", "is_defined", "(", "self", ",", "objtxt", ",", "force_import", "=", "False", ")", ":", "return", "isdefined", "(", "objtxt", ",", "force_import", "=", "force_import", ",", "namespace", "=", "self", ".", "locals", ")" ]
Return True if object is defined
[ "Return", "True", "if", "object", "is", "defined" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L310-L313
train
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/texteditor.py
TextEditor.text_changed
def text_changed(self): """Text has changed""" # Save text as bytes, if it was initially bytes if self.is_binary: self.text = to_binary_string(self.edit.toPlainText(), 'utf8') else: self.text = to_text_string(self.edit.toPlainText()) if self.btn_save_and_close: self.btn_save_and_close.setEnabled(True) self.btn_save_and_close.setAutoDefault(True) self.btn_save_and_close.setDefault(True)
python
def text_changed(self): """Text has changed""" # Save text as bytes, if it was initially bytes if self.is_binary: self.text = to_binary_string(self.edit.toPlainText(), 'utf8') else: self.text = to_text_string(self.edit.toPlainText()) if self.btn_save_and_close: self.btn_save_and_close.setEnabled(True) self.btn_save_and_close.setAutoDefault(True) self.btn_save_and_close.setDefault(True)
[ "def", "text_changed", "(", "self", ")", ":", "# Save text as bytes, if it was initially bytes\r", "if", "self", ".", "is_binary", ":", "self", ".", "text", "=", "to_binary_string", "(", "self", ".", "edit", ".", "toPlainText", "(", ")", ",", "'utf8'", ")", "else", ":", "self", ".", "text", "=", "to_text_string", "(", "self", ".", "edit", ".", "toPlainText", "(", ")", ")", "if", "self", ".", "btn_save_and_close", ":", "self", ".", "btn_save_and_close", ".", "setEnabled", "(", "True", ")", "self", ".", "btn_save_and_close", ".", "setAutoDefault", "(", "True", ")", "self", ".", "btn_save_and_close", ".", "setDefault", "(", "True", ")" ]
Text has changed
[ "Text", "has", "changed" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/texteditor.py#L98-L108
train
spyder-ide/spyder
spyder/plugins/editor/lsp/transport/main.py
logger_init
def logger_init(level): """ Initialize the logger for this thread. Sets the log level to ERROR (0), WARNING (1), INFO (2), or DEBUG (3), depending on the argument `level`. """ levellist = [logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG] handler = logging.StreamHandler() fmt = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) ' '-35s %(lineno) -5d: %(message)s') handler.setFormatter(logging.Formatter(fmt)) logger = logging.root logger.addHandler(handler) logger.setLevel(levellist[level])
python
def logger_init(level): """ Initialize the logger for this thread. Sets the log level to ERROR (0), WARNING (1), INFO (2), or DEBUG (3), depending on the argument `level`. """ levellist = [logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG] handler = logging.StreamHandler() fmt = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) ' '-35s %(lineno) -5d: %(message)s') handler.setFormatter(logging.Formatter(fmt)) logger = logging.root logger.addHandler(handler) logger.setLevel(levellist[level])
[ "def", "logger_init", "(", "level", ")", ":", "levellist", "=", "[", "logging", ".", "ERROR", ",", "logging", ".", "WARNING", ",", "logging", ".", "INFO", ",", "logging", ".", "DEBUG", "]", "handler", "=", "logging", ".", "StreamHandler", "(", ")", "fmt", "=", "(", "'%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '", "'-35s %(lineno) -5d: %(message)s'", ")", "handler", ".", "setFormatter", "(", "logging", ".", "Formatter", "(", "fmt", ")", ")", "logger", "=", "logging", ".", "root", "logger", ".", "addHandler", "(", "handler", ")", "logger", ".", "setLevel", "(", "levellist", "[", "level", "]", ")" ]
Initialize the logger for this thread. Sets the log level to ERROR (0), WARNING (1), INFO (2), or DEBUG (3), depending on the argument `level`.
[ "Initialize", "the", "logger", "for", "this", "thread", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/transport/main.py#L62-L76
train
spyder-ide/spyder
spyder/plugins/editor/lsp/transport/main.py
SignalManager.restore
def restore(self): """Restore signal handlers to their original settings.""" signal.signal(signal.SIGINT, self.original_sigint) signal.signal(signal.SIGTERM, self.original_sigterm) if os.name == 'nt': signal.signal(signal.SIGBREAK, self.original_sigbreak)
python
def restore(self): """Restore signal handlers to their original settings.""" signal.signal(signal.SIGINT, self.original_sigint) signal.signal(signal.SIGTERM, self.original_sigterm) if os.name == 'nt': signal.signal(signal.SIGBREAK, self.original_sigbreak)
[ "def", "restore", "(", "self", ")", ":", "signal", ".", "signal", "(", "signal", ".", "SIGINT", ",", "self", ".", "original_sigint", ")", "signal", ".", "signal", "(", "signal", ".", "SIGTERM", ",", "self", ".", "original_sigterm", ")", "if", "os", ".", "name", "==", "'nt'", ":", "signal", ".", "signal", "(", "signal", ".", "SIGBREAK", ",", "self", ".", "original_sigbreak", ")" ]
Restore signal handlers to their original settings.
[ "Restore", "signal", "handlers", "to", "their", "original", "settings", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/transport/main.py#L102-L107
train
spyder-ide/spyder
spyder/requirements.py
show_warning
def show_warning(message): """Show warning using Tkinter if available""" try: # If Tkinter is installed (highly probable), showing an error pop-up import Tkinter, tkMessageBox root = Tkinter.Tk() root.withdraw() tkMessageBox.showerror("Spyder", message) except ImportError: pass raise RuntimeError(message)
python
def show_warning(message): """Show warning using Tkinter if available""" try: # If Tkinter is installed (highly probable), showing an error pop-up import Tkinter, tkMessageBox root = Tkinter.Tk() root.withdraw() tkMessageBox.showerror("Spyder", message) except ImportError: pass raise RuntimeError(message)
[ "def", "show_warning", "(", "message", ")", ":", "try", ":", "# If Tkinter is installed (highly probable), showing an error pop-up\r", "import", "Tkinter", ",", "tkMessageBox", "root", "=", "Tkinter", ".", "Tk", "(", ")", "root", ".", "withdraw", "(", ")", "tkMessageBox", ".", "showerror", "(", "\"Spyder\"", ",", "message", ")", "except", "ImportError", ":", "pass", "raise", "RuntimeError", "(", "message", ")" ]
Show warning using Tkinter if available
[ "Show", "warning", "using", "Tkinter", "if", "available" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/requirements.py#L14-L24
train
spyder-ide/spyder
spyder/requirements.py
check_path
def check_path(): """Check sys.path: is Spyder properly installed?""" dirname = osp.abspath(osp.join(osp.dirname(__file__), osp.pardir)) if dirname not in sys.path: show_warning("Spyder must be installed properly " "(e.g. from source: 'python setup.py install'),\n" "or directory '%s' must be in PYTHONPATH " "environment variable." % dirname)
python
def check_path(): """Check sys.path: is Spyder properly installed?""" dirname = osp.abspath(osp.join(osp.dirname(__file__), osp.pardir)) if dirname not in sys.path: show_warning("Spyder must be installed properly " "(e.g. from source: 'python setup.py install'),\n" "or directory '%s' must be in PYTHONPATH " "environment variable." % dirname)
[ "def", "check_path", "(", ")", ":", "dirname", "=", "osp", ".", "abspath", "(", "osp", ".", "join", "(", "osp", ".", "dirname", "(", "__file__", ")", ",", "osp", ".", "pardir", ")", ")", "if", "dirname", "not", "in", "sys", ".", "path", ":", "show_warning", "(", "\"Spyder must be installed properly \"", "\"(e.g. from source: 'python setup.py install'),\\n\"", "\"or directory '%s' must be in PYTHONPATH \"", "\"environment variable.\"", "%", "dirname", ")" ]
Check sys.path: is Spyder properly installed?
[ "Check", "sys", ".", "path", ":", "is", "Spyder", "properly", "installed?" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/requirements.py#L27-L34
train
spyder-ide/spyder
spyder/requirements.py
check_qt
def check_qt(): """Check Qt binding requirements""" qt_infos = dict(pyqt5=("PyQt5", "5.6")) try: import qtpy package_name, required_ver = qt_infos[qtpy.API] actual_ver = qtpy.PYQT_VERSION if LooseVersion(actual_ver) < LooseVersion(required_ver): show_warning("Please check Spyder installation requirements:\n" "%s %s+ is required (found v%s)." % (package_name, required_ver, actual_ver)) except ImportError: show_warning("Failed to import qtpy.\n" "Please check Spyder installation requirements:\n\n" "qtpy 1.2.0+ and\n" "%s %s+\n\n" "are required to run Spyder." % (qt_infos['pyqt5']))
python
def check_qt(): """Check Qt binding requirements""" qt_infos = dict(pyqt5=("PyQt5", "5.6")) try: import qtpy package_name, required_ver = qt_infos[qtpy.API] actual_ver = qtpy.PYQT_VERSION if LooseVersion(actual_ver) < LooseVersion(required_ver): show_warning("Please check Spyder installation requirements:\n" "%s %s+ is required (found v%s)." % (package_name, required_ver, actual_ver)) except ImportError: show_warning("Failed to import qtpy.\n" "Please check Spyder installation requirements:\n\n" "qtpy 1.2.0+ and\n" "%s %s+\n\n" "are required to run Spyder." % (qt_infos['pyqt5']))
[ "def", "check_qt", "(", ")", ":", "qt_infos", "=", "dict", "(", "pyqt5", "=", "(", "\"PyQt5\"", ",", "\"5.6\"", ")", ")", "try", ":", "import", "qtpy", "package_name", ",", "required_ver", "=", "qt_infos", "[", "qtpy", ".", "API", "]", "actual_ver", "=", "qtpy", ".", "PYQT_VERSION", "if", "LooseVersion", "(", "actual_ver", ")", "<", "LooseVersion", "(", "required_ver", ")", ":", "show_warning", "(", "\"Please check Spyder installation requirements:\\n\"", "\"%s %s+ is required (found v%s).\"", "%", "(", "package_name", ",", "required_ver", ",", "actual_ver", ")", ")", "except", "ImportError", ":", "show_warning", "(", "\"Failed to import qtpy.\\n\"", "\"Please check Spyder installation requirements:\\n\\n\"", "\"qtpy 1.2.0+ and\\n\"", "\"%s %s+\\n\\n\"", "\"are required to run Spyder.\"", "%", "(", "qt_infos", "[", "'pyqt5'", "]", ")", ")" ]
Check Qt binding requirements
[ "Check", "Qt", "binding", "requirements" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/requirements.py#L37-L54
train
spyder-ide/spyder
spyder/requirements.py
check_spyder_kernels
def check_spyder_kernels(): """Check spyder-kernel requirement.""" try: import spyder_kernels required_ver = '1.0.0' actual_ver = spyder_kernels.__version__ if LooseVersion(actual_ver) < LooseVersion(required_ver): show_warning("Please check Spyder installation requirements:\n" "spyder-kernels >= 1.0 is required (found %s)." % actual_ver) except ImportError: show_warning("Failed to import spyder-kernels.\n" "Please check Spyder installation requirements:\n\n" "spyder-kernels >= 1.0 is required")
python
def check_spyder_kernels(): """Check spyder-kernel requirement.""" try: import spyder_kernels required_ver = '1.0.0' actual_ver = spyder_kernels.__version__ if LooseVersion(actual_ver) < LooseVersion(required_ver): show_warning("Please check Spyder installation requirements:\n" "spyder-kernels >= 1.0 is required (found %s)." % actual_ver) except ImportError: show_warning("Failed to import spyder-kernels.\n" "Please check Spyder installation requirements:\n\n" "spyder-kernels >= 1.0 is required")
[ "def", "check_spyder_kernels", "(", ")", ":", "try", ":", "import", "spyder_kernels", "required_ver", "=", "'1.0.0'", "actual_ver", "=", "spyder_kernels", ".", "__version__", "if", "LooseVersion", "(", "actual_ver", ")", "<", "LooseVersion", "(", "required_ver", ")", ":", "show_warning", "(", "\"Please check Spyder installation requirements:\\n\"", "\"spyder-kernels >= 1.0 is required (found %s).\"", "%", "actual_ver", ")", "except", "ImportError", ":", "show_warning", "(", "\"Failed to import spyder-kernels.\\n\"", "\"Please check Spyder installation requirements:\\n\\n\"", "\"spyder-kernels >= 1.0 is required\"", ")" ]
Check spyder-kernel requirement.
[ "Check", "spyder", "-", "kernel", "requirement", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/requirements.py#L57-L70
train
spyder-ide/spyder
spyder/plugins/breakpoints/plugin.py
Breakpoints.register_plugin
def register_plugin(self): """Register plugin in Spyder's main window""" self.breakpoints.edit_goto.connect(self.main.editor.load) #self.redirect_stdio.connect(self.main.redirect_internalshell_stdio) self.breakpoints.clear_all_breakpoints.connect( self.main.editor.clear_all_breakpoints) self.breakpoints.clear_breakpoint.connect( self.main.editor.clear_breakpoint) self.main.editor.breakpoints_saved.connect(self.breakpoints.set_data) self.breakpoints.set_or_edit_conditional_breakpoint.connect( self.main.editor.set_or_edit_conditional_breakpoint) self.main.add_dockwidget(self) list_action = create_action(self, _("List breakpoints"), triggered=self.show) list_action.setEnabled(True) pos = self.main.debug_menu_actions.index('list_breakpoints') self.main.debug_menu_actions.insert(pos, list_action) self.main.editor.pythonfile_dependent_actions += [list_action]
python
def register_plugin(self): """Register plugin in Spyder's main window""" self.breakpoints.edit_goto.connect(self.main.editor.load) #self.redirect_stdio.connect(self.main.redirect_internalshell_stdio) self.breakpoints.clear_all_breakpoints.connect( self.main.editor.clear_all_breakpoints) self.breakpoints.clear_breakpoint.connect( self.main.editor.clear_breakpoint) self.main.editor.breakpoints_saved.connect(self.breakpoints.set_data) self.breakpoints.set_or_edit_conditional_breakpoint.connect( self.main.editor.set_or_edit_conditional_breakpoint) self.main.add_dockwidget(self) list_action = create_action(self, _("List breakpoints"), triggered=self.show) list_action.setEnabled(True) pos = self.main.debug_menu_actions.index('list_breakpoints') self.main.debug_menu_actions.insert(pos, list_action) self.main.editor.pythonfile_dependent_actions += [list_action]
[ "def", "register_plugin", "(", "self", ")", ":", "self", ".", "breakpoints", ".", "edit_goto", ".", "connect", "(", "self", ".", "main", ".", "editor", ".", "load", ")", "#self.redirect_stdio.connect(self.main.redirect_internalshell_stdio)\r", "self", ".", "breakpoints", ".", "clear_all_breakpoints", ".", "connect", "(", "self", ".", "main", ".", "editor", ".", "clear_all_breakpoints", ")", "self", ".", "breakpoints", ".", "clear_breakpoint", ".", "connect", "(", "self", ".", "main", ".", "editor", ".", "clear_breakpoint", ")", "self", ".", "main", ".", "editor", ".", "breakpoints_saved", ".", "connect", "(", "self", ".", "breakpoints", ".", "set_data", ")", "self", ".", "breakpoints", ".", "set_or_edit_conditional_breakpoint", ".", "connect", "(", "self", ".", "main", ".", "editor", ".", "set_or_edit_conditional_breakpoint", ")", "self", ".", "main", ".", "add_dockwidget", "(", "self", ")", "list_action", "=", "create_action", "(", "self", ",", "_", "(", "\"List breakpoints\"", ")", ",", "triggered", "=", "self", ".", "show", ")", "list_action", ".", "setEnabled", "(", "True", ")", "pos", "=", "self", ".", "main", ".", "debug_menu_actions", ".", "index", "(", "'list_breakpoints'", ")", "self", ".", "main", ".", "debug_menu_actions", ".", "insert", "(", "pos", ",", "list_action", ")", "self", ".", "main", ".", "editor", ".", "pythonfile_dependent_actions", "+=", "[", "list_action", "]" ]
Register plugin in Spyder's main window
[ "Register", "plugin", "in", "Spyder", "s", "main", "window" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/breakpoints/plugin.py#L77-L96
train
spyder-ide/spyder
spyder/utils/external/lockfile.py
isLocked
def isLocked(name): """Determine if the lock of the given name is held or not. @type name: C{str} @param name: The filesystem path to the lock to test @rtype: C{bool} @return: True if the lock is held, False otherwise. """ l = FilesystemLock(name) result = None try: result = l.lock() finally: if result: l.unlock() return not result
python
def isLocked(name): """Determine if the lock of the given name is held or not. @type name: C{str} @param name: The filesystem path to the lock to test @rtype: C{bool} @return: True if the lock is held, False otherwise. """ l = FilesystemLock(name) result = None try: result = l.lock() finally: if result: l.unlock() return not result
[ "def", "isLocked", "(", "name", ")", ":", "l", "=", "FilesystemLock", "(", "name", ")", "result", "=", "None", "try", ":", "result", "=", "l", ".", "lock", "(", ")", "finally", ":", "if", "result", ":", "l", ".", "unlock", "(", ")", "return", "not", "result" ]
Determine if the lock of the given name is held or not. @type name: C{str} @param name: The filesystem path to the lock to test @rtype: C{bool} @return: True if the lock is held, False otherwise.
[ "Determine", "if", "the", "lock", "of", "the", "given", "name", "is", "held", "or", "not", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/external/lockfile.py#L248-L264
train
spyder-ide/spyder
spyder/utils/external/lockfile.py
FilesystemLock.lock
def lock(self): """ Acquire this lock. @rtype: C{bool} @return: True if the lock is acquired, false otherwise. @raise: Any exception os.symlink() may raise, other than EEXIST. """ clean = True while True: try: symlink(str(os.getpid()), self.name) except OSError as e: if _windows and e.errno in (errno.EACCES, errno.EIO): # The lock is in the middle of being deleted because we're # on Windows where lock removal isn't atomic. Give up, we # don't know how long this is going to take. return False if e.errno == errno.EEXIST: try: pid = readlink(self.name) except OSError as e: if e.errno == errno.ENOENT: # The lock has vanished, try to claim it in the # next iteration through the loop. continue raise except IOError as e: if _windows and e.errno == errno.EACCES: # The lock is in the middle of being # deleted because we're on Windows where # lock removal isn't atomic. Give up, we # don't know how long this is going to # take. return False raise try: if kill is not None: kill(int(pid), 0) # Verify that the running process corresponds to # a Spyder one p = psutil.Process(int(pid)) # Valid names for main script names = set(['spyder', 'spyder3', 'spyder.exe', 'spyder3.exe', 'bootstrap.py', 'spyder-script.py']) if running_under_pytest(): names.add('runtests.py') # Check the first three command line arguments arguments = set(os.path.basename(arg) for arg in p.cmdline()[:3]) conditions = [names & arguments] if not any(conditions): raise(OSError(errno.ESRCH, 'No such process')) except OSError as e: if e.errno == errno.ESRCH: # The owner has vanished, try to claim it in the # next iteration through the loop. try: rmlink(self.name) except OSError as e: if e.errno == errno.ENOENT: # Another process cleaned up the lock. # Race them to acquire it in the next # iteration through the loop. continue raise clean = False continue raise return False raise self.locked = True self.clean = clean return True
python
def lock(self): """ Acquire this lock. @rtype: C{bool} @return: True if the lock is acquired, false otherwise. @raise: Any exception os.symlink() may raise, other than EEXIST. """ clean = True while True: try: symlink(str(os.getpid()), self.name) except OSError as e: if _windows and e.errno in (errno.EACCES, errno.EIO): # The lock is in the middle of being deleted because we're # on Windows where lock removal isn't atomic. Give up, we # don't know how long this is going to take. return False if e.errno == errno.EEXIST: try: pid = readlink(self.name) except OSError as e: if e.errno == errno.ENOENT: # The lock has vanished, try to claim it in the # next iteration through the loop. continue raise except IOError as e: if _windows and e.errno == errno.EACCES: # The lock is in the middle of being # deleted because we're on Windows where # lock removal isn't atomic. Give up, we # don't know how long this is going to # take. return False raise try: if kill is not None: kill(int(pid), 0) # Verify that the running process corresponds to # a Spyder one p = psutil.Process(int(pid)) # Valid names for main script names = set(['spyder', 'spyder3', 'spyder.exe', 'spyder3.exe', 'bootstrap.py', 'spyder-script.py']) if running_under_pytest(): names.add('runtests.py') # Check the first three command line arguments arguments = set(os.path.basename(arg) for arg in p.cmdline()[:3]) conditions = [names & arguments] if not any(conditions): raise(OSError(errno.ESRCH, 'No such process')) except OSError as e: if e.errno == errno.ESRCH: # The owner has vanished, try to claim it in the # next iteration through the loop. try: rmlink(self.name) except OSError as e: if e.errno == errno.ENOENT: # Another process cleaned up the lock. # Race them to acquire it in the next # iteration through the loop. continue raise clean = False continue raise return False raise self.locked = True self.clean = clean return True
[ "def", "lock", "(", "self", ")", ":", "clean", "=", "True", "while", "True", ":", "try", ":", "symlink", "(", "str", "(", "os", ".", "getpid", "(", ")", ")", ",", "self", ".", "name", ")", "except", "OSError", "as", "e", ":", "if", "_windows", "and", "e", ".", "errno", "in", "(", "errno", ".", "EACCES", ",", "errno", ".", "EIO", ")", ":", "# The lock is in the middle of being deleted because we're\r", "# on Windows where lock removal isn't atomic. Give up, we\r", "# don't know how long this is going to take.\r", "return", "False", "if", "e", ".", "errno", "==", "errno", ".", "EEXIST", ":", "try", ":", "pid", "=", "readlink", "(", "self", ".", "name", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "==", "errno", ".", "ENOENT", ":", "# The lock has vanished, try to claim it in the\r", "# next iteration through the loop.\r", "continue", "raise", "except", "IOError", "as", "e", ":", "if", "_windows", "and", "e", ".", "errno", "==", "errno", ".", "EACCES", ":", "# The lock is in the middle of being\r", "# deleted because we're on Windows where\r", "# lock removal isn't atomic. Give up, we\r", "# don't know how long this is going to\r", "# take.\r", "return", "False", "raise", "try", ":", "if", "kill", "is", "not", "None", ":", "kill", "(", "int", "(", "pid", ")", ",", "0", ")", "# Verify that the running process corresponds to\r", "# a Spyder one\r", "p", "=", "psutil", ".", "Process", "(", "int", "(", "pid", ")", ")", "# Valid names for main script\r", "names", "=", "set", "(", "[", "'spyder'", ",", "'spyder3'", ",", "'spyder.exe'", ",", "'spyder3.exe'", ",", "'bootstrap.py'", ",", "'spyder-script.py'", "]", ")", "if", "running_under_pytest", "(", ")", ":", "names", ".", "add", "(", "'runtests.py'", ")", "# Check the first three command line arguments\r", "arguments", "=", "set", "(", "os", ".", "path", ".", "basename", "(", "arg", ")", "for", "arg", "in", "p", ".", "cmdline", "(", ")", "[", ":", "3", "]", ")", "conditions", "=", "[", "names", "&", "arguments", "]", "if", "not", "any", "(", "conditions", ")", ":", "raise", "(", "OSError", "(", "errno", ".", "ESRCH", ",", "'No such process'", ")", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "==", "errno", ".", "ESRCH", ":", "# The owner has vanished, try to claim it in the\r", "# next iteration through the loop.\r", "try", ":", "rmlink", "(", "self", ".", "name", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "==", "errno", ".", "ENOENT", ":", "# Another process cleaned up the lock.\r", "# Race them to acquire it in the next\r", "# iteration through the loop.\r", "continue", "raise", "clean", "=", "False", "continue", "raise", "return", "False", "raise", "self", ".", "locked", "=", "True", "self", ".", "clean", "=", "clean", "return", "True" ]
Acquire this lock. @rtype: C{bool} @return: True if the lock is acquired, false otherwise. @raise: Any exception os.symlink() may raise, other than EEXIST.
[ "Acquire", "this", "lock", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/external/lockfile.py#L152-L230
train
spyder-ide/spyder
spyder/utils/external/lockfile.py
FilesystemLock.unlock
def unlock(self): """ Release this lock. This deletes the directory with the given name. @raise: Any exception os.readlink() may raise, or ValueError if the lock is not owned by this process. """ pid = readlink(self.name) if int(pid) != os.getpid(): raise ValueError("Lock %r not owned by this process" % (self.name,)) rmlink(self.name) self.locked = False
python
def unlock(self): """ Release this lock. This deletes the directory with the given name. @raise: Any exception os.readlink() may raise, or ValueError if the lock is not owned by this process. """ pid = readlink(self.name) if int(pid) != os.getpid(): raise ValueError("Lock %r not owned by this process" % (self.name,)) rmlink(self.name) self.locked = False
[ "def", "unlock", "(", "self", ")", ":", "pid", "=", "readlink", "(", "self", ".", "name", ")", "if", "int", "(", "pid", ")", "!=", "os", ".", "getpid", "(", ")", ":", "raise", "ValueError", "(", "\"Lock %r not owned by this process\"", "%", "(", "self", ".", "name", ",", ")", ")", "rmlink", "(", "self", ".", "name", ")", "self", ".", "locked", "=", "False" ]
Release this lock. This deletes the directory with the given name. @raise: Any exception os.readlink() may raise, or ValueError if the lock is not owned by this process.
[ "Release", "this", "lock", ".", "This", "deletes", "the", "directory", "with", "the", "given", "name", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/external/lockfile.py#L232-L245
train
spyder-ide/spyder
spyder/plugins/help/utils/sphinxthread.py
SphinxThread.render
def render(self, doc, context=None, math_option=False, img_path='', css_path=CSS_PATH): """Start thread to render a given documentation""" # If the thread is already running wait for it to finish before # starting it again. if self.wait(): self.doc = doc self.context = context self.math_option = math_option self.img_path = img_path self.css_path = css_path # This causes run() to be executed in separate thread self.start()
python
def render(self, doc, context=None, math_option=False, img_path='', css_path=CSS_PATH): """Start thread to render a given documentation""" # If the thread is already running wait for it to finish before # starting it again. if self.wait(): self.doc = doc self.context = context self.math_option = math_option self.img_path = img_path self.css_path = css_path # This causes run() to be executed in separate thread self.start()
[ "def", "render", "(", "self", ",", "doc", ",", "context", "=", "None", ",", "math_option", "=", "False", ",", "img_path", "=", "''", ",", "css_path", "=", "CSS_PATH", ")", ":", "# If the thread is already running wait for it to finish before", "# starting it again.", "if", "self", ".", "wait", "(", ")", ":", "self", ".", "doc", "=", "doc", "self", ".", "context", "=", "context", "self", ".", "math_option", "=", "math_option", "self", ".", "img_path", "=", "img_path", "self", ".", "css_path", "=", "css_path", "# This causes run() to be executed in separate thread", "self", ".", "start", "(", ")" ]
Start thread to render a given documentation
[ "Start", "thread", "to", "render", "a", "given", "documentation" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/utils/sphinxthread.py#L48-L60
train
spyder-ide/spyder
spyder/preferences/languageserver.py
LSPServersModel.sortByName
def sortByName(self): """Qt Override.""" self.servers = sorted(self.servers, key=lambda x: x.language) self.reset()
python
def sortByName(self): """Qt Override.""" self.servers = sorted(self.servers, key=lambda x: x.language) self.reset()
[ "def", "sortByName", "(", "self", ")", ":", "self", ".", "servers", "=", "sorted", "(", "self", ".", "servers", ",", "key", "=", "lambda", "x", ":", "x", ".", "language", ")", "self", ".", "reset", "(", ")" ]
Qt Override.
[ "Qt", "Override", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L413-L416
train
spyder-ide/spyder
spyder/preferences/languageserver.py
LSPServersModel.data
def data(self, index, role=Qt.DisplayRole): """Qt Override.""" row = index.row() if not index.isValid() or not (0 <= row < len(self.servers)): return to_qvariant() server = self.servers[row] column = index.column() if role == Qt.DisplayRole: if column == LANGUAGE: return to_qvariant(server.language) elif column == ADDR: text = '{0}:{1}'.format(server.host, server.port) return to_qvariant(text) elif column == CMD: text = '&nbsp;<tt style="color:{0}">{{0}} {{1}}</tt>' text = text.format(self.text_color) if server.external: text = '&nbsp;<tt>External server</tt>' return to_qvariant(text.format(server.cmd, server.args)) elif role == Qt.TextAlignmentRole: return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter)) return to_qvariant()
python
def data(self, index, role=Qt.DisplayRole): """Qt Override.""" row = index.row() if not index.isValid() or not (0 <= row < len(self.servers)): return to_qvariant() server = self.servers[row] column = index.column() if role == Qt.DisplayRole: if column == LANGUAGE: return to_qvariant(server.language) elif column == ADDR: text = '{0}:{1}'.format(server.host, server.port) return to_qvariant(text) elif column == CMD: text = '&nbsp;<tt style="color:{0}">{{0}} {{1}}</tt>' text = text.format(self.text_color) if server.external: text = '&nbsp;<tt>External server</tt>' return to_qvariant(text.format(server.cmd, server.args)) elif role == Qt.TextAlignmentRole: return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter)) return to_qvariant()
[ "def", "data", "(", "self", ",", "index", ",", "role", "=", "Qt", ".", "DisplayRole", ")", ":", "row", "=", "index", ".", "row", "(", ")", "if", "not", "index", ".", "isValid", "(", ")", "or", "not", "(", "0", "<=", "row", "<", "len", "(", "self", ".", "servers", ")", ")", ":", "return", "to_qvariant", "(", ")", "server", "=", "self", ".", "servers", "[", "row", "]", "column", "=", "index", ".", "column", "(", ")", "if", "role", "==", "Qt", ".", "DisplayRole", ":", "if", "column", "==", "LANGUAGE", ":", "return", "to_qvariant", "(", "server", ".", "language", ")", "elif", "column", "==", "ADDR", ":", "text", "=", "'{0}:{1}'", ".", "format", "(", "server", ".", "host", ",", "server", ".", "port", ")", "return", "to_qvariant", "(", "text", ")", "elif", "column", "==", "CMD", ":", "text", "=", "'&nbsp;<tt style=\"color:{0}\">{{0}} {{1}}</tt>'", "text", "=", "text", ".", "format", "(", "self", ".", "text_color", ")", "if", "server", ".", "external", ":", "text", "=", "'&nbsp;<tt>External server</tt>'", "return", "to_qvariant", "(", "text", ".", "format", "(", "server", ".", "cmd", ",", "server", ".", "args", ")", ")", "elif", "role", "==", "Qt", ".", "TextAlignmentRole", ":", "return", "to_qvariant", "(", "int", "(", "Qt", ".", "AlignHCenter", "|", "Qt", ".", "AlignVCenter", ")", ")", "return", "to_qvariant", "(", ")" ]
Qt Override.
[ "Qt", "Override", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L424-L447
train
spyder-ide/spyder
spyder/preferences/languageserver.py
LSPServersModel.headerData
def headerData(self, section, orientation, role=Qt.DisplayRole): """Qt Override.""" if role == Qt.TextAlignmentRole: if orientation == Qt.Horizontal: return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter)) return to_qvariant(int(Qt.AlignRight | Qt.AlignVCenter)) if role != Qt.DisplayRole: return to_qvariant() if orientation == Qt.Horizontal: if section == LANGUAGE: return to_qvariant(_("Language")) elif section == ADDR: return to_qvariant(_("Address")) elif section == CMD: return to_qvariant(_("Command to execute")) return to_qvariant()
python
def headerData(self, section, orientation, role=Qt.DisplayRole): """Qt Override.""" if role == Qt.TextAlignmentRole: if orientation == Qt.Horizontal: return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter)) return to_qvariant(int(Qt.AlignRight | Qt.AlignVCenter)) if role != Qt.DisplayRole: return to_qvariant() if orientation == Qt.Horizontal: if section == LANGUAGE: return to_qvariant(_("Language")) elif section == ADDR: return to_qvariant(_("Address")) elif section == CMD: return to_qvariant(_("Command to execute")) return to_qvariant()
[ "def", "headerData", "(", "self", ",", "section", ",", "orientation", ",", "role", "=", "Qt", ".", "DisplayRole", ")", ":", "if", "role", "==", "Qt", ".", "TextAlignmentRole", ":", "if", "orientation", "==", "Qt", ".", "Horizontal", ":", "return", "to_qvariant", "(", "int", "(", "Qt", ".", "AlignHCenter", "|", "Qt", ".", "AlignVCenter", ")", ")", "return", "to_qvariant", "(", "int", "(", "Qt", ".", "AlignRight", "|", "Qt", ".", "AlignVCenter", ")", ")", "if", "role", "!=", "Qt", ".", "DisplayRole", ":", "return", "to_qvariant", "(", ")", "if", "orientation", "==", "Qt", ".", "Horizontal", ":", "if", "section", "==", "LANGUAGE", ":", "return", "to_qvariant", "(", "_", "(", "\"Language\"", ")", ")", "elif", "section", "==", "ADDR", ":", "return", "to_qvariant", "(", "_", "(", "\"Address\"", ")", ")", "elif", "section", "==", "CMD", ":", "return", "to_qvariant", "(", "_", "(", "\"Command to execute\"", ")", ")", "return", "to_qvariant", "(", ")" ]
Qt Override.
[ "Qt", "Override", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L449-L464
train
spyder-ide/spyder
spyder/preferences/languageserver.py
LSPServerTable.focusInEvent
def focusInEvent(self, e): """Qt Override.""" super(LSPServerTable, self).focusInEvent(e) self.selectRow(self.currentIndex().row())
python
def focusInEvent(self, e): """Qt Override.""" super(LSPServerTable, self).focusInEvent(e) self.selectRow(self.currentIndex().row())
[ "def", "focusInEvent", "(", "self", ",", "e", ")", ":", "super", "(", "LSPServerTable", ",", "self", ")", ".", "focusInEvent", "(", "e", ")", "self", ".", "selectRow", "(", "self", ".", "currentIndex", "(", ")", ".", "row", "(", ")", ")" ]
Qt Override.
[ "Qt", "Override", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L507-L510
train
spyder-ide/spyder
spyder/preferences/languageserver.py
LSPServerTable.selection
def selection(self, index): """Update selected row.""" self.update() self.isActiveWindow() self._parent.delete_btn.setEnabled(True)
python
def selection(self, index): """Update selected row.""" self.update() self.isActiveWindow() self._parent.delete_btn.setEnabled(True)
[ "def", "selection", "(", "self", ",", "index", ")", ":", "self", ".", "update", "(", ")", "self", ".", "isActiveWindow", "(", ")", "self", ".", "_parent", ".", "delete_btn", ".", "setEnabled", "(", "True", ")" ]
Update selected row.
[ "Update", "selected", "row", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L512-L516
train
spyder-ide/spyder
spyder/preferences/languageserver.py
LSPServerTable.adjust_cells
def adjust_cells(self): """Adjust column size based on contents.""" self.resizeColumnsToContents() fm = self.horizontalHeader().fontMetrics() names = [fm.width(s.cmd) for s in self.source_model.servers] if names: self.setColumnWidth(CMD, max(names)) self.horizontalHeader().setStretchLastSection(True)
python
def adjust_cells(self): """Adjust column size based on contents.""" self.resizeColumnsToContents() fm = self.horizontalHeader().fontMetrics() names = [fm.width(s.cmd) for s in self.source_model.servers] if names: self.setColumnWidth(CMD, max(names)) self.horizontalHeader().setStretchLastSection(True)
[ "def", "adjust_cells", "(", "self", ")", ":", "self", ".", "resizeColumnsToContents", "(", ")", "fm", "=", "self", ".", "horizontalHeader", "(", ")", ".", "fontMetrics", "(", ")", "names", "=", "[", "fm", ".", "width", "(", "s", ".", "cmd", ")", "for", "s", "in", "self", ".", "source_model", ".", "servers", "]", "if", "names", ":", "self", ".", "setColumnWidth", "(", "CMD", ",", "max", "(", "names", ")", ")", "self", ".", "horizontalHeader", "(", ")", ".", "setStretchLastSection", "(", "True", ")" ]
Adjust column size based on contents.
[ "Adjust", "column", "size", "based", "on", "contents", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L518-L525
train
spyder-ide/spyder
spyder/preferences/languageserver.py
LSPServerTable.next_row
def next_row(self): """Move to next row from currently selected row.""" row = self.currentIndex().row() rows = self.source_model.rowCount() if row + 1 == rows: row = -1 self.selectRow(row + 1)
python
def next_row(self): """Move to next row from currently selected row.""" row = self.currentIndex().row() rows = self.source_model.rowCount() if row + 1 == rows: row = -1 self.selectRow(row + 1)
[ "def", "next_row", "(", "self", ")", ":", "row", "=", "self", ".", "currentIndex", "(", ")", ".", "row", "(", ")", "rows", "=", "self", ".", "source_model", ".", "rowCount", "(", ")", "if", "row", "+", "1", "==", "rows", ":", "row", "=", "-", "1", "self", ".", "selectRow", "(", "row", "+", "1", ")" ]
Move to next row from currently selected row.
[ "Move", "to", "next", "row", "from", "currently", "selected", "row", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L573-L579
train
spyder-ide/spyder
spyder/preferences/languageserver.py
LSPServerTable.previous_row
def previous_row(self): """Move to previous row from currently selected row.""" row = self.currentIndex().row() rows = self.source_model.rowCount() if row == 0: row = rows self.selectRow(row - 1)
python
def previous_row(self): """Move to previous row from currently selected row.""" row = self.currentIndex().row() rows = self.source_model.rowCount() if row == 0: row = rows self.selectRow(row - 1)
[ "def", "previous_row", "(", "self", ")", ":", "row", "=", "self", ".", "currentIndex", "(", ")", ".", "row", "(", ")", "rows", "=", "self", ".", "source_model", ".", "rowCount", "(", ")", "if", "row", "==", "0", ":", "row", "=", "rows", "self", ".", "selectRow", "(", "row", "-", "1", ")" ]
Move to previous row from currently selected row.
[ "Move", "to", "previous", "row", "from", "currently", "selected", "row", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L581-L587
train
spyder-ide/spyder
spyder/preferences/languageserver.py
LSPServerTable.keyPressEvent
def keyPressEvent(self, event): """Qt Override.""" key = event.key() if key in [Qt.Key_Enter, Qt.Key_Return]: self.show_editor() elif key in [Qt.Key_Backtab]: self.parent().reset_btn.setFocus() elif key in [Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right]: super(LSPServerTable, self).keyPressEvent(event) elif key in [Qt.Key_Escape]: self.finder.keyPressEvent(event) else: super(LSPServerTable, self).keyPressEvent(event)
python
def keyPressEvent(self, event): """Qt Override.""" key = event.key() if key in [Qt.Key_Enter, Qt.Key_Return]: self.show_editor() elif key in [Qt.Key_Backtab]: self.parent().reset_btn.setFocus() elif key in [Qt.Key_Up, Qt.Key_Down, Qt.Key_Left, Qt.Key_Right]: super(LSPServerTable, self).keyPressEvent(event) elif key in [Qt.Key_Escape]: self.finder.keyPressEvent(event) else: super(LSPServerTable, self).keyPressEvent(event)
[ "def", "keyPressEvent", "(", "self", ",", "event", ")", ":", "key", "=", "event", ".", "key", "(", ")", "if", "key", "in", "[", "Qt", ".", "Key_Enter", ",", "Qt", ".", "Key_Return", "]", ":", "self", ".", "show_editor", "(", ")", "elif", "key", "in", "[", "Qt", ".", "Key_Backtab", "]", ":", "self", ".", "parent", "(", ")", ".", "reset_btn", ".", "setFocus", "(", ")", "elif", "key", "in", "[", "Qt", ".", "Key_Up", ",", "Qt", ".", "Key_Down", ",", "Qt", ".", "Key_Left", ",", "Qt", ".", "Key_Right", "]", ":", "super", "(", "LSPServerTable", ",", "self", ")", ".", "keyPressEvent", "(", "event", ")", "elif", "key", "in", "[", "Qt", ".", "Key_Escape", "]", ":", "self", ".", "finder", ".", "keyPressEvent", "(", "event", ")", "else", ":", "super", "(", "LSPServerTable", ",", "self", ")", ".", "keyPressEvent", "(", "event", ")" ]
Qt Override.
[ "Qt", "Override", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L589-L601
train
spyder-ide/spyder
spyder/preferences/languageserver.py
LSPManagerConfigPage.setup_docstring_style_convention
def setup_docstring_style_convention(self, text): """Handle convention changes.""" if text == 'Custom': self.docstring_style_select.label.setText( _("Show the following errors:")) self.docstring_style_ignore.label.setText( _("Ignore the following errors:")) else: self.docstring_style_select.label.setText( _("Show the following errors in addition " "to the specified convention:")) self.docstring_style_ignore.label.setText( _("Ignore the following errors in addition " "to the specified convention:"))
python
def setup_docstring_style_convention(self, text): """Handle convention changes.""" if text == 'Custom': self.docstring_style_select.label.setText( _("Show the following errors:")) self.docstring_style_ignore.label.setText( _("Ignore the following errors:")) else: self.docstring_style_select.label.setText( _("Show the following errors in addition " "to the specified convention:")) self.docstring_style_ignore.label.setText( _("Ignore the following errors in addition " "to the specified convention:"))
[ "def", "setup_docstring_style_convention", "(", "self", ",", "text", ")", ":", "if", "text", "==", "'Custom'", ":", "self", ".", "docstring_style_select", ".", "label", ".", "setText", "(", "_", "(", "\"Show the following errors:\"", ")", ")", "self", ".", "docstring_style_ignore", ".", "label", ".", "setText", "(", "_", "(", "\"Ignore the following errors:\"", ")", ")", "else", ":", "self", ".", "docstring_style_select", ".", "label", ".", "setText", "(", "_", "(", "\"Show the following errors in addition \"", "\"to the specified convention:\"", ")", ")", "self", ".", "docstring_style_ignore", ".", "label", ".", "setText", "(", "_", "(", "\"Ignore the following errors in addition \"", "\"to the specified convention:\"", ")", ")" ]
Handle convention changes.
[ "Handle", "convention", "changes", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L955-L968
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
SearchInComboBox.add_external_path
def add_external_path(self, path): """ Adds an external path to the combobox if it exists on the file system. If the path is already listed in the combobox, it is removed from its current position and added back at the end. If the maximum number of paths is reached, the oldest external path is removed from the list. """ if not osp.exists(path): return self.removeItem(self.findText(path)) self.addItem(path) self.setItemData(self.count() - 1, path, Qt.ToolTipRole) while self.count() > MAX_PATH_HISTORY + EXTERNAL_PATHS: self.removeItem(EXTERNAL_PATHS)
python
def add_external_path(self, path): """ Adds an external path to the combobox if it exists on the file system. If the path is already listed in the combobox, it is removed from its current position and added back at the end. If the maximum number of paths is reached, the oldest external path is removed from the list. """ if not osp.exists(path): return self.removeItem(self.findText(path)) self.addItem(path) self.setItemData(self.count() - 1, path, Qt.ToolTipRole) while self.count() > MAX_PATH_HISTORY + EXTERNAL_PATHS: self.removeItem(EXTERNAL_PATHS)
[ "def", "add_external_path", "(", "self", ",", "path", ")", ":", "if", "not", "osp", ".", "exists", "(", "path", ")", ":", "return", "self", ".", "removeItem", "(", "self", ".", "findText", "(", "path", ")", ")", "self", ".", "addItem", "(", "path", ")", "self", ".", "setItemData", "(", "self", ".", "count", "(", ")", "-", "1", ",", "path", ",", "Qt", ".", "ToolTipRole", ")", "while", "self", ".", "count", "(", ")", ">", "MAX_PATH_HISTORY", "+", "EXTERNAL_PATHS", ":", "self", ".", "removeItem", "(", "EXTERNAL_PATHS", ")" ]
Adds an external path to the combobox if it exists on the file system. If the path is already listed in the combobox, it is removed from its current position and added back at the end. If the maximum number of paths is reached, the oldest external path is removed from the list.
[ "Adds", "an", "external", "path", "to", "the", "combobox", "if", "it", "exists", "on", "the", "file", "system", ".", "If", "the", "path", "is", "already", "listed", "in", "the", "combobox", "it", "is", "removed", "from", "its", "current", "position", "and", "added", "back", "at", "the", "end", ".", "If", "the", "maximum", "number", "of", "paths", "is", "reached", "the", "oldest", "external", "path", "is", "removed", "from", "the", "list", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L273-L286
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
SearchInComboBox.get_external_paths
def get_external_paths(self): """Returns a list of the external paths listed in the combobox.""" return [to_text_string(self.itemText(i)) for i in range(EXTERNAL_PATHS, self.count())]
python
def get_external_paths(self): """Returns a list of the external paths listed in the combobox.""" return [to_text_string(self.itemText(i)) for i in range(EXTERNAL_PATHS, self.count())]
[ "def", "get_external_paths", "(", "self", ")", ":", "return", "[", "to_text_string", "(", "self", ".", "itemText", "(", "i", ")", ")", "for", "i", "in", "range", "(", "EXTERNAL_PATHS", ",", "self", ".", "count", "(", ")", ")", "]" ]
Returns a list of the external paths listed in the combobox.
[ "Returns", "a", "list", "of", "the", "external", "paths", "listed", "in", "the", "combobox", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L288-L291
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
SearchInComboBox.get_current_searchpath
def get_current_searchpath(self): """ Returns the path corresponding to the currently selected item in the combobox. """ idx = self.currentIndex() if idx == CWD: return self.path elif idx == PROJECT: return self.project_path elif idx == FILE_PATH: return self.file_path else: return self.external_path
python
def get_current_searchpath(self): """ Returns the path corresponding to the currently selected item in the combobox. """ idx = self.currentIndex() if idx == CWD: return self.path elif idx == PROJECT: return self.project_path elif idx == FILE_PATH: return self.file_path else: return self.external_path
[ "def", "get_current_searchpath", "(", "self", ")", ":", "idx", "=", "self", ".", "currentIndex", "(", ")", "if", "idx", "==", "CWD", ":", "return", "self", ".", "path", "elif", "idx", "==", "PROJECT", ":", "return", "self", ".", "project_path", "elif", "idx", "==", "FILE_PATH", ":", "return", "self", ".", "file_path", "else", ":", "return", "self", ".", "external_path" ]
Returns the path corresponding to the currently selected item in the combobox.
[ "Returns", "the", "path", "corresponding", "to", "the", "currently", "selected", "item", "in", "the", "combobox", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L298-L311
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
SearchInComboBox.path_selection_changed
def path_selection_changed(self): """Handles when the current index of the combobox changes.""" idx = self.currentIndex() if idx == SELECT_OTHER: external_path = self.select_directory() if len(external_path) > 0: self.add_external_path(external_path) self.setCurrentIndex(self.count() - 1) else: self.setCurrentIndex(CWD) elif idx == CLEAR_LIST: reply = QMessageBox.question( self, _("Clear other directories"), _("Do you want to clear the list of other directories?"), QMessageBox.Yes | QMessageBox.No) if reply == QMessageBox.Yes: self.clear_external_paths() self.setCurrentIndex(CWD) elif idx >= EXTERNAL_PATHS: self.external_path = to_text_string(self.itemText(idx))
python
def path_selection_changed(self): """Handles when the current index of the combobox changes.""" idx = self.currentIndex() if idx == SELECT_OTHER: external_path = self.select_directory() if len(external_path) > 0: self.add_external_path(external_path) self.setCurrentIndex(self.count() - 1) else: self.setCurrentIndex(CWD) elif idx == CLEAR_LIST: reply = QMessageBox.question( self, _("Clear other directories"), _("Do you want to clear the list of other directories?"), QMessageBox.Yes | QMessageBox.No) if reply == QMessageBox.Yes: self.clear_external_paths() self.setCurrentIndex(CWD) elif idx >= EXTERNAL_PATHS: self.external_path = to_text_string(self.itemText(idx))
[ "def", "path_selection_changed", "(", "self", ")", ":", "idx", "=", "self", ".", "currentIndex", "(", ")", "if", "idx", "==", "SELECT_OTHER", ":", "external_path", "=", "self", ".", "select_directory", "(", ")", "if", "len", "(", "external_path", ")", ">", "0", ":", "self", ".", "add_external_path", "(", "external_path", ")", "self", ".", "setCurrentIndex", "(", "self", ".", "count", "(", ")", "-", "1", ")", "else", ":", "self", ".", "setCurrentIndex", "(", "CWD", ")", "elif", "idx", "==", "CLEAR_LIST", ":", "reply", "=", "QMessageBox", ".", "question", "(", "self", ",", "_", "(", "\"Clear other directories\"", ")", ",", "_", "(", "\"Do you want to clear the list of other directories?\"", ")", ",", "QMessageBox", ".", "Yes", "|", "QMessageBox", ".", "No", ")", "if", "reply", "==", "QMessageBox", ".", "Yes", ":", "self", ".", "clear_external_paths", "(", ")", "self", ".", "setCurrentIndex", "(", "CWD", ")", "elif", "idx", ">=", "EXTERNAL_PATHS", ":", "self", ".", "external_path", "=", "to_text_string", "(", "self", ".", "itemText", "(", "idx", ")", ")" ]
Handles when the current index of the combobox changes.
[ "Handles", "when", "the", "current", "index", "of", "the", "combobox", "changes", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L321-L340
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
SearchInComboBox.select_directory
def select_directory(self): """Select directory""" self.__redirect_stdio_emit(False) directory = getexistingdirectory( self, _("Select directory"), self.path) if directory: directory = to_unicode_from_fs(osp.abspath(directory)) self.__redirect_stdio_emit(True) return directory
python
def select_directory(self): """Select directory""" self.__redirect_stdio_emit(False) directory = getexistingdirectory( self, _("Select directory"), self.path) if directory: directory = to_unicode_from_fs(osp.abspath(directory)) self.__redirect_stdio_emit(True) return directory
[ "def", "select_directory", "(", "self", ")", ":", "self", ".", "__redirect_stdio_emit", "(", "False", ")", "directory", "=", "getexistingdirectory", "(", "self", ",", "_", "(", "\"Select directory\"", ")", ",", "self", ".", "path", ")", "if", "directory", ":", "directory", "=", "to_unicode_from_fs", "(", "osp", ".", "abspath", "(", "directory", ")", ")", "self", ".", "__redirect_stdio_emit", "(", "True", ")", "return", "directory" ]
Select directory
[ "Select", "directory" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L343-L351
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
SearchInComboBox.set_project_path
def set_project_path(self, path): """ Sets the project path and disables the project search in the combobox if the value of path is None. """ if path is None: self.project_path = None self.model().item(PROJECT, 0).setEnabled(False) if self.currentIndex() == PROJECT: self.setCurrentIndex(CWD) else: path = osp.abspath(path) self.project_path = path self.model().item(PROJECT, 0).setEnabled(True)
python
def set_project_path(self, path): """ Sets the project path and disables the project search in the combobox if the value of path is None. """ if path is None: self.project_path = None self.model().item(PROJECT, 0).setEnabled(False) if self.currentIndex() == PROJECT: self.setCurrentIndex(CWD) else: path = osp.abspath(path) self.project_path = path self.model().item(PROJECT, 0).setEnabled(True)
[ "def", "set_project_path", "(", "self", ",", "path", ")", ":", "if", "path", "is", "None", ":", "self", ".", "project_path", "=", "None", "self", ".", "model", "(", ")", ".", "item", "(", "PROJECT", ",", "0", ")", ".", "setEnabled", "(", "False", ")", "if", "self", ".", "currentIndex", "(", ")", "==", "PROJECT", ":", "self", ".", "setCurrentIndex", "(", "CWD", ")", "else", ":", "path", "=", "osp", ".", "abspath", "(", "path", ")", "self", ".", "project_path", "=", "path", "self", ".", "model", "(", ")", ".", "item", "(", "PROJECT", ",", "0", ")", ".", "setEnabled", "(", "True", ")" ]
Sets the project path and disables the project search in the combobox if the value of path is None.
[ "Sets", "the", "project", "path", "and", "disables", "the", "project", "search", "in", "the", "combobox", "if", "the", "value", "of", "path", "is", "None", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L353-L366
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
SearchInComboBox.eventFilter
def eventFilter(self, widget, event): """Used to handle key events on the QListView of the combobox.""" if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Delete: index = self.view().currentIndex().row() if index >= EXTERNAL_PATHS: # Remove item and update the view. self.removeItem(index) self.showPopup() # Set the view selection so that it doesn't bounce around. new_index = min(self.count() - 1, index) new_index = 0 if new_index < EXTERNAL_PATHS else new_index self.view().setCurrentIndex(self.model().index(new_index, 0)) self.setCurrentIndex(new_index) return True return QComboBox.eventFilter(self, widget, event)
python
def eventFilter(self, widget, event): """Used to handle key events on the QListView of the combobox.""" if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Delete: index = self.view().currentIndex().row() if index >= EXTERNAL_PATHS: # Remove item and update the view. self.removeItem(index) self.showPopup() # Set the view selection so that it doesn't bounce around. new_index = min(self.count() - 1, index) new_index = 0 if new_index < EXTERNAL_PATHS else new_index self.view().setCurrentIndex(self.model().index(new_index, 0)) self.setCurrentIndex(new_index) return True return QComboBox.eventFilter(self, widget, event)
[ "def", "eventFilter", "(", "self", ",", "widget", ",", "event", ")", ":", "if", "event", ".", "type", "(", ")", "==", "QEvent", ".", "KeyPress", "and", "event", ".", "key", "(", ")", "==", "Qt", ".", "Key_Delete", ":", "index", "=", "self", ".", "view", "(", ")", ".", "currentIndex", "(", ")", ".", "row", "(", ")", "if", "index", ">=", "EXTERNAL_PATHS", ":", "# Remove item and update the view.\r", "self", ".", "removeItem", "(", "index", ")", "self", ".", "showPopup", "(", ")", "# Set the view selection so that it doesn't bounce around.\r", "new_index", "=", "min", "(", "self", ".", "count", "(", ")", "-", "1", ",", "index", ")", "new_index", "=", "0", "if", "new_index", "<", "EXTERNAL_PATHS", "else", "new_index", "self", ".", "view", "(", ")", ".", "setCurrentIndex", "(", "self", ".", "model", "(", ")", ".", "index", "(", "new_index", ",", "0", ")", ")", "self", ".", "setCurrentIndex", "(", "new_index", ")", "return", "True", "return", "QComboBox", ".", "eventFilter", "(", "self", ",", "widget", ",", "event", ")" ]
Used to handle key events on the QListView of the combobox.
[ "Used", "to", "handle", "key", "events", "on", "the", "QListView", "of", "the", "combobox", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L368-L382
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
SearchInComboBox.__redirect_stdio_emit
def __redirect_stdio_emit(self, value): """ Searches through the parent tree to see if it is possible to emit the redirect_stdio signal. This logic allows to test the SearchInComboBox select_directory method outside of the FindInFiles plugin. """ parent = self.parent() while parent is not None: try: parent.redirect_stdio.emit(value) except AttributeError: parent = parent.parent() else: break
python
def __redirect_stdio_emit(self, value): """ Searches through the parent tree to see if it is possible to emit the redirect_stdio signal. This logic allows to test the SearchInComboBox select_directory method outside of the FindInFiles plugin. """ parent = self.parent() while parent is not None: try: parent.redirect_stdio.emit(value) except AttributeError: parent = parent.parent() else: break
[ "def", "__redirect_stdio_emit", "(", "self", ",", "value", ")", ":", "parent", "=", "self", ".", "parent", "(", ")", "while", "parent", "is", "not", "None", ":", "try", ":", "parent", ".", "redirect_stdio", ".", "emit", "(", "value", ")", "except", "AttributeError", ":", "parent", "=", "parent", ".", "parent", "(", ")", "else", ":", "break" ]
Searches through the parent tree to see if it is possible to emit the redirect_stdio signal. This logic allows to test the SearchInComboBox select_directory method outside of the FindInFiles plugin.
[ "Searches", "through", "the", "parent", "tree", "to", "see", "if", "it", "is", "possible", "to", "emit", "the", "redirect_stdio", "signal", ".", "This", "logic", "allows", "to", "test", "the", "SearchInComboBox", "select_directory", "method", "outside", "of", "the", "FindInFiles", "plugin", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L384-L398
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
FindOptions.get_options
def get_options(self, to_save=False): """Get options""" text_re = self.edit_regexp.isChecked() exclude_re = self.exclude_regexp.isChecked() case_sensitive = self.case_button.isChecked() # Return current options for them to be saved when closing # Spyder. if to_save: search_text = [to_text_string(self.search_text.itemText(index)) for index in range(self.search_text.count())] exclude = [to_text_string(self.exclude_pattern.itemText(index)) for index in range(self.exclude_pattern.count())] exclude_idx = self.exclude_pattern.currentIndex() path_history = self.path_selection_combo.get_external_paths() more_options = self.more_options.isChecked() return (search_text, text_re, exclude, exclude_idx, exclude_re, more_options, case_sensitive, path_history) # Clear fields self.search_text.lineEdit().setStyleSheet("") self.exclude_pattern.lineEdit().setStyleSheet("") self.search_text.setToolTip("") self.exclude_pattern.setToolTip("") utext = to_text_string(self.search_text.currentText()) if not utext: return try: texts = [(utext.encode('utf-8'), 'utf-8')] except UnicodeEncodeError: texts = [] for enc in self.supported_encodings: try: texts.append((utext.encode(enc), enc)) except UnicodeDecodeError: pass exclude = to_text_string(self.exclude_pattern.currentText()) if not case_sensitive: texts = [(text[0].lower(), text[1]) for text in texts] file_search = self.path_selection_combo.is_file_search() path = self.path_selection_combo.get_current_searchpath() if not exclude_re: items = [fnmatch.translate(item.strip()) for item in exclude.split(",") if item.strip() != ''] exclude = '|'.join(items) # Validate exclude regular expression if exclude: error_msg = regexp_error_msg(exclude) if error_msg: exclude_edit = self.exclude_pattern.lineEdit() exclude_edit.setStyleSheet(self.REGEX_INVALID) tooltip = self.REGEX_ERROR + u': ' + to_text_string(error_msg) self.exclude_pattern.setToolTip(tooltip) return None else: exclude = re.compile(exclude) # Validate text regular expression if text_re: error_msg = regexp_error_msg(texts[0][0]) if error_msg: self.search_text.lineEdit().setStyleSheet(self.REGEX_INVALID) tooltip = self.REGEX_ERROR + u': ' + to_text_string(error_msg) self.search_text.setToolTip(tooltip) return None else: texts = [(re.compile(x[0]), x[1]) for x in texts] return (path, file_search, exclude, texts, text_re, case_sensitive)
python
def get_options(self, to_save=False): """Get options""" text_re = self.edit_regexp.isChecked() exclude_re = self.exclude_regexp.isChecked() case_sensitive = self.case_button.isChecked() # Return current options for them to be saved when closing # Spyder. if to_save: search_text = [to_text_string(self.search_text.itemText(index)) for index in range(self.search_text.count())] exclude = [to_text_string(self.exclude_pattern.itemText(index)) for index in range(self.exclude_pattern.count())] exclude_idx = self.exclude_pattern.currentIndex() path_history = self.path_selection_combo.get_external_paths() more_options = self.more_options.isChecked() return (search_text, text_re, exclude, exclude_idx, exclude_re, more_options, case_sensitive, path_history) # Clear fields self.search_text.lineEdit().setStyleSheet("") self.exclude_pattern.lineEdit().setStyleSheet("") self.search_text.setToolTip("") self.exclude_pattern.setToolTip("") utext = to_text_string(self.search_text.currentText()) if not utext: return try: texts = [(utext.encode('utf-8'), 'utf-8')] except UnicodeEncodeError: texts = [] for enc in self.supported_encodings: try: texts.append((utext.encode(enc), enc)) except UnicodeDecodeError: pass exclude = to_text_string(self.exclude_pattern.currentText()) if not case_sensitive: texts = [(text[0].lower(), text[1]) for text in texts] file_search = self.path_selection_combo.is_file_search() path = self.path_selection_combo.get_current_searchpath() if not exclude_re: items = [fnmatch.translate(item.strip()) for item in exclude.split(",") if item.strip() != ''] exclude = '|'.join(items) # Validate exclude regular expression if exclude: error_msg = regexp_error_msg(exclude) if error_msg: exclude_edit = self.exclude_pattern.lineEdit() exclude_edit.setStyleSheet(self.REGEX_INVALID) tooltip = self.REGEX_ERROR + u': ' + to_text_string(error_msg) self.exclude_pattern.setToolTip(tooltip) return None else: exclude = re.compile(exclude) # Validate text regular expression if text_re: error_msg = regexp_error_msg(texts[0][0]) if error_msg: self.search_text.lineEdit().setStyleSheet(self.REGEX_INVALID) tooltip = self.REGEX_ERROR + u': ' + to_text_string(error_msg) self.search_text.setToolTip(tooltip) return None else: texts = [(re.compile(x[0]), x[1]) for x in texts] return (path, file_search, exclude, texts, text_re, case_sensitive)
[ "def", "get_options", "(", "self", ",", "to_save", "=", "False", ")", ":", "text_re", "=", "self", ".", "edit_regexp", ".", "isChecked", "(", ")", "exclude_re", "=", "self", ".", "exclude_regexp", ".", "isChecked", "(", ")", "case_sensitive", "=", "self", ".", "case_button", ".", "isChecked", "(", ")", "# Return current options for them to be saved when closing\r", "# Spyder.\r", "if", "to_save", ":", "search_text", "=", "[", "to_text_string", "(", "self", ".", "search_text", ".", "itemText", "(", "index", ")", ")", "for", "index", "in", "range", "(", "self", ".", "search_text", ".", "count", "(", ")", ")", "]", "exclude", "=", "[", "to_text_string", "(", "self", ".", "exclude_pattern", ".", "itemText", "(", "index", ")", ")", "for", "index", "in", "range", "(", "self", ".", "exclude_pattern", ".", "count", "(", ")", ")", "]", "exclude_idx", "=", "self", ".", "exclude_pattern", ".", "currentIndex", "(", ")", "path_history", "=", "self", ".", "path_selection_combo", ".", "get_external_paths", "(", ")", "more_options", "=", "self", ".", "more_options", ".", "isChecked", "(", ")", "return", "(", "search_text", ",", "text_re", ",", "exclude", ",", "exclude_idx", ",", "exclude_re", ",", "more_options", ",", "case_sensitive", ",", "path_history", ")", "# Clear fields\r", "self", ".", "search_text", ".", "lineEdit", "(", ")", ".", "setStyleSheet", "(", "\"\"", ")", "self", ".", "exclude_pattern", ".", "lineEdit", "(", ")", ".", "setStyleSheet", "(", "\"\"", ")", "self", ".", "search_text", ".", "setToolTip", "(", "\"\"", ")", "self", ".", "exclude_pattern", ".", "setToolTip", "(", "\"\"", ")", "utext", "=", "to_text_string", "(", "self", ".", "search_text", ".", "currentText", "(", ")", ")", "if", "not", "utext", ":", "return", "try", ":", "texts", "=", "[", "(", "utext", ".", "encode", "(", "'utf-8'", ")", ",", "'utf-8'", ")", "]", "except", "UnicodeEncodeError", ":", "texts", "=", "[", "]", "for", "enc", "in", "self", ".", "supported_encodings", ":", "try", ":", "texts", ".", "append", "(", "(", "utext", ".", "encode", "(", "enc", ")", ",", "enc", ")", ")", "except", "UnicodeDecodeError", ":", "pass", "exclude", "=", "to_text_string", "(", "self", ".", "exclude_pattern", ".", "currentText", "(", ")", ")", "if", "not", "case_sensitive", ":", "texts", "=", "[", "(", "text", "[", "0", "]", ".", "lower", "(", ")", ",", "text", "[", "1", "]", ")", "for", "text", "in", "texts", "]", "file_search", "=", "self", ".", "path_selection_combo", ".", "is_file_search", "(", ")", "path", "=", "self", ".", "path_selection_combo", ".", "get_current_searchpath", "(", ")", "if", "not", "exclude_re", ":", "items", "=", "[", "fnmatch", ".", "translate", "(", "item", ".", "strip", "(", ")", ")", "for", "item", "in", "exclude", ".", "split", "(", "\",\"", ")", "if", "item", ".", "strip", "(", ")", "!=", "''", "]", "exclude", "=", "'|'", ".", "join", "(", "items", ")", "# Validate exclude regular expression\r", "if", "exclude", ":", "error_msg", "=", "regexp_error_msg", "(", "exclude", ")", "if", "error_msg", ":", "exclude_edit", "=", "self", ".", "exclude_pattern", ".", "lineEdit", "(", ")", "exclude_edit", ".", "setStyleSheet", "(", "self", ".", "REGEX_INVALID", ")", "tooltip", "=", "self", ".", "REGEX_ERROR", "+", "u': '", "+", "to_text_string", "(", "error_msg", ")", "self", ".", "exclude_pattern", ".", "setToolTip", "(", "tooltip", ")", "return", "None", "else", ":", "exclude", "=", "re", ".", "compile", "(", "exclude", ")", "# Validate text regular expression\r", "if", "text_re", ":", "error_msg", "=", "regexp_error_msg", "(", "texts", "[", "0", "]", "[", "0", "]", ")", "if", "error_msg", ":", "self", ".", "search_text", ".", "lineEdit", "(", ")", ".", "setStyleSheet", "(", "self", ".", "REGEX_INVALID", ")", "tooltip", "=", "self", ".", "REGEX_ERROR", "+", "u': '", "+", "to_text_string", "(", "error_msg", ")", "self", ".", "search_text", ".", "setToolTip", "(", "tooltip", ")", "return", "None", "else", ":", "texts", "=", "[", "(", "re", ".", "compile", "(", "x", "[", "0", "]", ")", ",", "x", "[", "1", "]", ")", "for", "x", "in", "texts", "]", "return", "(", "path", ",", "file_search", ",", "exclude", ",", "texts", ",", "text_re", ",", "case_sensitive", ")" ]
Get options
[ "Get", "options" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L532-L610
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
FindOptions.keyPressEvent
def keyPressEvent(self, event): """Reimplemented to handle key events""" ctrl = event.modifiers() & Qt.ControlModifier shift = event.modifiers() & Qt.ShiftModifier if event.key() in (Qt.Key_Enter, Qt.Key_Return): self.find.emit() elif event.key() == Qt.Key_F and ctrl and shift: # Toggle find widgets self.parent().toggle_visibility.emit(not self.isVisible()) else: QWidget.keyPressEvent(self, event)
python
def keyPressEvent(self, event): """Reimplemented to handle key events""" ctrl = event.modifiers() & Qt.ControlModifier shift = event.modifiers() & Qt.ShiftModifier if event.key() in (Qt.Key_Enter, Qt.Key_Return): self.find.emit() elif event.key() == Qt.Key_F and ctrl and shift: # Toggle find widgets self.parent().toggle_visibility.emit(not self.isVisible()) else: QWidget.keyPressEvent(self, event)
[ "def", "keyPressEvent", "(", "self", ",", "event", ")", ":", "ctrl", "=", "event", ".", "modifiers", "(", ")", "&", "Qt", ".", "ControlModifier", "shift", "=", "event", ".", "modifiers", "(", ")", "&", "Qt", ".", "ShiftModifier", "if", "event", ".", "key", "(", ")", "in", "(", "Qt", ".", "Key_Enter", ",", "Qt", ".", "Key_Return", ")", ":", "self", ".", "find", ".", "emit", "(", ")", "elif", "event", ".", "key", "(", ")", "==", "Qt", ".", "Key_F", "and", "ctrl", "and", "shift", ":", "# Toggle find widgets\r", "self", ".", "parent", "(", ")", ".", "toggle_visibility", ".", "emit", "(", "not", "self", ".", "isVisible", "(", ")", ")", "else", ":", "QWidget", ".", "keyPressEvent", "(", "self", ",", "event", ")" ]
Reimplemented to handle key events
[ "Reimplemented", "to", "handle", "key", "events" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L636-L646
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
ResultsBrowser.activated
def activated(self, item): """Double-click event""" itemdata = self.data.get(id(self.currentItem())) if itemdata is not None: filename, lineno, colno = itemdata self.sig_edit_goto.emit(filename, lineno, self.search_text)
python
def activated(self, item): """Double-click event""" itemdata = self.data.get(id(self.currentItem())) if itemdata is not None: filename, lineno, colno = itemdata self.sig_edit_goto.emit(filename, lineno, self.search_text)
[ "def", "activated", "(", "self", ",", "item", ")", ":", "itemdata", "=", "self", ".", "data", ".", "get", "(", "id", "(", "self", ".", "currentItem", "(", ")", ")", ")", "if", "itemdata", "is", "not", "None", ":", "filename", ",", "lineno", ",", "colno", "=", "itemdata", "self", ".", "sig_edit_goto", ".", "emit", "(", "filename", ",", "lineno", ",", "self", ".", "search_text", ")" ]
Double-click event
[ "Double", "-", "click", "event" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L771-L776
train
spyder-ide/spyder
spyder/plugins/findinfiles/widgets.py
ResultsBrowser.set_sorting
def set_sorting(self, flag): """Enable result sorting after search is complete.""" self.sorting['status'] = flag self.header().setSectionsClickable(flag == ON)
python
def set_sorting(self, flag): """Enable result sorting after search is complete.""" self.sorting['status'] = flag self.header().setSectionsClickable(flag == ON)
[ "def", "set_sorting", "(", "self", ",", "flag", ")", ":", "self", ".", "sorting", "[", "'status'", "]", "=", "flag", "self", ".", "header", "(", ")", ".", "setSectionsClickable", "(", "flag", "==", "ON", ")" ]
Enable result sorting after search is complete.
[ "Enable", "result", "sorting", "after", "search", "is", "complete", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L778-L781
train