id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
30,800
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.rename_client_tab
def rename_client_tab(self, client, given_name): """Rename client's tab""" index = self.get_client_index_from_id(id(client)) if given_name is not None: client.given_name = given_name self.tabwidget.setTabText(index, client.get_name())
python
def rename_client_tab(self, client, given_name): """Rename client's tab""" index = self.get_client_index_from_id(id(client)) if given_name is not None: client.given_name = given_name self.tabwidget.setTabText(index, client.get_name())
[ "def", "rename_client_tab", "(", "self", ",", "client", ",", "given_name", ")", ":", "index", "=", "self", ".", "get_client_index_from_id", "(", "id", "(", "client", ")", ")", "if", "given_name", "is", "not", "None", ":", "client", ".", "given_name", "=", ...
Rename client's tab
[ "Rename", "client", "s", "tab" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1290-L1296
30,801
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.rename_tabs_after_change
def rename_tabs_after_change(self, given_name): """Rename tabs after a change in name.""" client = self.get_current_client() # Prevent renames that want to assign the same name of # a previous tab repeated = False for cl in self.get_clients(): if id(client) != id(cl) and given_name == cl.given_name: repeated = True break # Rename current client tab to add str_id if client.allow_rename and not u'/' in given_name and not repeated: self.rename_client_tab(client, given_name) else: self.rename_client_tab(client, None) # Rename related clients if client.allow_rename and not u'/' in given_name and not repeated: for cl in self.get_related_clients(client): self.rename_client_tab(cl, given_name)
python
def rename_tabs_after_change(self, given_name): """Rename tabs after a change in name.""" client = self.get_current_client() # Prevent renames that want to assign the same name of # a previous tab repeated = False for cl in self.get_clients(): if id(client) != id(cl) and given_name == cl.given_name: repeated = True break # Rename current client tab to add str_id if client.allow_rename and not u'/' in given_name and not repeated: self.rename_client_tab(client, given_name) else: self.rename_client_tab(client, None) # Rename related clients if client.allow_rename and not u'/' in given_name and not repeated: for cl in self.get_related_clients(client): self.rename_client_tab(cl, given_name)
[ "def", "rename_tabs_after_change", "(", "self", ",", "given_name", ")", ":", "client", "=", "self", ".", "get_current_client", "(", ")", "# Prevent renames that want to assign the same name of\r", "# a previous tab\r", "repeated", "=", "False", "for", "cl", "in", "self"...
Rename tabs after a change in name.
[ "Rename", "tabs", "after", "a", "change", "in", "name", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1298-L1319
30,802
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.tab_name_editor
def tab_name_editor(self): """Trigger the tab name editor.""" index = self.tabwidget.currentIndex() self.tabwidget.tabBar().tab_name_editor.edit_tab(index)
python
def tab_name_editor(self): """Trigger the tab name editor.""" index = self.tabwidget.currentIndex() self.tabwidget.tabBar().tab_name_editor.edit_tab(index)
[ "def", "tab_name_editor", "(", "self", ")", ":", "index", "=", "self", ".", "tabwidget", ".", "currentIndex", "(", ")", "self", ".", "tabwidget", ".", "tabBar", "(", ")", ".", "tab_name_editor", ".", "edit_tab", "(", "index", ")" ]
Trigger the tab name editor.
[ "Trigger", "the", "tab", "name", "editor", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1321-L1324
30,803
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.show_intro
def show_intro(self): """Show intro to IPython help""" from IPython.core.usage import interactive_usage self.main.help.show_rich_text(interactive_usage)
python
def show_intro(self): """Show intro to IPython help""" from IPython.core.usage import interactive_usage self.main.help.show_rich_text(interactive_usage)
[ "def", "show_intro", "(", "self", ")", ":", "from", "IPython", ".", "core", ".", "usage", "import", "interactive_usage", "self", ".", "main", ".", "help", ".", "show_rich_text", "(", "interactive_usage", ")" ]
Show intro to IPython help
[ "Show", "intro", "to", "IPython", "help" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1338-L1341
30,804
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.show_guiref
def show_guiref(self): """Show qtconsole help""" from qtconsole.usage import gui_reference self.main.help.show_rich_text(gui_reference, collapse=True)
python
def show_guiref(self): """Show qtconsole help""" from qtconsole.usage import gui_reference self.main.help.show_rich_text(gui_reference, collapse=True)
[ "def", "show_guiref", "(", "self", ")", ":", "from", "qtconsole", ".", "usage", "import", "gui_reference", "self", ".", "main", ".", "help", ".", "show_rich_text", "(", "gui_reference", ",", "collapse", "=", "True", ")" ]
Show qtconsole help
[ "Show", "qtconsole", "help" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1344-L1347
30,805
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole.show_quickref
def show_quickref(self): """Show IPython Cheat Sheet""" from IPython.core.usage import quick_reference self.main.help.show_plain_text(quick_reference)
python
def show_quickref(self): """Show IPython Cheat Sheet""" from IPython.core.usage import quick_reference self.main.help.show_plain_text(quick_reference)
[ "def", "show_quickref", "(", "self", ")", ":", "from", "IPython", ".", "core", ".", "usage", "import", "quick_reference", "self", ".", "main", ".", "help", ".", "show_plain_text", "(", "quick_reference", ")" ]
Show IPython Cheat Sheet
[ "Show", "IPython", "Cheat", "Sheet" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1350-L1353
30,806
spyder-ide/spyder
spyder/plugins/ipythonconsole/plugin.py
IPythonConsole._remove_old_stderr_files
def _remove_old_stderr_files(self): """ Remove stderr files left by previous Spyder instances. This is only required on Windows because we can't clean up stderr files while Spyder is running on it. """ if os.name == 'nt': tmpdir = get_temp_dir() for fname in os.listdir(tmpdir): if osp.splitext(fname)[1] == '.stderr': try: os.remove(osp.join(tmpdir, fname)) except Exception: pass
python
def _remove_old_stderr_files(self): """ Remove stderr files left by previous Spyder instances. This is only required on Windows because we can't clean up stderr files while Spyder is running on it. """ if os.name == 'nt': tmpdir = get_temp_dir() for fname in os.listdir(tmpdir): if osp.splitext(fname)[1] == '.stderr': try: os.remove(osp.join(tmpdir, fname)) except Exception: pass
[ "def", "_remove_old_stderr_files", "(", "self", ")", ":", "if", "os", ".", "name", "==", "'nt'", ":", "tmpdir", "=", "get_temp_dir", "(", ")", "for", "fname", "in", "os", ".", "listdir", "(", "tmpdir", ")", ":", "if", "osp", ".", "splitext", "(", "fn...
Remove stderr files left by previous Spyder instances. This is only required on Windows because we can't clean up stderr files while Spyder is running on it.
[ "Remove", "stderr", "files", "left", "by", "previous", "Spyder", "instances", ".", "This", "is", "only", "required", "on", "Windows", "because", "we", "can", "t", "clean", "up", "stderr", "files", "while", "Spyder", "is", "running", "on", "it", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/plugin.py#L1504-L1518
30,807
spyder-ide/spyder
spyder/plugins/editor/utils/kill_ring.py
KillRing.rotate
def rotate(self): """ Rotate the kill ring, then yank back the new top. Returns ------- A text string or None. """ self._index -= 1 if self._index >= 0: return self._ring[self._index] return None
python
def rotate(self): """ Rotate the kill ring, then yank back the new top. Returns ------- A text string or None. """ self._index -= 1 if self._index >= 0: return self._ring[self._index] return None
[ "def", "rotate", "(", "self", ")", ":", "self", ".", "_index", "-=", "1", "if", "self", ".", "_index", ">=", "0", ":", "return", "self", ".", "_ring", "[", "self", ".", "_index", "]", "return", "None" ]
Rotate the kill ring, then yank back the new top. Returns ------- A text string or None.
[ "Rotate", "the", "kill", "ring", "then", "yank", "back", "the", "new", "top", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/kill_ring.py#L55-L65
30,808
spyder-ide/spyder
spyder/plugins/editor/utils/kill_ring.py
QtKillRing.kill_cursor
def kill_cursor(self, cursor): """ Kills the text selected by the give cursor. """ text = cursor.selectedText() if text: cursor.removeSelectedText() self.kill(text)
python
def kill_cursor(self, cursor): """ Kills the text selected by the give cursor. """ text = cursor.selectedText() if text: cursor.removeSelectedText() self.kill(text)
[ "def", "kill_cursor", "(", "self", ",", "cursor", ")", ":", "text", "=", "cursor", ".", "selectedText", "(", ")", "if", "text", ":", "cursor", ".", "removeSelectedText", "(", ")", "self", ".", "kill", "(", "text", ")" ]
Kills the text selected by the give cursor.
[ "Kills", "the", "text", "selected", "by", "the", "give", "cursor", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/kill_ring.py#L100-L106
30,809
spyder-ide/spyder
spyder/plugins/editor/utils/kill_ring.py
QtKillRing.yank
def yank(self): """ Yank back the most recently killed text. """ text = self._ring.yank() if text: self._skip_cursor = True cursor = self._text_edit.textCursor() cursor.insertText(text) self._prev_yank = text
python
def yank(self): """ Yank back the most recently killed text. """ text = self._ring.yank() if text: self._skip_cursor = True cursor = self._text_edit.textCursor() cursor.insertText(text) self._prev_yank = text
[ "def", "yank", "(", "self", ")", ":", "text", "=", "self", ".", "_ring", ".", "yank", "(", ")", "if", "text", ":", "self", ".", "_skip_cursor", "=", "True", "cursor", "=", "self", ".", "_text_edit", ".", "textCursor", "(", ")", "cursor", ".", "inse...
Yank back the most recently killed text.
[ "Yank", "back", "the", "most", "recently", "killed", "text", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/kill_ring.py#L108-L116
30,810
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
fixpath
def fixpath(path): """Normalize path fixing case, making absolute and removing symlinks""" norm = osp.normcase if os.name == 'nt' else osp.normpath return norm(osp.abspath(osp.realpath(path)))
python
def fixpath(path): """Normalize path fixing case, making absolute and removing symlinks""" norm = osp.normcase if os.name == 'nt' else osp.normpath return norm(osp.abspath(osp.realpath(path)))
[ "def", "fixpath", "(", "path", ")", ":", "norm", "=", "osp", ".", "normcase", "if", "os", ".", "name", "==", "'nt'", "else", "osp", ".", "normpath", "return", "norm", "(", "osp", ".", "abspath", "(", "osp", ".", "realpath", "(", "path", ")", ")", ...
Normalize path fixing case, making absolute and removing symlinks
[ "Normalize", "path", "fixing", "case", "making", "absolute", "and", "removing", "symlinks" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L71-L74
30,811
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
create_script
def create_script(fname): """Create a new Python script""" text = os.linesep.join(["# -*- coding: utf-8 -*-", "", ""]) try: encoding.write(to_text_string(text), fname, 'utf-8') except EnvironmentError as error: QMessageBox.critical(_("Save Error"), _("<b>Unable to save file '%s'</b>" "<br><br>Error message:<br>%s" ) % (osp.basename(fname), str(error)))
python
def create_script(fname): """Create a new Python script""" text = os.linesep.join(["# -*- coding: utf-8 -*-", "", ""]) try: encoding.write(to_text_string(text), fname, 'utf-8') except EnvironmentError as error: QMessageBox.critical(_("Save Error"), _("<b>Unable to save file '%s'</b>" "<br><br>Error message:<br>%s" ) % (osp.basename(fname), str(error)))
[ "def", "create_script", "(", "fname", ")", ":", "text", "=", "os", ".", "linesep", ".", "join", "(", "[", "\"# -*- coding: utf-8 -*-\"", ",", "\"\"", ",", "\"\"", "]", ")", "try", ":", "encoding", ".", "write", "(", "to_text_string", "(", "text", ")", ...
Create a new Python script
[ "Create", "a", "new", "Python", "script" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L77-L86
30,812
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
listdir
def listdir(path, include=r'.', exclude=r'\.pyc$|^\.', show_all=False, folders_only=False): """List files and directories""" namelist = [] dirlist = [to_text_string(osp.pardir)] for item in os.listdir(to_text_string(path)): if re.search(exclude, item) and not show_all: continue if osp.isdir(osp.join(path, item)): dirlist.append(item) elif folders_only: continue elif re.search(include, item) or show_all: namelist.append(item) return sorted(dirlist, key=str_lower) + \ sorted(namelist, key=str_lower)
python
def listdir(path, include=r'.', exclude=r'\.pyc$|^\.', show_all=False, folders_only=False): """List files and directories""" namelist = [] dirlist = [to_text_string(osp.pardir)] for item in os.listdir(to_text_string(path)): if re.search(exclude, item) and not show_all: continue if osp.isdir(osp.join(path, item)): dirlist.append(item) elif folders_only: continue elif re.search(include, item) or show_all: namelist.append(item) return sorted(dirlist, key=str_lower) + \ sorted(namelist, key=str_lower)
[ "def", "listdir", "(", "path", ",", "include", "=", "r'.'", ",", "exclude", "=", "r'\\.pyc$|^\\.'", ",", "show_all", "=", "False", ",", "folders_only", "=", "False", ")", ":", "namelist", "=", "[", "]", "dirlist", "=", "[", "to_text_string", "(", "osp", ...
List files and directories
[ "List", "files", "and", "directories" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L88-L103
30,813
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
has_subdirectories
def has_subdirectories(path, include, exclude, show_all): """Return True if path has subdirectories""" try: # > 1 because of '..' return len( listdir(path, include, exclude, show_all, folders_only=True) ) > 1 except (IOError, OSError): return False
python
def has_subdirectories(path, include, exclude, show_all): """Return True if path has subdirectories""" try: # > 1 because of '..' return len( listdir(path, include, exclude, show_all, folders_only=True) ) > 1 except (IOError, OSError): return False
[ "def", "has_subdirectories", "(", "path", ",", "include", ",", "exclude", ",", "show_all", ")", ":", "try", ":", "# > 1 because of '..'\r", "return", "len", "(", "listdir", "(", "path", ",", "include", ",", "exclude", ",", "show_all", ",", "folders_only", "=...
Return True if path has subdirectories
[ "Return", "True", "if", "path", "has", "subdirectories" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L106-L113
30,814
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.setup_fs_model
def setup_fs_model(self): """Setup filesystem model""" filters = QDir.AllDirs | QDir.Files | QDir.Drives | QDir.NoDotAndDotDot self.fsmodel = QFileSystemModel(self) self.fsmodel.setFilter(filters) self.fsmodel.setNameFilterDisables(False)
python
def setup_fs_model(self): """Setup filesystem model""" filters = QDir.AllDirs | QDir.Files | QDir.Drives | QDir.NoDotAndDotDot self.fsmodel = QFileSystemModel(self) self.fsmodel.setFilter(filters) self.fsmodel.setNameFilterDisables(False)
[ "def", "setup_fs_model", "(", "self", ")", ":", "filters", "=", "QDir", ".", "AllDirs", "|", "QDir", ".", "Files", "|", "QDir", ".", "Drives", "|", "QDir", ".", "NoDotAndDotDot", "self", ".", "fsmodel", "=", "QFileSystemModel", "(", "self", ")", "self", ...
Setup filesystem model
[ "Setup", "filesystem", "model" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L167-L172
30,815
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.set_single_click_to_open
def set_single_click_to_open(self, value): """Set single click to open items.""" self.single_click_to_open = value self.parent_widget.sig_option_changed.emit('single_click_to_open', value)
python
def set_single_click_to_open(self, value): """Set single click to open items.""" self.single_click_to_open = value self.parent_widget.sig_option_changed.emit('single_click_to_open', value)
[ "def", "set_single_click_to_open", "(", "self", ",", "value", ")", ":", "self", ".", "single_click_to_open", "=", "value", "self", ".", "parent_widget", ".", "sig_option_changed", ".", "emit", "(", "'single_click_to_open'", ",", "value", ")" ]
Set single click to open items.
[ "Set", "single", "click", "to", "open", "items", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L191-L195
30,816
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.set_name_filters
def set_name_filters(self, name_filters): """Set name filters""" self.name_filters = name_filters self.fsmodel.setNameFilters(name_filters)
python
def set_name_filters(self, name_filters): """Set name filters""" self.name_filters = name_filters self.fsmodel.setNameFilters(name_filters)
[ "def", "set_name_filters", "(", "self", ",", "name_filters", ")", ":", "self", ".", "name_filters", "=", "name_filters", "self", ".", "fsmodel", ".", "setNameFilters", "(", "name_filters", ")" ]
Set name filters
[ "Set", "name", "filters" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L197-L200
30,817
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.set_show_all
def set_show_all(self, state): """Toggle 'show all files' state""" if state: self.fsmodel.setNameFilters([]) else: self.fsmodel.setNameFilters(self.name_filters)
python
def set_show_all(self, state): """Toggle 'show all files' state""" if state: self.fsmodel.setNameFilters([]) else: self.fsmodel.setNameFilters(self.name_filters)
[ "def", "set_show_all", "(", "self", ",", "state", ")", ":", "if", "state", ":", "self", ".", "fsmodel", ".", "setNameFilters", "(", "[", "]", ")", "else", ":", "self", ".", "fsmodel", ".", "setNameFilters", "(", "self", ".", "name_filters", ")" ]
Toggle 'show all files' state
[ "Toggle", "show", "all", "files", "state" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L202-L207
30,818
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.get_selected_filenames
def get_selected_filenames(self): """Return selected filenames""" if self.selectionMode() == self.ExtendedSelection: if self.selectionModel() is None: return [] return [self.get_filename(idx) for idx in self.selectionModel().selectedRows()] else: return [self.get_filename(self.currentIndex())]
python
def get_selected_filenames(self): """Return selected filenames""" if self.selectionMode() == self.ExtendedSelection: if self.selectionModel() is None: return [] return [self.get_filename(idx) for idx in self.selectionModel().selectedRows()] else: return [self.get_filename(self.currentIndex())]
[ "def", "get_selected_filenames", "(", "self", ")", ":", "if", "self", ".", "selectionMode", "(", ")", "==", "self", ".", "ExtendedSelection", ":", "if", "self", ".", "selectionModel", "(", ")", "is", "None", ":", "return", "[", "]", "return", "[", "self"...
Return selected filenames
[ "Return", "selected", "filenames" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L218-L226
30,819
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.setup
def setup(self, name_filters=['*.py', '*.pyw'], show_all=False, single_click_to_open=False): """Setup tree widget""" self.setup_view() self.set_name_filters(name_filters) self.show_all = show_all self.single_click_to_open = single_click_to_open # Setup context menu self.menu = QMenu(self) self.common_actions = self.setup_common_actions()
python
def setup(self, name_filters=['*.py', '*.pyw'], show_all=False, single_click_to_open=False): """Setup tree widget""" self.setup_view() self.set_name_filters(name_filters) self.show_all = show_all self.single_click_to_open = single_click_to_open # Setup context menu self.menu = QMenu(self) self.common_actions = self.setup_common_actions()
[ "def", "setup", "(", "self", ",", "name_filters", "=", "[", "'*.py'", ",", "'*.pyw'", "]", ",", "show_all", "=", "False", ",", "single_click_to_open", "=", "False", ")", ":", "self", ".", "setup_view", "(", ")", "self", ".", "set_name_filters", "(", "nam...
Setup tree widget
[ "Setup", "tree", "widget" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L238-L249
30,820
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.edit_filter
def edit_filter(self): """Edit name filters""" filters, valid = QInputDialog.getText(self, _('Edit filename filters'), _('Name filters:'), QLineEdit.Normal, ", ".join(self.name_filters)) if valid: filters = [f.strip() for f in to_text_string(filters).split(',')] self.parent_widget.sig_option_changed.emit('name_filters', filters) self.set_name_filters(filters)
python
def edit_filter(self): """Edit name filters""" filters, valid = QInputDialog.getText(self, _('Edit filename filters'), _('Name filters:'), QLineEdit.Normal, ", ".join(self.name_filters)) if valid: filters = [f.strip() for f in to_text_string(filters).split(',')] self.parent_widget.sig_option_changed.emit('name_filters', filters) self.set_name_filters(filters)
[ "def", "edit_filter", "(", "self", ")", ":", "filters", ",", "valid", "=", "QInputDialog", ".", "getText", "(", "self", ",", "_", "(", "'Edit filename filters'", ")", ",", "_", "(", "'Name filters:'", ")", ",", "QLineEdit", ".", "Normal", ",", "\", \"", ...
Edit name filters
[ "Edit", "name", "filters" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L279-L288
30,821
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.toggle_all
def toggle_all(self, checked): """Toggle all files mode""" self.parent_widget.sig_option_changed.emit('show_all', checked) self.show_all = checked self.set_show_all(checked)
python
def toggle_all(self, checked): """Toggle all files mode""" self.parent_widget.sig_option_changed.emit('show_all', checked) self.show_all = checked self.set_show_all(checked)
[ "def", "toggle_all", "(", "self", ",", "checked", ")", ":", "self", ".", "parent_widget", ".", "sig_option_changed", ".", "emit", "(", "'show_all'", ",", "checked", ")", "self", ".", "show_all", "=", "checked", "self", ".", "set_show_all", "(", "checked", ...
Toggle all files mode
[ "Toggle", "all", "files", "mode" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L291-L295
30,822
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.create_file_new_actions
def create_file_new_actions(self, fnames): """Return actions for submenu 'New...'""" if not fnames: return [] new_file_act = create_action(self, _("File..."), icon=ima.icon('filenew'), triggered=lambda: self.new_file(fnames[-1])) new_module_act = create_action(self, _("Module..."), icon=ima.icon('spyder'), triggered=lambda: self.new_module(fnames[-1])) new_folder_act = create_action(self, _("Folder..."), icon=ima.icon('folder_new'), triggered=lambda: self.new_folder(fnames[-1])) new_package_act = create_action(self, _("Package..."), icon=ima.icon('package_new'), triggered=lambda: self.new_package(fnames[-1])) return [new_file_act, new_folder_act, None, new_module_act, new_package_act]
python
def create_file_new_actions(self, fnames): """Return actions for submenu 'New...'""" if not fnames: return [] new_file_act = create_action(self, _("File..."), icon=ima.icon('filenew'), triggered=lambda: self.new_file(fnames[-1])) new_module_act = create_action(self, _("Module..."), icon=ima.icon('spyder'), triggered=lambda: self.new_module(fnames[-1])) new_folder_act = create_action(self, _("Folder..."), icon=ima.icon('folder_new'), triggered=lambda: self.new_folder(fnames[-1])) new_package_act = create_action(self, _("Package..."), icon=ima.icon('package_new'), triggered=lambda: self.new_package(fnames[-1])) return [new_file_act, new_folder_act, None, new_module_act, new_package_act]
[ "def", "create_file_new_actions", "(", "self", ",", "fnames", ")", ":", "if", "not", "fnames", ":", "return", "[", "]", "new_file_act", "=", "create_action", "(", "self", ",", "_", "(", "\"File...\"", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'f...
Return actions for submenu 'New...
[ "Return", "actions", "for", "submenu", "New", "..." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L297-L318
30,823
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.create_folder_manage_actions
def create_folder_manage_actions(self, fnames): """Return folder management actions""" actions = [] if os.name == 'nt': _title = _("Open command prompt here") else: _title = _("Open terminal here") _title = _("Open IPython console here") action = create_action(self, _title, triggered=lambda: self.open_interpreter(fnames)) actions.append(action) return actions
python
def create_folder_manage_actions(self, fnames): """Return folder management actions""" actions = [] if os.name == 'nt': _title = _("Open command prompt here") else: _title = _("Open terminal here") _title = _("Open IPython console here") action = create_action(self, _title, triggered=lambda: self.open_interpreter(fnames)) actions.append(action) return actions
[ "def", "create_folder_manage_actions", "(", "self", ",", "fnames", ")", ":", "actions", "=", "[", "]", "if", "os", ".", "name", "==", "'nt'", ":", "_title", "=", "_", "(", "\"Open command prompt here\"", ")", "else", ":", "_title", "=", "_", "(", "\"Open...
Return folder management actions
[ "Return", "folder", "management", "actions" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L414-L426
30,824
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.create_context_menu_actions
def create_context_menu_actions(self): """Create context menu actions""" actions = [] fnames = self.get_selected_filenames() new_actions = self.create_file_new_actions(fnames) if len(new_actions) > 1: # Creating a submenu only if there is more than one entry new_act_menu = QMenu(_('New'), self) add_actions(new_act_menu, new_actions) actions.append(new_act_menu) else: actions += new_actions import_actions = self.create_file_import_actions(fnames) if len(import_actions) > 1: # Creating a submenu only if there is more than one entry import_act_menu = QMenu(_('Import'), self) add_actions(import_act_menu, import_actions) actions.append(import_act_menu) else: actions += import_actions if actions: actions.append(None) if fnames: actions += self.create_file_manage_actions(fnames) if actions: actions.append(None) if fnames and all([osp.isdir(_fn) for _fn in fnames]): actions += self.create_folder_manage_actions(fnames) return actions
python
def create_context_menu_actions(self): """Create context menu actions""" actions = [] fnames = self.get_selected_filenames() new_actions = self.create_file_new_actions(fnames) if len(new_actions) > 1: # Creating a submenu only if there is more than one entry new_act_menu = QMenu(_('New'), self) add_actions(new_act_menu, new_actions) actions.append(new_act_menu) else: actions += new_actions import_actions = self.create_file_import_actions(fnames) if len(import_actions) > 1: # Creating a submenu only if there is more than one entry import_act_menu = QMenu(_('Import'), self) add_actions(import_act_menu, import_actions) actions.append(import_act_menu) else: actions += import_actions if actions: actions.append(None) if fnames: actions += self.create_file_manage_actions(fnames) if actions: actions.append(None) if fnames and all([osp.isdir(_fn) for _fn in fnames]): actions += self.create_folder_manage_actions(fnames) return actions
[ "def", "create_context_menu_actions", "(", "self", ")", ":", "actions", "=", "[", "]", "fnames", "=", "self", ".", "get_selected_filenames", "(", ")", "new_actions", "=", "self", ".", "create_file_new_actions", "(", "fnames", ")", "if", "len", "(", "new_action...
Create context menu actions
[ "Create", "context", "menu", "actions" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L428-L456
30,825
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.update_menu
def update_menu(self): """Update context menu""" self.menu.clear() add_actions(self.menu, self.create_context_menu_actions())
python
def update_menu(self): """Update context menu""" self.menu.clear() add_actions(self.menu, self.create_context_menu_actions())
[ "def", "update_menu", "(", "self", ")", ":", "self", ".", "menu", ".", "clear", "(", ")", "add_actions", "(", "self", ".", "menu", ",", "self", ".", "create_context_menu_actions", "(", ")", ")" ]
Update context menu
[ "Update", "context", "menu" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L458-L461
30,826
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.dragMoveEvent
def dragMoveEvent(self, event): """Drag and Drop - Move event""" if (event.mimeData().hasFormat("text/plain")): event.setDropAction(Qt.MoveAction) event.accept() else: event.ignore()
python
def dragMoveEvent(self, event): """Drag and Drop - Move event""" if (event.mimeData().hasFormat("text/plain")): event.setDropAction(Qt.MoveAction) event.accept() else: event.ignore()
[ "def", "dragMoveEvent", "(", "self", ",", "event", ")", ":", "if", "(", "event", ".", "mimeData", "(", ")", ".", "hasFormat", "(", "\"text/plain\"", ")", ")", ":", "event", ".", "setDropAction", "(", "Qt", ".", "MoveAction", ")", "event", ".", "accept"...
Drag and Drop - Move event
[ "Drag", "and", "Drop", "-", "Move", "event" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L533-L539
30,827
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.startDrag
def startDrag(self, dropActions): """Reimplement Qt Method - handle drag event""" data = QMimeData() data.setUrls([QUrl(fname) for fname in self.get_selected_filenames()]) drag = QDrag(self) drag.setMimeData(data) drag.exec_()
python
def startDrag(self, dropActions): """Reimplement Qt Method - handle drag event""" data = QMimeData() data.setUrls([QUrl(fname) for fname in self.get_selected_filenames()]) drag = QDrag(self) drag.setMimeData(data) drag.exec_()
[ "def", "startDrag", "(", "self", ",", "dropActions", ")", ":", "data", "=", "QMimeData", "(", ")", "data", ".", "setUrls", "(", "[", "QUrl", "(", "fname", ")", "for", "fname", "in", "self", ".", "get_selected_filenames", "(", ")", "]", ")", "drag", "...
Reimplement Qt Method - handle drag event
[ "Reimplement", "Qt", "Method", "-", "handle", "drag", "event" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L541-L547
30,828
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.open
def open(self, fnames=None): """Open files with the appropriate application""" if fnames is None: fnames = self.get_selected_filenames() for fname in fnames: if osp.isfile(fname) and encoding.is_text_file(fname): self.parent_widget.sig_open_file.emit(fname) else: self.open_outside_spyder([fname])
python
def open(self, fnames=None): """Open files with the appropriate application""" if fnames is None: fnames = self.get_selected_filenames() for fname in fnames: if osp.isfile(fname) and encoding.is_text_file(fname): self.parent_widget.sig_open_file.emit(fname) else: self.open_outside_spyder([fname])
[ "def", "open", "(", "self", ",", "fnames", "=", "None", ")", ":", "if", "fnames", "is", "None", ":", "fnames", "=", "self", ".", "get_selected_filenames", "(", ")", "for", "fname", "in", "fnames", ":", "if", "osp", ".", "isfile", "(", "fname", ")", ...
Open files with the appropriate application
[ "Open", "files", "with", "the", "appropriate", "application" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L551-L559
30,829
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.open_external
def open_external(self, fnames=None): """Open files with default application""" if fnames is None: fnames = self.get_selected_filenames() for fname in fnames: self.open_outside_spyder([fname])
python
def open_external(self, fnames=None): """Open files with default application""" if fnames is None: fnames = self.get_selected_filenames() for fname in fnames: self.open_outside_spyder([fname])
[ "def", "open_external", "(", "self", ",", "fnames", "=", "None", ")", ":", "if", "fnames", "is", "None", ":", "fnames", "=", "self", ".", "get_selected_filenames", "(", ")", "for", "fname", "in", "fnames", ":", "self", ".", "open_outside_spyder", "(", "[...
Open files with default application
[ "Open", "files", "with", "default", "application" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L562-L567
30,830
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.open_outside_spyder
def open_outside_spyder(self, fnames): """Open file outside Spyder with the appropriate application If this does not work, opening unknown file in Spyder, as text file""" for path in sorted(fnames): path = file_uri(path) ok = programs.start_file(path) if not ok: self.sig_edit.emit(path)
python
def open_outside_spyder(self, fnames): """Open file outside Spyder with the appropriate application If this does not work, opening unknown file in Spyder, as text file""" for path in sorted(fnames): path = file_uri(path) ok = programs.start_file(path) if not ok: self.sig_edit.emit(path)
[ "def", "open_outside_spyder", "(", "self", ",", "fnames", ")", ":", "for", "path", "in", "sorted", "(", "fnames", ")", ":", "path", "=", "file_uri", "(", "path", ")", "ok", "=", "programs", ".", "start_file", "(", "path", ")", "if", "not", "ok", ":",...
Open file outside Spyder with the appropriate application If this does not work, opening unknown file in Spyder, as text file
[ "Open", "file", "outside", "Spyder", "with", "the", "appropriate", "application", "If", "this", "does", "not", "work", "opening", "unknown", "file", "in", "Spyder", "as", "text", "file" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L569-L576
30,831
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.run
def run(self, fnames=None): """Run Python scripts""" if fnames is None: fnames = self.get_selected_filenames() for fname in fnames: self.sig_run.emit(fname)
python
def run(self, fnames=None): """Run Python scripts""" if fnames is None: fnames = self.get_selected_filenames() for fname in fnames: self.sig_run.emit(fname)
[ "def", "run", "(", "self", ",", "fnames", "=", "None", ")", ":", "if", "fnames", "is", "None", ":", "fnames", "=", "self", ".", "get_selected_filenames", "(", ")", "for", "fname", "in", "fnames", ":", "self", ".", "sig_run", ".", "emit", "(", "fname"...
Run Python scripts
[ "Run", "Python", "scripts" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L584-L589
30,832
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.remove_tree
def remove_tree(self, dirname): """Remove whole directory tree Reimplemented in project explorer widget""" while osp.exists(dirname): try: shutil.rmtree(dirname, onerror=misc.onerror) except Exception as e: # This handles a Windows problem with shutil.rmtree. # See issue #8567. if type(e).__name__ == "OSError": error_path = to_text_string(e.filename) shutil.rmtree(error_path, ignore_errors=True)
python
def remove_tree(self, dirname): """Remove whole directory tree Reimplemented in project explorer widget""" while osp.exists(dirname): try: shutil.rmtree(dirname, onerror=misc.onerror) except Exception as e: # This handles a Windows problem with shutil.rmtree. # See issue #8567. if type(e).__name__ == "OSError": error_path = to_text_string(e.filename) shutil.rmtree(error_path, ignore_errors=True)
[ "def", "remove_tree", "(", "self", ",", "dirname", ")", ":", "while", "osp", ".", "exists", "(", "dirname", ")", ":", "try", ":", "shutil", ".", "rmtree", "(", "dirname", ",", "onerror", "=", "misc", ".", "onerror", ")", "except", "Exception", "as", ...
Remove whole directory tree Reimplemented in project explorer widget
[ "Remove", "whole", "directory", "tree", "Reimplemented", "in", "project", "explorer", "widget" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L591-L602
30,833
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.convert_notebook
def convert_notebook(self, fname): """Convert an IPython notebook to a Python script in editor""" try: script = nbexporter().from_filename(fname)[0] except Exception as e: QMessageBox.critical(self, _('Conversion error'), _("It was not possible to convert this " "notebook. The error is:\n\n") + \ to_text_string(e)) return self.sig_new_file.emit(script)
python
def convert_notebook(self, fname): """Convert an IPython notebook to a Python script in editor""" try: script = nbexporter().from_filename(fname)[0] except Exception as e: QMessageBox.critical(self, _('Conversion error'), _("It was not possible to convert this " "notebook. The error is:\n\n") + \ to_text_string(e)) return self.sig_new_file.emit(script)
[ "def", "convert_notebook", "(", "self", ",", "fname", ")", ":", "try", ":", "script", "=", "nbexporter", "(", ")", ".", "from_filename", "(", "fname", ")", "[", "0", "]", "except", "Exception", "as", "e", ":", "QMessageBox", ".", "critical", "(", "self...
Convert an IPython notebook to a Python script in editor
[ "Convert", "an", "IPython", "notebook", "to", "a", "Python", "script", "in", "editor" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L661-L671
30,834
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.convert_notebooks
def convert_notebooks(self): """Convert IPython notebooks to Python scripts in editor""" fnames = self.get_selected_filenames() if not isinstance(fnames, (tuple, list)): fnames = [fnames] for fname in fnames: self.convert_notebook(fname)
python
def convert_notebooks(self): """Convert IPython notebooks to Python scripts in editor""" fnames = self.get_selected_filenames() if not isinstance(fnames, (tuple, list)): fnames = [fnames] for fname in fnames: self.convert_notebook(fname)
[ "def", "convert_notebooks", "(", "self", ")", ":", "fnames", "=", "self", ".", "get_selected_filenames", "(", ")", "if", "not", "isinstance", "(", "fnames", ",", "(", "tuple", ",", "list", ")", ")", ":", "fnames", "=", "[", "fnames", "]", "for", "fname...
Convert IPython notebooks to Python scripts in editor
[ "Convert", "IPython", "notebooks", "to", "Python", "scripts", "in", "editor" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L674-L680
30,835
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.create_new_file
def create_new_file(self, current_path, title, filters, create_func): """Create new file Returns True if successful""" if current_path is None: current_path = '' if osp.isfile(current_path): current_path = osp.dirname(current_path) self.redirect_stdio.emit(False) fname, _selfilter = getsavefilename(self, title, current_path, filters) self.redirect_stdio.emit(True) if fname: try: create_func(fname) return fname except EnvironmentError as error: QMessageBox.critical(self, _("New file"), _("<b>Unable to create file <i>%s</i>" "</b><br><br>Error message:<br>%s" ) % (fname, to_text_string(error)))
python
def create_new_file(self, current_path, title, filters, create_func): """Create new file Returns True if successful""" if current_path is None: current_path = '' if osp.isfile(current_path): current_path = osp.dirname(current_path) self.redirect_stdio.emit(False) fname, _selfilter = getsavefilename(self, title, current_path, filters) self.redirect_stdio.emit(True) if fname: try: create_func(fname) return fname except EnvironmentError as error: QMessageBox.critical(self, _("New file"), _("<b>Unable to create file <i>%s</i>" "</b><br><br>Error message:<br>%s" ) % (fname, to_text_string(error)))
[ "def", "create_new_file", "(", "self", ",", "current_path", ",", "title", ",", "filters", ",", "create_func", ")", ":", "if", "current_path", "is", "None", ":", "current_path", "=", "''", "if", "osp", ".", "isfile", "(", "current_path", ")", ":", "current_...
Create new file Returns True if successful
[ "Create", "new", "file", "Returns", "True", "if", "successful" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L803-L821
30,836
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.create_shortcuts
def create_shortcuts(self): """Create shortcuts for this file explorer.""" # Configurable copy_clipboard_file = config_shortcut(self.copy_file_clipboard, context='explorer', name='copy file', parent=self) paste_clipboard_file = config_shortcut(self.save_file_clipboard, context='explorer', name='paste file', parent=self) copy_absolute_path = config_shortcut(self.copy_absolute_path, context='explorer', name='copy absolute path', parent=self) copy_relative_path = config_shortcut(self.copy_relative_path, context='explorer', name='copy relative path', parent=self) return [copy_clipboard_file, paste_clipboard_file, copy_absolute_path, copy_relative_path]
python
def create_shortcuts(self): """Create shortcuts for this file explorer.""" # Configurable copy_clipboard_file = config_shortcut(self.copy_file_clipboard, context='explorer', name='copy file', parent=self) paste_clipboard_file = config_shortcut(self.save_file_clipboard, context='explorer', name='paste file', parent=self) copy_absolute_path = config_shortcut(self.copy_absolute_path, context='explorer', name='copy absolute path', parent=self) copy_relative_path = config_shortcut(self.copy_relative_path, context='explorer', name='copy relative path', parent=self) return [copy_clipboard_file, paste_clipboard_file, copy_absolute_path, copy_relative_path]
[ "def", "create_shortcuts", "(", "self", ")", ":", "# Configurable\r", "copy_clipboard_file", "=", "config_shortcut", "(", "self", ".", "copy_file_clipboard", ",", "context", "=", "'explorer'", ",", "name", "=", "'copy file'", ",", "parent", "=", "self", ")", "pa...
Create shortcuts for this file explorer.
[ "Create", "shortcuts", "for", "this", "file", "explorer", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1003-L1021
30,837
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.set_scrollbar_position
def set_scrollbar_position(self, position): """Set scrollbar positions""" # Scrollbars will be restored after the expanded state self._scrollbar_positions = position if self._to_be_loaded is not None and len(self._to_be_loaded) == 0: self.restore_scrollbar_positions()
python
def set_scrollbar_position(self, position): """Set scrollbar positions""" # Scrollbars will be restored after the expanded state self._scrollbar_positions = position if self._to_be_loaded is not None and len(self._to_be_loaded) == 0: self.restore_scrollbar_positions()
[ "def", "set_scrollbar_position", "(", "self", ",", "position", ")", ":", "# Scrollbars will be restored after the expanded state\r", "self", ".", "_scrollbar_positions", "=", "position", "if", "self", ".", "_to_be_loaded", "is", "not", "None", "and", "len", "(", "self...
Set scrollbar positions
[ "Set", "scrollbar", "positions" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1052-L1057
30,838
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.restore_scrollbar_positions
def restore_scrollbar_positions(self): """Restore scrollbar positions once tree is loaded""" hor, ver = self._scrollbar_positions self.horizontalScrollBar().setValue(hor) self.verticalScrollBar().setValue(ver)
python
def restore_scrollbar_positions(self): """Restore scrollbar positions once tree is loaded""" hor, ver = self._scrollbar_positions self.horizontalScrollBar().setValue(hor) self.verticalScrollBar().setValue(ver)
[ "def", "restore_scrollbar_positions", "(", "self", ")", ":", "hor", ",", "ver", "=", "self", ".", "_scrollbar_positions", "self", ".", "horizontalScrollBar", "(", ")", ".", "setValue", "(", "hor", ")", "self", ".", "verticalScrollBar", "(", ")", ".", "setVal...
Restore scrollbar positions once tree is loaded
[ "Restore", "scrollbar", "positions", "once", "tree", "is", "loaded" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1059-L1063
30,839
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.restore_directory_state
def restore_directory_state(self, fname): """Restore directory expanded state""" root = osp.normpath(to_text_string(fname)) if not osp.exists(root): # Directory has been (re)moved outside Spyder return for basename in os.listdir(root): path = osp.normpath(osp.join(root, basename)) if osp.isdir(path) and path in self.__expanded_state: self.__expanded_state.pop(self.__expanded_state.index(path)) if self._to_be_loaded is None: self._to_be_loaded = [] self._to_be_loaded.append(path) self.setExpanded(self.get_index(path), True) if not self.__expanded_state: self.fsmodel.directoryLoaded.disconnect(self.restore_directory_state)
python
def restore_directory_state(self, fname): """Restore directory expanded state""" root = osp.normpath(to_text_string(fname)) if not osp.exists(root): # Directory has been (re)moved outside Spyder return for basename in os.listdir(root): path = osp.normpath(osp.join(root, basename)) if osp.isdir(path) and path in self.__expanded_state: self.__expanded_state.pop(self.__expanded_state.index(path)) if self._to_be_loaded is None: self._to_be_loaded = [] self._to_be_loaded.append(path) self.setExpanded(self.get_index(path), True) if not self.__expanded_state: self.fsmodel.directoryLoaded.disconnect(self.restore_directory_state)
[ "def", "restore_directory_state", "(", "self", ",", "fname", ")", ":", "root", "=", "osp", ".", "normpath", "(", "to_text_string", "(", "fname", ")", ")", "if", "not", "osp", ".", "exists", "(", "root", ")", ":", "# Directory has been (re)moved outside Spyder\...
Restore directory expanded state
[ "Restore", "directory", "expanded", "state" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1086-L1101
30,840
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.follow_directories_loaded
def follow_directories_loaded(self, fname): """Follow directories loaded during startup""" if self._to_be_loaded is None: return path = osp.normpath(to_text_string(fname)) if path in self._to_be_loaded: self._to_be_loaded.remove(path) if self._to_be_loaded is not None and len(self._to_be_loaded) == 0: self.fsmodel.directoryLoaded.disconnect( self.follow_directories_loaded) if self._scrollbar_positions is not None: # The tree view need some time to render branches: QTimer.singleShot(50, self.restore_scrollbar_positions)
python
def follow_directories_loaded(self, fname): """Follow directories loaded during startup""" if self._to_be_loaded is None: return path = osp.normpath(to_text_string(fname)) if path in self._to_be_loaded: self._to_be_loaded.remove(path) if self._to_be_loaded is not None and len(self._to_be_loaded) == 0: self.fsmodel.directoryLoaded.disconnect( self.follow_directories_loaded) if self._scrollbar_positions is not None: # The tree view need some time to render branches: QTimer.singleShot(50, self.restore_scrollbar_positions)
[ "def", "follow_directories_loaded", "(", "self", ",", "fname", ")", ":", "if", "self", ".", "_to_be_loaded", "is", "None", ":", "return", "path", "=", "osp", ".", "normpath", "(", "to_text_string", "(", "fname", ")", ")", "if", "path", "in", "self", ".",...
Follow directories loaded during startup
[ "Follow", "directories", "loaded", "during", "startup" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1103-L1115
30,841
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
DirView.filter_directories
def filter_directories(self): """Filter the directories to show""" index = self.get_index('.spyproject') if index is not None: self.setRowHidden(index.row(), index.parent(), True)
python
def filter_directories(self): """Filter the directories to show""" index = self.get_index('.spyproject') if index is not None: self.setRowHidden(index.row(), index.parent(), True)
[ "def", "filter_directories", "(", "self", ")", ":", "index", "=", "self", ".", "get_index", "(", "'.spyproject'", ")", "if", "index", "is", "not", "None", ":", "self", ".", "setRowHidden", "(", "index", ".", "row", "(", ")", ",", "index", ".", "parent"...
Filter the directories to show
[ "Filter", "the", "directories", "to", "show" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1127-L1131
30,842
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
ProxyModel.setup_filter
def setup_filter(self, root_path, path_list): """Setup proxy model filter parameters""" self.root_path = osp.normpath(to_text_string(root_path)) self.path_list = [osp.normpath(to_text_string(p)) for p in path_list] self.invalidateFilter()
python
def setup_filter(self, root_path, path_list): """Setup proxy model filter parameters""" self.root_path = osp.normpath(to_text_string(root_path)) self.path_list = [osp.normpath(to_text_string(p)) for p in path_list] self.invalidateFilter()
[ "def", "setup_filter", "(", "self", ",", "root_path", ",", "path_list", ")", ":", "self", ".", "root_path", "=", "osp", ".", "normpath", "(", "to_text_string", "(", "root_path", ")", ")", "self", ".", "path_list", "=", "[", "osp", ".", "normpath", "(", ...
Setup proxy model filter parameters
[ "Setup", "proxy", "model", "filter", "parameters" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1141-L1145
30,843
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
ProxyModel.data
def data(self, index, role): """Show tooltip with full path only for the root directory""" if role == Qt.ToolTipRole: root_dir = self.path_list[0].split(osp.sep)[-1] if index.data() == root_dir: return osp.join(self.root_path, root_dir) return QSortFilterProxyModel.data(self, index, role)
python
def data(self, index, role): """Show tooltip with full path only for the root directory""" if role == Qt.ToolTipRole: root_dir = self.path_list[0].split(osp.sep)[-1] if index.data() == root_dir: return osp.join(self.root_path, root_dir) return QSortFilterProxyModel.data(self, index, role)
[ "def", "data", "(", "self", ",", "index", ",", "role", ")", ":", "if", "role", "==", "Qt", ".", "ToolTipRole", ":", "root_dir", "=", "self", ".", "path_list", "[", "0", "]", ".", "split", "(", "osp", ".", "sep", ")", "[", "-", "1", "]", "if", ...
Show tooltip with full path only for the root directory
[ "Show", "tooltip", "with", "full", "path", "only", "for", "the", "root", "directory" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1168-L1174
30,844
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
FilteredDirView.setup_proxy_model
def setup_proxy_model(self): """Setup proxy model""" self.proxymodel = ProxyModel(self) self.proxymodel.setSourceModel(self.fsmodel)
python
def setup_proxy_model(self): """Setup proxy model""" self.proxymodel = ProxyModel(self) self.proxymodel.setSourceModel(self.fsmodel)
[ "def", "setup_proxy_model", "(", "self", ")", ":", "self", ".", "proxymodel", "=", "ProxyModel", "(", "self", ")", "self", ".", "proxymodel", ".", "setSourceModel", "(", "self", ".", "fsmodel", ")" ]
Setup proxy model
[ "Setup", "proxy", "model" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1185-L1188
30,845
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
FilteredDirView.set_root_path
def set_root_path(self, root_path): """Set root path""" self.root_path = root_path self.install_model() index = self.fsmodel.setRootPath(root_path) self.proxymodel.setup_filter(self.root_path, []) self.setRootIndex(self.proxymodel.mapFromSource(index))
python
def set_root_path(self, root_path): """Set root path""" self.root_path = root_path self.install_model() index = self.fsmodel.setRootPath(root_path) self.proxymodel.setup_filter(self.root_path, []) self.setRootIndex(self.proxymodel.mapFromSource(index))
[ "def", "set_root_path", "(", "self", ",", "root_path", ")", ":", "self", ".", "root_path", "=", "root_path", "self", ".", "install_model", "(", ")", "index", "=", "self", ".", "fsmodel", ".", "setRootPath", "(", "root_path", ")", "self", ".", "proxymodel",...
Set root path
[ "Set", "root", "path" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1195-L1201
30,846
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
FilteredDirView.get_index
def get_index(self, filename): """Return index associated with filename""" index = self.fsmodel.index(filename) if index.isValid() and index.model() is self.fsmodel: return self.proxymodel.mapFromSource(index)
python
def get_index(self, filename): """Return index associated with filename""" index = self.fsmodel.index(filename) if index.isValid() and index.model() is self.fsmodel: return self.proxymodel.mapFromSource(index)
[ "def", "get_index", "(", "self", ",", "filename", ")", ":", "index", "=", "self", ".", "fsmodel", ".", "index", "(", "filename", ")", "if", "index", ".", "isValid", "(", ")", "and", "index", ".", "model", "(", ")", "is", "self", ".", "fsmodel", ":"...
Return index associated with filename
[ "Return", "index", "associated", "with", "filename" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1203-L1207
30,847
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
FilteredDirView.set_folder_names
def set_folder_names(self, folder_names): """Set folder names""" assert self.root_path is not None path_list = [osp.join(self.root_path, dirname) for dirname in folder_names] self.proxymodel.setup_filter(self.root_path, path_list)
python
def set_folder_names(self, folder_names): """Set folder names""" assert self.root_path is not None path_list = [osp.join(self.root_path, dirname) for dirname in folder_names] self.proxymodel.setup_filter(self.root_path, path_list)
[ "def", "set_folder_names", "(", "self", ",", "folder_names", ")", ":", "assert", "self", ".", "root_path", "is", "not", "None", "path_list", "=", "[", "osp", ".", "join", "(", "self", ".", "root_path", ",", "dirname", ")", "for", "dirname", "in", "folder...
Set folder names
[ "Set", "folder", "names" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1209-L1214
30,848
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
FilteredDirView.get_filename
def get_filename(self, index): """Return filename from index""" if index: path = self.fsmodel.filePath(self.proxymodel.mapToSource(index)) return osp.normpath(to_text_string(path))
python
def get_filename(self, index): """Return filename from index""" if index: path = self.fsmodel.filePath(self.proxymodel.mapToSource(index)) return osp.normpath(to_text_string(path))
[ "def", "get_filename", "(", "self", ",", "index", ")", ":", "if", "index", ":", "path", "=", "self", ".", "fsmodel", ".", "filePath", "(", "self", ".", "proxymodel", ".", "mapToSource", "(", "index", ")", ")", "return", "osp", ".", "normpath", "(", "...
Return filename from index
[ "Return", "filename", "from", "index" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1216-L1220
30,849
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
FilteredDirView.setup_project_view
def setup_project_view(self): """Setup view for projects""" for i in [1, 2, 3]: self.hideColumn(i) self.setHeaderHidden(True) # Disable the view of .spyproject. self.filter_directories()
python
def setup_project_view(self): """Setup view for projects""" for i in [1, 2, 3]: self.hideColumn(i) self.setHeaderHidden(True) # Disable the view of .spyproject. self.filter_directories()
[ "def", "setup_project_view", "(", "self", ")", ":", "for", "i", "in", "[", "1", ",", "2", ",", "3", "]", ":", "self", ".", "hideColumn", "(", "i", ")", "self", ".", "setHeaderHidden", "(", "True", ")", "# Disable the view of .spyproject. \r", "self", "."...
Setup view for projects
[ "Setup", "view", "for", "projects" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1222-L1228
30,850
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
ExplorerTreeWidget.toggle_show_cd_only
def toggle_show_cd_only(self, checked): """Toggle show current directory only mode""" self.parent_widget.sig_option_changed.emit('show_cd_only', checked) self.show_cd_only = checked if checked: if self.__last_folder is not None: self.set_current_folder(self.__last_folder) elif self.__original_root_index is not None: self.setRootIndex(self.__original_root_index)
python
def toggle_show_cd_only(self, checked): """Toggle show current directory only mode""" self.parent_widget.sig_option_changed.emit('show_cd_only', checked) self.show_cd_only = checked if checked: if self.__last_folder is not None: self.set_current_folder(self.__last_folder) elif self.__original_root_index is not None: self.setRootIndex(self.__original_root_index)
[ "def", "toggle_show_cd_only", "(", "self", ",", "checked", ")", ":", "self", ".", "parent_widget", ".", "sig_option_changed", ".", "emit", "(", "'show_cd_only'", ",", "checked", ")", "self", ".", "show_cd_only", "=", "checked", "if", "checked", ":", "if", "s...
Toggle show current directory only mode
[ "Toggle", "show", "current", "directory", "only", "mode" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1275-L1283
30,851
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
ExplorerTreeWidget.set_current_folder
def set_current_folder(self, folder): """Set current folder and return associated model index""" index = self.fsmodel.setRootPath(folder) self.__last_folder = folder if self.show_cd_only: if self.__original_root_index is None: self.__original_root_index = self.rootIndex() self.setRootIndex(index) return index
python
def set_current_folder(self, folder): """Set current folder and return associated model index""" index = self.fsmodel.setRootPath(folder) self.__last_folder = folder if self.show_cd_only: if self.__original_root_index is None: self.__original_root_index = self.rootIndex() self.setRootIndex(index) return index
[ "def", "set_current_folder", "(", "self", ",", "folder", ")", ":", "index", "=", "self", ".", "fsmodel", ".", "setRootPath", "(", "folder", ")", "self", ".", "__last_folder", "=", "folder", "if", "self", ".", "show_cd_only", ":", "if", "self", ".", "__or...
Set current folder and return associated model index
[ "Set", "current", "folder", "and", "return", "associated", "model", "index" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1286-L1294
30,852
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
ExplorerTreeWidget.go_to_parent_directory
def go_to_parent_directory(self): """Go to parent directory""" self.chdir(osp.abspath(osp.join(getcwd_or_home(), os.pardir)))
python
def go_to_parent_directory(self): """Go to parent directory""" self.chdir(osp.abspath(osp.join(getcwd_or_home(), os.pardir)))
[ "def", "go_to_parent_directory", "(", "self", ")", ":", "self", ".", "chdir", "(", "osp", ".", "abspath", "(", "osp", ".", "join", "(", "getcwd_or_home", "(", ")", ",", "os", ".", "pardir", ")", ")", ")" ]
Go to parent directory
[ "Go", "to", "parent", "directory" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1322-L1324
30,853
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
ExplorerTreeWidget.update_history
def update_history(self, directory): """Update browse history""" try: directory = osp.abspath(to_text_string(directory)) if directory in self.history: self.histindex = self.history.index(directory) except Exception: user_directory = get_home_dir() self.chdir(directory=user_directory, browsing_history=True)
python
def update_history(self, directory): """Update browse history""" try: directory = osp.abspath(to_text_string(directory)) if directory in self.history: self.histindex = self.history.index(directory) except Exception: user_directory = get_home_dir() self.chdir(directory=user_directory, browsing_history=True)
[ "def", "update_history", "(", "self", ",", "directory", ")", ":", "try", ":", "directory", "=", "osp", ".", "abspath", "(", "to_text_string", "(", "directory", ")", ")", "if", "directory", "in", "self", ".", "history", ":", "self", ".", "histindex", "=",...
Update browse history
[ "Update", "browse", "history" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1338-L1346
30,854
spyder-ide/spyder
spyder/plugins/explorer/widgets.py
ExplorerWidget.toggle_icontext
def toggle_icontext(self, state): """Toggle icon text""" self.sig_option_changed.emit('show_icontext', state) for widget in self.action_widgets: if widget is not self.button_menu: if state: widget.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) else: widget.setToolButtonStyle(Qt.ToolButtonIconOnly)
python
def toggle_icontext(self, state): """Toggle icon text""" self.sig_option_changed.emit('show_icontext', state) for widget in self.action_widgets: if widget is not self.button_menu: if state: widget.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) else: widget.setToolButtonStyle(Qt.ToolButtonIconOnly)
[ "def", "toggle_icontext", "(", "self", ",", "state", ")", ":", "self", ".", "sig_option_changed", ".", "emit", "(", "'show_icontext'", ",", "state", ")", "for", "widget", "in", "self", ".", "action_widgets", ":", "if", "widget", "is", "not", "self", ".", ...
Toggle icon text
[ "Toggle", "icon", "text" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1463-L1471
30,855
spyder-ide/spyder
spyder/plugins/breakpoints/widgets/breakpointsgui.py
BreakpointTableModel.data
def data(self, index, role=Qt.DisplayRole): """Return data at table index""" if not index.isValid(): return to_qvariant() if role == Qt.DisplayRole: if index.column() == 0: value = osp.basename(self.get_value(index)) return to_qvariant(value) else: value = self.get_value(index) return to_qvariant(value) elif role == Qt.TextAlignmentRole: return to_qvariant(int(Qt.AlignLeft|Qt.AlignVCenter)) elif role == Qt.ToolTipRole: if index.column() == 0: value = self.get_value(index) return to_qvariant(value) else: return to_qvariant()
python
def data(self, index, role=Qt.DisplayRole): """Return data at table index""" if not index.isValid(): return to_qvariant() if role == Qt.DisplayRole: if index.column() == 0: value = osp.basename(self.get_value(index)) return to_qvariant(value) else: value = self.get_value(index) return to_qvariant(value) elif role == Qt.TextAlignmentRole: return to_qvariant(int(Qt.AlignLeft|Qt.AlignVCenter)) elif role == Qt.ToolTipRole: if index.column() == 0: value = self.get_value(index) return to_qvariant(value) else: return to_qvariant()
[ "def", "data", "(", "self", ",", "index", ",", "role", "=", "Qt", ".", "DisplayRole", ")", ":", "if", "not", "index", ".", "isValid", "(", ")", ":", "return", "to_qvariant", "(", ")", "if", "role", "==", "Qt", ".", "DisplayRole", ":", "if", "index"...
Return data at table index
[ "Return", "data", "at", "table", "index" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/breakpoints/widgets/breakpointsgui.py#L107-L125
30,856
spyder-ide/spyder
spyder/plugins/editor/lsp/manager.py
LSPManager.get_languages
def get_languages(self): """ Get the list of languages we need to start servers and create clients for. """ languages = ['python'] all_options = CONF.options(self.CONF_SECTION) for option in all_options: if option in [l.lower() for l in LSP_LANGUAGES]: languages.append(option) return languages
python
def get_languages(self): """ Get the list of languages we need to start servers and create clients for. """ languages = ['python'] all_options = CONF.options(self.CONF_SECTION) for option in all_options: if option in [l.lower() for l in LSP_LANGUAGES]: languages.append(option) return languages
[ "def", "get_languages", "(", "self", ")", ":", "languages", "=", "[", "'python'", "]", "all_options", "=", "CONF", ".", "options", "(", "self", ".", "CONF_SECTION", ")", "for", "option", "in", "all_options", ":", "if", "option", "in", "[", "l", ".", "l...
Get the list of languages we need to start servers and create clients for.
[ "Get", "the", "list", "of", "languages", "we", "need", "to", "start", "servers", "and", "create", "clients", "for", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/manager.py#L68-L78
30,857
spyder-ide/spyder
spyder/plugins/editor/lsp/manager.py
LSPManager.get_root_path
def get_root_path(self, language): """ Get root path to pass to the LSP servers. This can be the current project path or the output of getcwd_or_home (except for Python, see below). """ path = None # Get path of the current project if self.main and self.main.projects: path = self.main.projects.get_active_project_path() # If there's no project, use the output of getcwd_or_home. if not path: # We can't use getcwd_or_home for Python because if it # returns home and you have a lot of Python files on it # then computing Rope completions takes a long time # and blocks the PyLS server. # Instead we use an empty directory inside our config one, # just like we did for Rope in Spyder 3. if language == 'python': path = get_conf_path('lsp_root_path') if not osp.exists(path): os.mkdir(path) else: path = getcwd_or_home() return path
python
def get_root_path(self, language): """ Get root path to pass to the LSP servers. This can be the current project path or the output of getcwd_or_home (except for Python, see below). """ path = None # Get path of the current project if self.main and self.main.projects: path = self.main.projects.get_active_project_path() # If there's no project, use the output of getcwd_or_home. if not path: # We can't use getcwd_or_home for Python because if it # returns home and you have a lot of Python files on it # then computing Rope completions takes a long time # and blocks the PyLS server. # Instead we use an empty directory inside our config one, # just like we did for Rope in Spyder 3. if language == 'python': path = get_conf_path('lsp_root_path') if not osp.exists(path): os.mkdir(path) else: path = getcwd_or_home() return path
[ "def", "get_root_path", "(", "self", ",", "language", ")", ":", "path", "=", "None", "# Get path of the current project", "if", "self", ".", "main", "and", "self", ".", "main", ".", "projects", ":", "path", "=", "self", ".", "main", ".", "projects", ".", ...
Get root path to pass to the LSP servers. This can be the current project path or the output of getcwd_or_home (except for Python, see below).
[ "Get", "root", "path", "to", "pass", "to", "the", "LSP", "servers", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/manager.py#L87-L115
30,858
spyder-ide/spyder
spyder/plugins/editor/lsp/manager.py
LSPManager.reinitialize_all_clients
def reinitialize_all_clients(self): """ Send a new initialize message to each LSP server when the project path has changed so they can update the respective server root paths. """ for language in self.clients: language_client = self.clients[language] if language_client['status'] == self.RUNNING: folder = self.get_root_path(language) instance = language_client['instance'] instance.folder = folder instance.initialize()
python
def reinitialize_all_clients(self): """ Send a new initialize message to each LSP server when the project path has changed so they can update the respective server root paths. """ for language in self.clients: language_client = self.clients[language] if language_client['status'] == self.RUNNING: folder = self.get_root_path(language) instance = language_client['instance'] instance.folder = folder instance.initialize()
[ "def", "reinitialize_all_clients", "(", "self", ")", ":", "for", "language", "in", "self", ".", "clients", ":", "language_client", "=", "self", ".", "clients", "[", "language", "]", "if", "language_client", "[", "'status'", "]", "==", "self", ".", "RUNNING",...
Send a new initialize message to each LSP server when the project path has changed so they can update the respective server root paths.
[ "Send", "a", "new", "initialize", "message", "to", "each", "LSP", "server", "when", "the", "project", "path", "has", "changed", "so", "they", "can", "update", "the", "respective", "server", "root", "paths", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/manager.py#L118-L129
30,859
spyder-ide/spyder
spyder/plugins/editor/lsp/manager.py
LSPManager.start_client
def start_client(self, language): """Start an LSP client for a given language.""" started = False if language in self.clients: language_client = self.clients[language] queue = self.register_queue[language] # Don't start LSP services when testing unless we demand # them. if running_under_pytest(): if not os.environ.get('SPY_TEST_USE_INTROSPECTION'): return started # Start client started = language_client['status'] == self.RUNNING if language_client['status'] == self.STOPPED: config = language_client['config'] if not config['external']: port = select_port(default_port=config['port']) config['port'] = port language_client['instance'] = LSPClient( parent=self, server_settings=config, folder=self.get_root_path(language), language=language ) # Connect signals emitted by the client to the methods that # can handle them if self.main and self.main.editor: language_client['instance'].sig_initialize.connect( self.main.editor.register_lsp_server_settings) logger.info("Starting LSP client for {}...".format(language)) language_client['instance'].start() language_client['status'] = self.RUNNING for entry in queue: language_client.register_file(*entry) self.register_queue[language] = [] return started
python
def start_client(self, language): """Start an LSP client for a given language.""" started = False if language in self.clients: language_client = self.clients[language] queue = self.register_queue[language] # Don't start LSP services when testing unless we demand # them. if running_under_pytest(): if not os.environ.get('SPY_TEST_USE_INTROSPECTION'): return started # Start client started = language_client['status'] == self.RUNNING if language_client['status'] == self.STOPPED: config = language_client['config'] if not config['external']: port = select_port(default_port=config['port']) config['port'] = port language_client['instance'] = LSPClient( parent=self, server_settings=config, folder=self.get_root_path(language), language=language ) # Connect signals emitted by the client to the methods that # can handle them if self.main and self.main.editor: language_client['instance'].sig_initialize.connect( self.main.editor.register_lsp_server_settings) logger.info("Starting LSP client for {}...".format(language)) language_client['instance'].start() language_client['status'] = self.RUNNING for entry in queue: language_client.register_file(*entry) self.register_queue[language] = [] return started
[ "def", "start_client", "(", "self", ",", "language", ")", ":", "started", "=", "False", "if", "language", "in", "self", ".", "clients", ":", "language_client", "=", "self", ".", "clients", "[", "language", "]", "queue", "=", "self", ".", "register_queue", ...
Start an LSP client for a given language.
[ "Start", "an", "LSP", "client", "for", "a", "given", "language", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/manager.py#L131-L172
30,860
spyder-ide/spyder
spyder/plugins/history/confpage.py
HistoryConfigPage.setup_page
def setup_page(self): """Setup config page widgets and options.""" settings_group = QGroupBox(_("Settings")) hist_spin = self.create_spinbox( _("History depth: "), _(" entries"), 'max_entries', min_=10, max_=10000, step=10, tip=_("Set maximum line count")) sourcecode_group = QGroupBox(_("Source code")) wrap_mode_box = self.create_checkbox(_("Wrap lines"), 'wrap') linenumbers_mode_box = self.create_checkbox(_("Show line numbers"), 'line_numbers') go_to_eof_box = self.create_checkbox( _("Scroll automatically to last entry"), 'go_to_eof') settings_layout = QVBoxLayout() settings_layout.addWidget(hist_spin) settings_group.setLayout(settings_layout) sourcecode_layout = QVBoxLayout() sourcecode_layout.addWidget(wrap_mode_box) sourcecode_layout.addWidget(linenumbers_mode_box) sourcecode_layout.addWidget(go_to_eof_box) sourcecode_group.setLayout(sourcecode_layout) vlayout = QVBoxLayout() vlayout.addWidget(settings_group) vlayout.addWidget(sourcecode_group) vlayout.addStretch(1) self.setLayout(vlayout)
python
def setup_page(self): """Setup config page widgets and options.""" settings_group = QGroupBox(_("Settings")) hist_spin = self.create_spinbox( _("History depth: "), _(" entries"), 'max_entries', min_=10, max_=10000, step=10, tip=_("Set maximum line count")) sourcecode_group = QGroupBox(_("Source code")) wrap_mode_box = self.create_checkbox(_("Wrap lines"), 'wrap') linenumbers_mode_box = self.create_checkbox(_("Show line numbers"), 'line_numbers') go_to_eof_box = self.create_checkbox( _("Scroll automatically to last entry"), 'go_to_eof') settings_layout = QVBoxLayout() settings_layout.addWidget(hist_spin) settings_group.setLayout(settings_layout) sourcecode_layout = QVBoxLayout() sourcecode_layout.addWidget(wrap_mode_box) sourcecode_layout.addWidget(linenumbers_mode_box) sourcecode_layout.addWidget(go_to_eof_box) sourcecode_group.setLayout(sourcecode_layout) vlayout = QVBoxLayout() vlayout.addWidget(settings_group) vlayout.addWidget(sourcecode_group) vlayout.addStretch(1) self.setLayout(vlayout)
[ "def", "setup_page", "(", "self", ")", ":", "settings_group", "=", "QGroupBox", "(", "_", "(", "\"Settings\"", ")", ")", "hist_spin", "=", "self", ".", "create_spinbox", "(", "_", "(", "\"History depth: \"", ")", ",", "_", "(", "\" entries\"", ")", ",", ...
Setup config page widgets and options.
[ "Setup", "config", "page", "widgets", "and", "options", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/history/confpage.py#L25-L54
30,861
spyder-ide/spyder
spyder/utils/encoding.py
transcode
def transcode(text, input=PREFERRED_ENCODING, output=PREFERRED_ENCODING): """Transcode a text string""" try: return text.decode("cp437").encode("cp1252") except UnicodeError: try: return text.decode("cp437").encode(output) except UnicodeError: return text
python
def transcode(text, input=PREFERRED_ENCODING, output=PREFERRED_ENCODING): """Transcode a text string""" try: return text.decode("cp437").encode("cp1252") except UnicodeError: try: return text.decode("cp437").encode(output) except UnicodeError: return text
[ "def", "transcode", "(", "text", ",", "input", "=", "PREFERRED_ENCODING", ",", "output", "=", "PREFERRED_ENCODING", ")", ":", "try", ":", "return", "text", ".", "decode", "(", "\"cp437\"", ")", ".", "encode", "(", "\"cp1252\"", ")", "except", "UnicodeError",...
Transcode a text string
[ "Transcode", "a", "text", "string" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/encoding.py#L33-L41
30,862
spyder-ide/spyder
spyder/utils/encoding.py
to_unicode_from_fs
def to_unicode_from_fs(string): """ Return a unicode version of string decoded using the file system encoding. """ if not is_string(string): # string is a QString string = to_text_string(string.toUtf8(), 'utf-8') else: if is_binary_string(string): try: unic = string.decode(FS_ENCODING) except (UnicodeError, TypeError): pass else: return unic return string
python
def to_unicode_from_fs(string): """ Return a unicode version of string decoded using the file system encoding. """ if not is_string(string): # string is a QString string = to_text_string(string.toUtf8(), 'utf-8') else: if is_binary_string(string): try: unic = string.decode(FS_ENCODING) except (UnicodeError, TypeError): pass else: return unic return string
[ "def", "to_unicode_from_fs", "(", "string", ")", ":", "if", "not", "is_string", "(", "string", ")", ":", "# string is a QString\r", "string", "=", "to_text_string", "(", "string", ".", "toUtf8", "(", ")", ",", "'utf-8'", ")", "else", ":", "if", "is_binary_st...
Return a unicode version of string decoded using the file system encoding.
[ "Return", "a", "unicode", "version", "of", "string", "decoded", "using", "the", "file", "system", "encoding", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/encoding.py#L63-L77
30,863
spyder-ide/spyder
spyder/utils/encoding.py
to_fs_from_unicode
def to_fs_from_unicode(unic): """ Return a byte string version of unic encoded using the file system encoding. """ if is_unicode(unic): try: string = unic.encode(FS_ENCODING) except (UnicodeError, TypeError): pass else: return string return unic
python
def to_fs_from_unicode(unic): """ Return a byte string version of unic encoded using the file system encoding. """ if is_unicode(unic): try: string = unic.encode(FS_ENCODING) except (UnicodeError, TypeError): pass else: return string return unic
[ "def", "to_fs_from_unicode", "(", "unic", ")", ":", "if", "is_unicode", "(", "unic", ")", ":", "try", ":", "string", "=", "unic", ".", "encode", "(", "FS_ENCODING", ")", "except", "(", "UnicodeError", ",", "TypeError", ")", ":", "pass", "else", ":", "r...
Return a byte string version of unic encoded using the file system encoding.
[ "Return", "a", "byte", "string", "version", "of", "unic", "encoded", "using", "the", "file", "system", "encoding", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/encoding.py#L79-L91
30,864
spyder-ide/spyder
spyder/utils/encoding.py
decode
def decode(text): """ Function to decode a text. @param text text to decode (string) @return decoded text and encoding """ try: if text.startswith(BOM_UTF8): # UTF-8 with BOM return to_text_string(text[len(BOM_UTF8):], 'utf-8'), 'utf-8-bom' elif text.startswith(BOM_UTF16): # UTF-16 with BOM return to_text_string(text[len(BOM_UTF16):], 'utf-16'), 'utf-16' elif text.startswith(BOM_UTF32): # UTF-32 with BOM return to_text_string(text[len(BOM_UTF32):], 'utf-32'), 'utf-32' coding = get_coding(text) if coding: return to_text_string(text, coding), coding except (UnicodeError, LookupError): pass # Assume UTF-8 try: return to_text_string(text, 'utf-8'), 'utf-8-guessed' except (UnicodeError, LookupError): pass # Assume Latin-1 (behaviour before 3.7.1) return to_text_string(text, "latin-1"), 'latin-1-guessed'
python
def decode(text): """ Function to decode a text. @param text text to decode (string) @return decoded text and encoding """ try: if text.startswith(BOM_UTF8): # UTF-8 with BOM return to_text_string(text[len(BOM_UTF8):], 'utf-8'), 'utf-8-bom' elif text.startswith(BOM_UTF16): # UTF-16 with BOM return to_text_string(text[len(BOM_UTF16):], 'utf-16'), 'utf-16' elif text.startswith(BOM_UTF32): # UTF-32 with BOM return to_text_string(text[len(BOM_UTF32):], 'utf-32'), 'utf-32' coding = get_coding(text) if coding: return to_text_string(text, coding), coding except (UnicodeError, LookupError): pass # Assume UTF-8 try: return to_text_string(text, 'utf-8'), 'utf-8-guessed' except (UnicodeError, LookupError): pass # Assume Latin-1 (behaviour before 3.7.1) return to_text_string(text, "latin-1"), 'latin-1-guessed'
[ "def", "decode", "(", "text", ")", ":", "try", ":", "if", "text", ".", "startswith", "(", "BOM_UTF8", ")", ":", "# UTF-8 with BOM\r", "return", "to_text_string", "(", "text", "[", "len", "(", "BOM_UTF8", ")", ":", "]", ",", "'utf-8'", ")", ",", "'utf-8...
Function to decode a text. @param text text to decode (string) @return decoded text and encoding
[ "Function", "to", "decode", "a", "text", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/encoding.py#L142-L169
30,865
spyder-ide/spyder
spyder/config/utils.py
_get_pygments_extensions
def _get_pygments_extensions(): """Return all file type extensions supported by Pygments""" # NOTE: Leave this import here to keep startup process fast! import pygments.lexers as lexers extensions = [] for lx in lexers.get_all_lexers(): lexer_exts = lx[2] if lexer_exts: # Reference: This line was included for leaving untrimmed the # extensions not starting with `*` other_exts = [le for le in lexer_exts if not le.startswith('*')] # Reference: This commented line was replaced by the following one # to trim only extensions that start with '*' # lexer_exts = [le[1:] for le in lexer_exts] lexer_exts = [le[1:] for le in lexer_exts if le.startswith('*')] lexer_exts = [le for le in lexer_exts if not le.endswith('_*')] extensions = extensions + list(lexer_exts) + list(other_exts) return sorted(list(set(extensions)))
python
def _get_pygments_extensions(): """Return all file type extensions supported by Pygments""" # NOTE: Leave this import here to keep startup process fast! import pygments.lexers as lexers extensions = [] for lx in lexers.get_all_lexers(): lexer_exts = lx[2] if lexer_exts: # Reference: This line was included for leaving untrimmed the # extensions not starting with `*` other_exts = [le for le in lexer_exts if not le.startswith('*')] # Reference: This commented line was replaced by the following one # to trim only extensions that start with '*' # lexer_exts = [le[1:] for le in lexer_exts] lexer_exts = [le[1:] for le in lexer_exts if le.startswith('*')] lexer_exts = [le for le in lexer_exts if not le.endswith('_*')] extensions = extensions + list(lexer_exts) + list(other_exts) return sorted(list(set(extensions)))
[ "def", "_get_pygments_extensions", "(", ")", ":", "# NOTE: Leave this import here to keep startup process fast!", "import", "pygments", ".", "lexers", "as", "lexers", "extensions", "=", "[", "]", "for", "lx", "in", "lexers", ".", "get_all_lexers", "(", ")", ":", "le...
Return all file type extensions supported by Pygments
[ "Return", "all", "file", "type", "extensions", "supported", "by", "Pygments" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/utils.py#L82-L102
30,866
spyder-ide/spyder
spyder/config/utils.py
get_filter
def get_filter(filetypes, ext): """Return filter associated to file extension""" if not ext: return ALL_FILTER for title, ftypes in filetypes: if ext in ftypes: return _create_filter(title, ftypes) else: return ''
python
def get_filter(filetypes, ext): """Return filter associated to file extension""" if not ext: return ALL_FILTER for title, ftypes in filetypes: if ext in ftypes: return _create_filter(title, ftypes) else: return ''
[ "def", "get_filter", "(", "filetypes", ",", "ext", ")", ":", "if", "not", "ext", ":", "return", "ALL_FILTER", "for", "title", ",", "ftypes", "in", "filetypes", ":", "if", "ext", "in", "ftypes", ":", "return", "_create_filter", "(", "title", ",", "ftypes"...
Return filter associated to file extension
[ "Return", "filter", "associated", "to", "file", "extension" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/utils.py#L108-L116
30,867
spyder-ide/spyder
spyder/config/utils.py
get_edit_filetypes
def get_edit_filetypes(): """Get all file types supported by the Editor""" # The filter details are not hidden on Windows, so we can't use # all Pygments extensions on that platform if os.name == 'nt': supported_exts = [] else: try: supported_exts = _get_pygments_extensions() except Exception: supported_exts = [] # NOTE: Try to not add too much extensions to this list to not # make the filter look too big on Windows favorite_exts = ['.py', '.R', '.jl', '.ipynb', '.md', '.pyw', '.pyx', '.c', '.cpp', '.json', '.dat', '.csv', '.tsv', '.txt', '.ini', '.html', '.js', '.h', '.bat'] other_exts = [ext for ext in supported_exts if ext not in favorite_exts] all_exts = tuple(favorite_exts + other_exts) text_filetypes = (_("Supported text files"), all_exts) return [text_filetypes] + EDIT_FILETYPES
python
def get_edit_filetypes(): """Get all file types supported by the Editor""" # The filter details are not hidden on Windows, so we can't use # all Pygments extensions on that platform if os.name == 'nt': supported_exts = [] else: try: supported_exts = _get_pygments_extensions() except Exception: supported_exts = [] # NOTE: Try to not add too much extensions to this list to not # make the filter look too big on Windows favorite_exts = ['.py', '.R', '.jl', '.ipynb', '.md', '.pyw', '.pyx', '.c', '.cpp', '.json', '.dat', '.csv', '.tsv', '.txt', '.ini', '.html', '.js', '.h', '.bat'] other_exts = [ext for ext in supported_exts if ext not in favorite_exts] all_exts = tuple(favorite_exts + other_exts) text_filetypes = (_("Supported text files"), all_exts) return [text_filetypes] + EDIT_FILETYPES
[ "def", "get_edit_filetypes", "(", ")", ":", "# The filter details are not hidden on Windows, so we can't use", "# all Pygments extensions on that platform", "if", "os", ".", "name", "==", "'nt'", ":", "supported_exts", "=", "[", "]", "else", ":", "try", ":", "supported_ex...
Get all file types supported by the Editor
[ "Get", "all", "file", "types", "supported", "by", "the", "Editor" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/utils.py#L119-L140
30,868
spyder-ide/spyder
spyder/config/utils.py
is_ubuntu
def is_ubuntu(): """Detect if we are running in an Ubuntu-based distribution""" if sys.platform.startswith('linux') and osp.isfile('/etc/lsb-release'): release_info = open('/etc/lsb-release').read() if 'Ubuntu' in release_info: return True else: return False else: return False
python
def is_ubuntu(): """Detect if we are running in an Ubuntu-based distribution""" if sys.platform.startswith('linux') and osp.isfile('/etc/lsb-release'): release_info = open('/etc/lsb-release').read() if 'Ubuntu' in release_info: return True else: return False else: return False
[ "def", "is_ubuntu", "(", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'linux'", ")", "and", "osp", ".", "isfile", "(", "'/etc/lsb-release'", ")", ":", "release_info", "=", "open", "(", "'/etc/lsb-release'", ")", ".", "read", "(", ")",...
Detect if we are running in an Ubuntu-based distribution
[ "Detect", "if", "we", "are", "running", "in", "an", "Ubuntu", "-", "based", "distribution" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/utils.py#L164-L173
30,869
spyder-ide/spyder
spyder/config/utils.py
is_gtk_desktop
def is_gtk_desktop(): """Detect if we are running in a Gtk-based desktop""" if sys.platform.startswith('linux'): xdg_desktop = os.environ.get('XDG_CURRENT_DESKTOP', '') if xdg_desktop: gtk_desktops = ['Unity', 'GNOME', 'XFCE'] if any([xdg_desktop.startswith(d) for d in gtk_desktops]): return True else: return False else: return False else: return False
python
def is_gtk_desktop(): """Detect if we are running in a Gtk-based desktop""" if sys.platform.startswith('linux'): xdg_desktop = os.environ.get('XDG_CURRENT_DESKTOP', '') if xdg_desktop: gtk_desktops = ['Unity', 'GNOME', 'XFCE'] if any([xdg_desktop.startswith(d) for d in gtk_desktops]): return True else: return False else: return False else: return False
[ "def", "is_gtk_desktop", "(", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'linux'", ")", ":", "xdg_desktop", "=", "os", ".", "environ", ".", "get", "(", "'XDG_CURRENT_DESKTOP'", ",", "''", ")", "if", "xdg_desktop", ":", "gtk_desktops",...
Detect if we are running in a Gtk-based desktop
[ "Detect", "if", "we", "are", "running", "in", "a", "Gtk", "-", "based", "desktop" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/utils.py#L176-L189
30,870
spyder-ide/spyder
spyder/config/utils.py
is_kde_desktop
def is_kde_desktop(): """Detect if we are running in a KDE desktop""" if sys.platform.startswith('linux'): xdg_desktop = os.environ.get('XDG_CURRENT_DESKTOP', '') if xdg_desktop: if 'KDE' in xdg_desktop: return True else: return False else: return False else: return False
python
def is_kde_desktop(): """Detect if we are running in a KDE desktop""" if sys.platform.startswith('linux'): xdg_desktop = os.environ.get('XDG_CURRENT_DESKTOP', '') if xdg_desktop: if 'KDE' in xdg_desktop: return True else: return False else: return False else: return False
[ "def", "is_kde_desktop", "(", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'linux'", ")", ":", "xdg_desktop", "=", "os", ".", "environ", ".", "get", "(", "'XDG_CURRENT_DESKTOP'", ",", "''", ")", "if", "xdg_desktop", ":", "if", "'KDE'"...
Detect if we are running in a KDE desktop
[ "Detect", "if", "we", "are", "running", "in", "a", "KDE", "desktop" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/utils.py#L192-L204
30,871
spyder-ide/spyder
spyder/plugins/projects/projecttypes/python.py
PythonProject._get_relative_pythonpath
def _get_relative_pythonpath(self): """Return PYTHONPATH list as relative paths""" # Workaround to replace os.path.relpath (new in Python v2.6): offset = len(self.root_path)+len(os.pathsep) return [path[offset:] for path in self.pythonpath]
python
def _get_relative_pythonpath(self): """Return PYTHONPATH list as relative paths""" # Workaround to replace os.path.relpath (new in Python v2.6): offset = len(self.root_path)+len(os.pathsep) return [path[offset:] for path in self.pythonpath]
[ "def", "_get_relative_pythonpath", "(", "self", ")", ":", "# Workaround to replace os.path.relpath (new in Python v2.6):\r", "offset", "=", "len", "(", "self", ".", "root_path", ")", "+", "len", "(", "os", ".", "pathsep", ")", "return", "[", "path", "[", "offset",...
Return PYTHONPATH list as relative paths
[ "Return", "PYTHONPATH", "list", "as", "relative", "paths" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/projecttypes/python.py#L23-L27
30,872
spyder-ide/spyder
spyder/plugins/projects/projecttypes/python.py
PythonProject._set_relative_pythonpath
def _set_relative_pythonpath(self, value): """Set PYTHONPATH list relative paths""" self.pythonpath = [osp.abspath(osp.join(self.root_path, path)) for path in value]
python
def _set_relative_pythonpath(self, value): """Set PYTHONPATH list relative paths""" self.pythonpath = [osp.abspath(osp.join(self.root_path, path)) for path in value]
[ "def", "_set_relative_pythonpath", "(", "self", ",", "value", ")", ":", "self", ".", "pythonpath", "=", "[", "osp", ".", "abspath", "(", "osp", ".", "join", "(", "self", ".", "root_path", ",", "path", ")", ")", "for", "path", "in", "value", "]" ]
Set PYTHONPATH list relative paths
[ "Set", "PYTHONPATH", "list", "relative", "paths" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/projecttypes/python.py#L29-L32
30,873
spyder-ide/spyder
spyder/plugins/projects/projecttypes/python.py
PythonProject.is_in_pythonpath
def is_in_pythonpath(self, dirname): """Return True if dirname is in project's PYTHONPATH""" return fixpath(dirname) in [fixpath(_p) for _p in self.pythonpath]
python
def is_in_pythonpath(self, dirname): """Return True if dirname is in project's PYTHONPATH""" return fixpath(dirname) in [fixpath(_p) for _p in self.pythonpath]
[ "def", "is_in_pythonpath", "(", "self", ",", "dirname", ")", ":", "return", "fixpath", "(", "dirname", ")", "in", "[", "fixpath", "(", "_p", ")", "for", "_p", "in", "self", ".", "pythonpath", "]" ]
Return True if dirname is in project's PYTHONPATH
[ "Return", "True", "if", "dirname", "is", "in", "project", "s", "PYTHONPATH" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/projecttypes/python.py#L38-L40
30,874
spyder-ide/spyder
spyder/plugins/projects/projecttypes/python.py
PythonProject.remove_from_pythonpath
def remove_from_pythonpath(self, path): """Remove path from project's PYTHONPATH Return True if path was removed, False if it was not found""" pathlist = self.get_pythonpath() if path in pathlist: pathlist.pop(pathlist.index(path)) self.set_pythonpath(pathlist) return True else: return False
python
def remove_from_pythonpath(self, path): """Remove path from project's PYTHONPATH Return True if path was removed, False if it was not found""" pathlist = self.get_pythonpath() if path in pathlist: pathlist.pop(pathlist.index(path)) self.set_pythonpath(pathlist) return True else: return False
[ "def", "remove_from_pythonpath", "(", "self", ",", "path", ")", ":", "pathlist", "=", "self", ".", "get_pythonpath", "(", ")", "if", "path", "in", "pathlist", ":", "pathlist", ".", "pop", "(", "pathlist", ".", "index", "(", "path", ")", ")", "self", "....
Remove path from project's PYTHONPATH Return True if path was removed, False if it was not found
[ "Remove", "path", "from", "project", "s", "PYTHONPATH", "Return", "True", "if", "path", "was", "removed", "False", "if", "it", "was", "not", "found" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/projecttypes/python.py#L51-L60
30,875
spyder-ide/spyder
spyder/plugins/projects/projecttypes/python.py
PythonProject.add_to_pythonpath
def add_to_pythonpath(self, path): """Add path to project's PYTHONPATH Return True if path was added, False if it was already there""" pathlist = self.get_pythonpath() if path in pathlist: return False else: pathlist.insert(0, path) self.set_pythonpath(pathlist) return True
python
def add_to_pythonpath(self, path): """Add path to project's PYTHONPATH Return True if path was added, False if it was already there""" pathlist = self.get_pythonpath() if path in pathlist: return False else: pathlist.insert(0, path) self.set_pythonpath(pathlist) return True
[ "def", "add_to_pythonpath", "(", "self", ",", "path", ")", ":", "pathlist", "=", "self", ".", "get_pythonpath", "(", ")", "if", "path", "in", "pathlist", ":", "return", "False", "else", ":", "pathlist", ".", "insert", "(", "0", ",", "path", ")", "self"...
Add path to project's PYTHONPATH Return True if path was added, False if it was already there
[ "Add", "path", "to", "project", "s", "PYTHONPATH", "Return", "True", "if", "path", "was", "added", "False", "if", "it", "was", "already", "there" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/projecttypes/python.py#L62-L71
30,876
spyder-ide/spyder
spyder/app/mainwindow.py
set_opengl_implementation
def set_opengl_implementation(option): """ Set the OpenGL implementation used by Spyder. See issue 7447 for the details. """ if option == 'software': QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL) if QQuickWindow is not None: QQuickWindow.setSceneGraphBackend(QSGRendererInterface.Software) elif option == 'desktop': QCoreApplication.setAttribute(Qt.AA_UseDesktopOpenGL) if QQuickWindow is not None: QQuickWindow.setSceneGraphBackend(QSGRendererInterface.OpenGL) elif option == 'gles': QCoreApplication.setAttribute(Qt.AA_UseOpenGLES) if QQuickWindow is not None: QQuickWindow.setSceneGraphBackend(QSGRendererInterface.OpenGL)
python
def set_opengl_implementation(option): """ Set the OpenGL implementation used by Spyder. See issue 7447 for the details. """ if option == 'software': QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL) if QQuickWindow is not None: QQuickWindow.setSceneGraphBackend(QSGRendererInterface.Software) elif option == 'desktop': QCoreApplication.setAttribute(Qt.AA_UseDesktopOpenGL) if QQuickWindow is not None: QQuickWindow.setSceneGraphBackend(QSGRendererInterface.OpenGL) elif option == 'gles': QCoreApplication.setAttribute(Qt.AA_UseOpenGLES) if QQuickWindow is not None: QQuickWindow.setSceneGraphBackend(QSGRendererInterface.OpenGL)
[ "def", "set_opengl_implementation", "(", "option", ")", ":", "if", "option", "==", "'software'", ":", "QCoreApplication", ".", "setAttribute", "(", "Qt", ".", "AA_UseSoftwareOpenGL", ")", "if", "QQuickWindow", "is", "not", "None", ":", "QQuickWindow", ".", "setS...
Set the OpenGL implementation used by Spyder. See issue 7447 for the details.
[ "Set", "the", "OpenGL", "implementation", "used", "by", "Spyder", ".", "See", "issue", "7447", "for", "the", "details", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L213-L230
30,877
spyder-ide/spyder
spyder/app/mainwindow.py
setup_logging
def setup_logging(cli_options): """Setup logging with cli options defined by the user.""" if cli_options.debug_info or get_debug_level() > 0: levels = {2: logging.INFO, 3: logging.DEBUG} log_level = levels[get_debug_level()] log_format = '%(asctime)s [%(levelname)s] [%(name)s] -> %(message)s' if cli_options.debug_output == 'file': log_file = 'spyder-debug.log' else: log_file = None logging.basicConfig(level=log_level, format=log_format, filename=log_file, filemode='w+')
python
def setup_logging(cli_options): """Setup logging with cli options defined by the user.""" if cli_options.debug_info or get_debug_level() > 0: levels = {2: logging.INFO, 3: logging.DEBUG} log_level = levels[get_debug_level()] log_format = '%(asctime)s [%(levelname)s] [%(name)s] -> %(message)s' if cli_options.debug_output == 'file': log_file = 'spyder-debug.log' else: log_file = None logging.basicConfig(level=log_level, format=log_format, filename=log_file, filemode='w+')
[ "def", "setup_logging", "(", "cli_options", ")", ":", "if", "cli_options", ".", "debug_info", "or", "get_debug_level", "(", ")", ">", "0", ":", "levels", "=", "{", "2", ":", "logging", ".", "INFO", ",", "3", ":", "logging", ".", "DEBUG", "}", "log_leve...
Setup logging with cli options defined by the user.
[ "Setup", "logging", "with", "cli", "options", "defined", "by", "the", "user", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L233-L248
30,878
spyder-ide/spyder
spyder/app/mainwindow.py
qt_message_handler
def qt_message_handler(msg_type, msg_log_context, msg_string): """ Qt warning messages are intercepted by this handler. On some operating systems, warning messages might be displayed even if the actual message does not apply. This filter adds a blacklist for messages that are being printed for no apparent reason. Anything else will get printed in the internal console. In DEV mode, all messages are printed. """ BLACKLIST = [ 'QMainWidget::resizeDocks: all sizes need to be larger than 0', ] if DEV or msg_string not in BLACKLIST: print(msg_string)
python
def qt_message_handler(msg_type, msg_log_context, msg_string): """ Qt warning messages are intercepted by this handler. On some operating systems, warning messages might be displayed even if the actual message does not apply. This filter adds a blacklist for messages that are being printed for no apparent reason. Anything else will get printed in the internal console. In DEV mode, all messages are printed. """ BLACKLIST = [ 'QMainWidget::resizeDocks: all sizes need to be larger than 0', ] if DEV or msg_string not in BLACKLIST: print(msg_string)
[ "def", "qt_message_handler", "(", "msg_type", ",", "msg_log_context", ",", "msg_string", ")", ":", "BLACKLIST", "=", "[", "'QMainWidget::resizeDocks: all sizes need to be larger than 0'", ",", "]", "if", "DEV", "or", "msg_string", "not", "in", "BLACKLIST", ":", "print...
Qt warning messages are intercepted by this handler. On some operating systems, warning messages might be displayed even if the actual message does not apply. This filter adds a blacklist for messages that are being printed for no apparent reason. Anything else will get printed in the internal console. In DEV mode, all messages are printed.
[ "Qt", "warning", "messages", "are", "intercepted", "by", "this", "handler", ".", "On", "some", "operating", "systems", "warning", "messages", "might", "be", "displayed", "even", "if", "the", "actual", "message", "does", "not", "apply", ".", "This", "filter", ...
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L251-L266
30,879
spyder-ide/spyder
spyder/app/mainwindow.py
initialize
def initialize(): """Initialize Qt, patching sys.exit and eventually setting up ETS""" # This doesn't create our QApplication, just holds a reference to # MAIN_APP, created above to show our splash screen as early as # possible app = qapplication() # --- Set application icon app.setWindowIcon(APP_ICON) #----Monkey patching QApplication class FakeQApplication(QApplication): """Spyder's fake QApplication""" def __init__(self, args): self = app # analysis:ignore @staticmethod def exec_(): """Do nothing because the Qt mainloop is already running""" pass from qtpy import QtWidgets QtWidgets.QApplication = FakeQApplication # ----Monkey patching sys.exit def fake_sys_exit(arg=[]): pass sys.exit = fake_sys_exit # ----Monkey patching sys.excepthook to avoid crashes in PyQt 5.5+ if PYQT5: def spy_excepthook(type_, value, tback): sys.__excepthook__(type_, value, tback) sys.excepthook = spy_excepthook # Removing arguments from sys.argv as in standard Python interpreter sys.argv = [''] # Selecting Qt4 backend for Enthought Tool Suite (if installed) try: from enthought.etsconfig.api import ETSConfig ETSConfig.toolkit = 'qt4' except ImportError: pass return app
python
def initialize(): """Initialize Qt, patching sys.exit and eventually setting up ETS""" # This doesn't create our QApplication, just holds a reference to # MAIN_APP, created above to show our splash screen as early as # possible app = qapplication() # --- Set application icon app.setWindowIcon(APP_ICON) #----Monkey patching QApplication class FakeQApplication(QApplication): """Spyder's fake QApplication""" def __init__(self, args): self = app # analysis:ignore @staticmethod def exec_(): """Do nothing because the Qt mainloop is already running""" pass from qtpy import QtWidgets QtWidgets.QApplication = FakeQApplication # ----Monkey patching sys.exit def fake_sys_exit(arg=[]): pass sys.exit = fake_sys_exit # ----Monkey patching sys.excepthook to avoid crashes in PyQt 5.5+ if PYQT5: def spy_excepthook(type_, value, tback): sys.__excepthook__(type_, value, tback) sys.excepthook = spy_excepthook # Removing arguments from sys.argv as in standard Python interpreter sys.argv = [''] # Selecting Qt4 backend for Enthought Tool Suite (if installed) try: from enthought.etsconfig.api import ETSConfig ETSConfig.toolkit = 'qt4' except ImportError: pass return app
[ "def", "initialize", "(", ")", ":", "# This doesn't create our QApplication, just holds a reference to\r", "# MAIN_APP, created above to show our splash screen as early as\r", "# possible\r", "app", "=", "qapplication", "(", ")", "# --- Set application icon\r", "app", ".", "setWindow...
Initialize Qt, patching sys.exit and eventually setting up ETS
[ "Initialize", "Qt", "patching", "sys", ".", "exit", "and", "eventually", "setting", "up", "ETS" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L3210-L3253
30,880
spyder-ide/spyder
spyder/app/mainwindow.py
run_spyder
def run_spyder(app, options, args): """ Create and show Spyder's main window Start QApplication event loop """ #TODO: insert here # Main window main = MainWindow(options) try: main.setup() except BaseException: if main.console is not None: try: main.console.shell.exit_interpreter() except BaseException: pass raise main.show() main.post_visible_setup() if main.console: main.console.shell.interpreter.namespace['spy'] = \ Spy(app=app, window=main) # Open external files passed as args if args: for a in args: main.open_external_file(a) # Don't show icons in menus for Mac if sys.platform == 'darwin': QCoreApplication.setAttribute(Qt.AA_DontShowIconsInMenus, True) # Open external files with our Mac app if running_in_mac_app(): app.sig_open_external_file.connect(main.open_external_file) # To give focus again to the last focused widget after restoring # the window app.focusChanged.connect(main.change_last_focused_widget) if not running_under_pytest(): app.exec_() return main
python
def run_spyder(app, options, args): """ Create and show Spyder's main window Start QApplication event loop """ #TODO: insert here # Main window main = MainWindow(options) try: main.setup() except BaseException: if main.console is not None: try: main.console.shell.exit_interpreter() except BaseException: pass raise main.show() main.post_visible_setup() if main.console: main.console.shell.interpreter.namespace['spy'] = \ Spy(app=app, window=main) # Open external files passed as args if args: for a in args: main.open_external_file(a) # Don't show icons in menus for Mac if sys.platform == 'darwin': QCoreApplication.setAttribute(Qt.AA_DontShowIconsInMenus, True) # Open external files with our Mac app if running_in_mac_app(): app.sig_open_external_file.connect(main.open_external_file) # To give focus again to the last focused widget after restoring # the window app.focusChanged.connect(main.change_last_focused_widget) if not running_under_pytest(): app.exec_() return main
[ "def", "run_spyder", "(", "app", ",", "options", ",", "args", ")", ":", "#TODO: insert here\r", "# Main window\r", "main", "=", "MainWindow", "(", "options", ")", "try", ":", "main", ".", "setup", "(", ")", "except", "BaseException", ":", "if", "main", "."...
Create and show Spyder's main window Start QApplication event loop
[ "Create", "and", "show", "Spyder", "s", "main", "window", "Start", "QApplication", "event", "loop" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L3274-L3318
30,881
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.post_visible_setup
def post_visible_setup(self): """Actions to be performed only after the main window's `show` method was triggered""" self.restore_scrollbar_position.emit() # [Workaround for Issue 880] # QDockWidget objects are not painted if restored as floating # windows, so we must dock them before showing the mainwindow, # then set them again as floating windows here. for widget in self.floating_dockwidgets: widget.setFloating(True) # In MacOS X 10.7 our app is not displayed after initialized (I don't # know why because this doesn't happen when started from the terminal), # so we need to resort to this hack to make it appear. if running_in_mac_app(): idx = __file__.index(MAC_APP_NAME) app_path = __file__[:idx] subprocess.call(['open', app_path + MAC_APP_NAME]) # Server to maintain just one Spyder instance and open files in it if # the user tries to start other instances with # $ spyder foo.py if (CONF.get('main', 'single_instance') and not self.new_instance and self.open_files_server): t = threading.Thread(target=self.start_open_files_server) t.setDaemon(True) t.start() # Connect the window to the signal emmited by the previous server # when it gets a client connected to it self.sig_open_external_file.connect(self.open_external_file) # Create Plugins and toolbars submenus self.create_plugins_menu() self.create_toolbars_menu() # Update toolbar visibility status self.toolbars_visible = CONF.get('main', 'toolbars_visible') self.load_last_visible_toolbars() # Update lock status self.lock_interface_action.setChecked(self.interface_locked) # Hide Internal Console so that people don't use it instead of # the External or IPython ones if self.console.dockwidget.isVisible() and DEV is None: self.console.toggle_view_action.setChecked(False) self.console.dockwidget.hide() # Show Help and Consoles by default plugins_to_show = [self.ipyconsole] if self.help is not None: plugins_to_show.append(self.help) for plugin in plugins_to_show: if plugin.dockwidget.isVisible(): plugin.dockwidget.raise_() # Show history file if no console is visible if not self.ipyconsole.isvisible: self.historylog.add_history(get_conf_path('history.py')) if self.open_project: self.projects.open_project(self.open_project) else: # Load last project if a project was active when Spyder # was closed self.projects.reopen_last_project() # If no project is active, load last session if self.projects.get_active_project() is None: self.editor.setup_open_files() # Check for spyder updates if DEV is None and CONF.get('main', 'check_updates_on_startup'): self.give_updates_feedback = False self.check_updates(startup=True) # Show dialog with missing dependencies self.report_missing_dependencies() # Raise the menuBar to the top of the main window widget's stack # (Fixes issue 3887) self.menuBar().raise_() self.is_setting_up = False
python
def post_visible_setup(self): """Actions to be performed only after the main window's `show` method was triggered""" self.restore_scrollbar_position.emit() # [Workaround for Issue 880] # QDockWidget objects are not painted if restored as floating # windows, so we must dock them before showing the mainwindow, # then set them again as floating windows here. for widget in self.floating_dockwidgets: widget.setFloating(True) # In MacOS X 10.7 our app is not displayed after initialized (I don't # know why because this doesn't happen when started from the terminal), # so we need to resort to this hack to make it appear. if running_in_mac_app(): idx = __file__.index(MAC_APP_NAME) app_path = __file__[:idx] subprocess.call(['open', app_path + MAC_APP_NAME]) # Server to maintain just one Spyder instance and open files in it if # the user tries to start other instances with # $ spyder foo.py if (CONF.get('main', 'single_instance') and not self.new_instance and self.open_files_server): t = threading.Thread(target=self.start_open_files_server) t.setDaemon(True) t.start() # Connect the window to the signal emmited by the previous server # when it gets a client connected to it self.sig_open_external_file.connect(self.open_external_file) # Create Plugins and toolbars submenus self.create_plugins_menu() self.create_toolbars_menu() # Update toolbar visibility status self.toolbars_visible = CONF.get('main', 'toolbars_visible') self.load_last_visible_toolbars() # Update lock status self.lock_interface_action.setChecked(self.interface_locked) # Hide Internal Console so that people don't use it instead of # the External or IPython ones if self.console.dockwidget.isVisible() and DEV is None: self.console.toggle_view_action.setChecked(False) self.console.dockwidget.hide() # Show Help and Consoles by default plugins_to_show = [self.ipyconsole] if self.help is not None: plugins_to_show.append(self.help) for plugin in plugins_to_show: if plugin.dockwidget.isVisible(): plugin.dockwidget.raise_() # Show history file if no console is visible if not self.ipyconsole.isvisible: self.historylog.add_history(get_conf_path('history.py')) if self.open_project: self.projects.open_project(self.open_project) else: # Load last project if a project was active when Spyder # was closed self.projects.reopen_last_project() # If no project is active, load last session if self.projects.get_active_project() is None: self.editor.setup_open_files() # Check for spyder updates if DEV is None and CONF.get('main', 'check_updates_on_startup'): self.give_updates_feedback = False self.check_updates(startup=True) # Show dialog with missing dependencies self.report_missing_dependencies() # Raise the menuBar to the top of the main window widget's stack # (Fixes issue 3887) self.menuBar().raise_() self.is_setting_up = False
[ "def", "post_visible_setup", "(", "self", ")", ":", "self", ".", "restore_scrollbar_position", ".", "emit", "(", ")", "# [Workaround for Issue 880]\r", "# QDockWidget objects are not painted if restored as floating\r", "# windows, so we must dock them before showing the mainwindow,\r",...
Actions to be performed only after the main window's `show` method was triggered
[ "Actions", "to", "be", "performed", "only", "after", "the", "main", "window", "s", "show", "method", "was", "triggered" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L1265-L1349
30,882
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.set_window_title
def set_window_title(self): """Set window title.""" if DEV is not None: title = u"Spyder %s (Python %s.%s)" % (__version__, sys.version_info[0], sys.version_info[1]) else: title = u"Spyder (Python %s.%s)" % (sys.version_info[0], sys.version_info[1]) if get_debug_level(): title += u" [DEBUG MODE %d]" % get_debug_level() if self.window_title is not None: title += u' -- ' + to_text_string(self.window_title) if self.projects is not None: path = self.projects.get_active_project_path() if path: path = path.replace(get_home_dir(), u'~') title = u'{0} - {1}'.format(path, title) self.base_title = title self.setWindowTitle(self.base_title)
python
def set_window_title(self): """Set window title.""" if DEV is not None: title = u"Spyder %s (Python %s.%s)" % (__version__, sys.version_info[0], sys.version_info[1]) else: title = u"Spyder (Python %s.%s)" % (sys.version_info[0], sys.version_info[1]) if get_debug_level(): title += u" [DEBUG MODE %d]" % get_debug_level() if self.window_title is not None: title += u' -- ' + to_text_string(self.window_title) if self.projects is not None: path = self.projects.get_active_project_path() if path: path = path.replace(get_home_dir(), u'~') title = u'{0} - {1}'.format(path, title) self.base_title = title self.setWindowTitle(self.base_title)
[ "def", "set_window_title", "(", "self", ")", ":", "if", "DEV", "is", "not", "None", ":", "title", "=", "u\"Spyder %s (Python %s.%s)\"", "%", "(", "__version__", ",", "sys", ".", "version_info", "[", "0", "]", ",", "sys", ".", "version_info", "[", "1", "]...
Set window title.
[ "Set", "window", "title", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L1351-L1374
30,883
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.report_missing_dependencies
def report_missing_dependencies(self): """Show a QMessageBox with a list of missing hard dependencies""" missing_deps = dependencies.missing_dependencies() if missing_deps: QMessageBox.critical(self, _('Error'), _("<b>You have missing dependencies!</b>" "<br><br><tt>%s</tt><br><br>" "<b>Please install them to avoid this message.</b>" "<br><br>" "<i>Note</i>: Spyder could work without some of these " "dependencies, however to have a smooth experience when " "using Spyder we <i>strongly</i> recommend you to install " "all the listed missing dependencies.<br><br>" "Failing to install these dependencies might result in bugs. " "Please be sure that any found bugs are not the direct " "result of missing dependencies, prior to reporting a new " "issue." ) % missing_deps, QMessageBox.Ok)
python
def report_missing_dependencies(self): """Show a QMessageBox with a list of missing hard dependencies""" missing_deps = dependencies.missing_dependencies() if missing_deps: QMessageBox.critical(self, _('Error'), _("<b>You have missing dependencies!</b>" "<br><br><tt>%s</tt><br><br>" "<b>Please install them to avoid this message.</b>" "<br><br>" "<i>Note</i>: Spyder could work without some of these " "dependencies, however to have a smooth experience when " "using Spyder we <i>strongly</i> recommend you to install " "all the listed missing dependencies.<br><br>" "Failing to install these dependencies might result in bugs. " "Please be sure that any found bugs are not the direct " "result of missing dependencies, prior to reporting a new " "issue." ) % missing_deps, QMessageBox.Ok)
[ "def", "report_missing_dependencies", "(", "self", ")", ":", "missing_deps", "=", "dependencies", ".", "missing_dependencies", "(", ")", "if", "missing_deps", ":", "QMessageBox", ".", "critical", "(", "self", ",", "_", "(", "'Error'", ")", ",", "_", "(", "\"...
Show a QMessageBox with a list of missing hard dependencies
[ "Show", "a", "QMessageBox", "with", "a", "list", "of", "missing", "hard", "dependencies" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L1376-L1393
30,884
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.get_window_settings
def get_window_settings(self): """Return current window settings Symetric to the 'set_window_settings' setter""" window_size = (self.window_size.width(), self.window_size.height()) is_fullscreen = self.isFullScreen() if is_fullscreen: is_maximized = self.maximized_flag else: is_maximized = self.isMaximized() pos = (self.window_position.x(), self.window_position.y()) prefs_dialog_size = (self.prefs_dialog_size.width(), self.prefs_dialog_size.height()) hexstate = qbytearray_to_str(self.saveState()) return (hexstate, window_size, prefs_dialog_size, pos, is_maximized, is_fullscreen)
python
def get_window_settings(self): """Return current window settings Symetric to the 'set_window_settings' setter""" window_size = (self.window_size.width(), self.window_size.height()) is_fullscreen = self.isFullScreen() if is_fullscreen: is_maximized = self.maximized_flag else: is_maximized = self.isMaximized() pos = (self.window_position.x(), self.window_position.y()) prefs_dialog_size = (self.prefs_dialog_size.width(), self.prefs_dialog_size.height()) hexstate = qbytearray_to_str(self.saveState()) return (hexstate, window_size, prefs_dialog_size, pos, is_maximized, is_fullscreen)
[ "def", "get_window_settings", "(", "self", ")", ":", "window_size", "=", "(", "self", ".", "window_size", ".", "width", "(", ")", ",", "self", ".", "window_size", ".", "height", "(", ")", ")", "is_fullscreen", "=", "self", ".", "isFullScreen", "(", ")", ...
Return current window settings Symetric to the 'set_window_settings' setter
[ "Return", "current", "window", "settings", "Symetric", "to", "the", "set_window_settings", "setter" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L1423-L1437
30,885
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.set_window_settings
def set_window_settings(self, hexstate, window_size, prefs_dialog_size, pos, is_maximized, is_fullscreen): """Set window settings Symetric to the 'get_window_settings' accessor""" self.setUpdatesEnabled(False) self.window_size = QSize(window_size[0], window_size[1]) # width,height self.prefs_dialog_size = QSize(prefs_dialog_size[0], prefs_dialog_size[1]) # width,height self.window_position = QPoint(pos[0], pos[1]) # x,y self.setWindowState(Qt.WindowNoState) self.resize(self.window_size) self.move(self.window_position) # Window layout if hexstate: self.restoreState( QByteArray().fromHex( str(hexstate).encode('utf-8')) ) # [Workaround for Issue 880] # QDockWidget objects are not painted if restored as floating # windows, so we must dock them before showing the mainwindow. for widget in self.children(): if isinstance(widget, QDockWidget) and widget.isFloating(): self.floating_dockwidgets.append(widget) widget.setFloating(False) # Is fullscreen? if is_fullscreen: self.setWindowState(Qt.WindowFullScreen) self.__update_fullscreen_action() # Is maximized? if is_fullscreen: self.maximized_flag = is_maximized elif is_maximized: self.setWindowState(Qt.WindowMaximized) self.setUpdatesEnabled(True)
python
def set_window_settings(self, hexstate, window_size, prefs_dialog_size, pos, is_maximized, is_fullscreen): """Set window settings Symetric to the 'get_window_settings' accessor""" self.setUpdatesEnabled(False) self.window_size = QSize(window_size[0], window_size[1]) # width,height self.prefs_dialog_size = QSize(prefs_dialog_size[0], prefs_dialog_size[1]) # width,height self.window_position = QPoint(pos[0], pos[1]) # x,y self.setWindowState(Qt.WindowNoState) self.resize(self.window_size) self.move(self.window_position) # Window layout if hexstate: self.restoreState( QByteArray().fromHex( str(hexstate).encode('utf-8')) ) # [Workaround for Issue 880] # QDockWidget objects are not painted if restored as floating # windows, so we must dock them before showing the mainwindow. for widget in self.children(): if isinstance(widget, QDockWidget) and widget.isFloating(): self.floating_dockwidgets.append(widget) widget.setFloating(False) # Is fullscreen? if is_fullscreen: self.setWindowState(Qt.WindowFullScreen) self.__update_fullscreen_action() # Is maximized? if is_fullscreen: self.maximized_flag = is_maximized elif is_maximized: self.setWindowState(Qt.WindowMaximized) self.setUpdatesEnabled(True)
[ "def", "set_window_settings", "(", "self", ",", "hexstate", ",", "window_size", ",", "prefs_dialog_size", ",", "pos", ",", "is_maximized", ",", "is_fullscreen", ")", ":", "self", ".", "setUpdatesEnabled", "(", "False", ")", "self", ".", "window_size", "=", "QS...
Set window settings Symetric to the 'get_window_settings' accessor
[ "Set", "window", "settings", "Symetric", "to", "the", "get_window_settings", "accessor" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L1439-L1474
30,886
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.tabify_plugins
def tabify_plugins(self, first, second): """Tabify plugin dockwigdets""" self.tabifyDockWidget(first.dockwidget, second.dockwidget)
python
def tabify_plugins(self, first, second): """Tabify plugin dockwigdets""" self.tabifyDockWidget(first.dockwidget, second.dockwidget)
[ "def", "tabify_plugins", "(", "self", ",", "first", ",", "second", ")", ":", "self", ".", "tabifyDockWidget", "(", "first", ".", "dockwidget", ",", "second", ".", "dockwidget", ")" ]
Tabify plugin dockwigdets
[ "Tabify", "plugin", "dockwigdets" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L1499-L1501
30,887
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.setup_layout
def setup_layout(self, default=False): """Setup window layout""" prefix = 'window' + '/' settings = self.load_window_settings(prefix, default) hexstate = settings[0] self.first_spyder_run = False if hexstate is None: # First Spyder execution: self.setWindowState(Qt.WindowMaximized) self.first_spyder_run = True self.setup_default_layouts('default', settings) # Now that the initial setup is done, copy the window settings, # except for the hexstate in the quick layouts sections for the # default layouts. # Order and name of the default layouts is found in config.py section = 'quick_layouts' get_func = CONF.get_default if default else CONF.get order = get_func(section, 'order') # restore the original defaults if reset layouts is called if default: CONF.set(section, 'active', order) CONF.set(section, 'order', order) CONF.set(section, 'names', order) for index, name, in enumerate(order): prefix = 'layout_{0}/'.format(index) self.save_current_window_settings(prefix, section, none_state=True) # store the initial layout as the default in spyder prefix = 'layout_default/' section = 'quick_layouts' self.save_current_window_settings(prefix, section, none_state=True) self.current_quick_layout = 'default' # Regenerate menu self.quick_layout_set_menu() self.set_window_settings(*settings) for plugin in (self.widgetlist + self.thirdparty_plugins): try: plugin.initialize_plugin_in_mainwindow_layout() except Exception as error: print("%s: %s" % (plugin, str(error)), file=STDERR) traceback.print_exc(file=STDERR)
python
def setup_layout(self, default=False): """Setup window layout""" prefix = 'window' + '/' settings = self.load_window_settings(prefix, default) hexstate = settings[0] self.first_spyder_run = False if hexstate is None: # First Spyder execution: self.setWindowState(Qt.WindowMaximized) self.first_spyder_run = True self.setup_default_layouts('default', settings) # Now that the initial setup is done, copy the window settings, # except for the hexstate in the quick layouts sections for the # default layouts. # Order and name of the default layouts is found in config.py section = 'quick_layouts' get_func = CONF.get_default if default else CONF.get order = get_func(section, 'order') # restore the original defaults if reset layouts is called if default: CONF.set(section, 'active', order) CONF.set(section, 'order', order) CONF.set(section, 'names', order) for index, name, in enumerate(order): prefix = 'layout_{0}/'.format(index) self.save_current_window_settings(prefix, section, none_state=True) # store the initial layout as the default in spyder prefix = 'layout_default/' section = 'quick_layouts' self.save_current_window_settings(prefix, section, none_state=True) self.current_quick_layout = 'default' # Regenerate menu self.quick_layout_set_menu() self.set_window_settings(*settings) for plugin in (self.widgetlist + self.thirdparty_plugins): try: plugin.initialize_plugin_in_mainwindow_layout() except Exception as error: print("%s: %s" % (plugin, str(error)), file=STDERR) traceback.print_exc(file=STDERR)
[ "def", "setup_layout", "(", "self", ",", "default", "=", "False", ")", ":", "prefix", "=", "'window'", "+", "'/'", "settings", "=", "self", ".", "load_window_settings", "(", "prefix", ",", "default", ")", "hexstate", "=", "settings", "[", "0", "]", "self...
Setup window layout
[ "Setup", "window", "layout" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L1504-L1551
30,888
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.reset_window_layout
def reset_window_layout(self): """Reset window layout to default""" answer = QMessageBox.warning(self, _("Warning"), _("Window layout will be reset to default settings: " "this affects window position, size and dockwidgets.\n" "Do you want to continue?"), QMessageBox.Yes | QMessageBox.No) if answer == QMessageBox.Yes: self.setup_layout(default=True)
python
def reset_window_layout(self): """Reset window layout to default""" answer = QMessageBox.warning(self, _("Warning"), _("Window layout will be reset to default settings: " "this affects window position, size and dockwidgets.\n" "Do you want to continue?"), QMessageBox.Yes | QMessageBox.No) if answer == QMessageBox.Yes: self.setup_layout(default=True)
[ "def", "reset_window_layout", "(", "self", ")", ":", "answer", "=", "QMessageBox", ".", "warning", "(", "self", ",", "_", "(", "\"Warning\"", ")", ",", "_", "(", "\"Window layout will be reset to default settings: \"", "\"this affects window position, size and dockwidgets...
Reset window layout to default
[ "Reset", "window", "layout", "to", "default" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L1903-L1911
30,889
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.quick_layout_save
def quick_layout_save(self): """Save layout dialog""" get = CONF.get set_ = CONF.set names = get('quick_layouts', 'names') order = get('quick_layouts', 'order') active = get('quick_layouts', 'active') dlg = self.dialog_layout_save(self, names) if dlg.exec_(): name = dlg.combo_box.currentText() if name in names: answer = QMessageBox.warning(self, _("Warning"), _("Layout <b>%s</b> will be \ overwritten. Do you want to \ continue?") % name, QMessageBox.Yes | QMessageBox.No) index = order.index(name) else: answer = True if None in names: index = names.index(None) names[index] = name else: index = len(names) names.append(name) order.append(name) # Always make active a new layout even if it overwrites an inactive # layout if name not in active: active.append(name) if answer: self.save_current_window_settings('layout_{}/'.format(index), section='quick_layouts') set_('quick_layouts', 'names', names) set_('quick_layouts', 'order', order) set_('quick_layouts', 'active', active) self.quick_layout_set_menu()
python
def quick_layout_save(self): """Save layout dialog""" get = CONF.get set_ = CONF.set names = get('quick_layouts', 'names') order = get('quick_layouts', 'order') active = get('quick_layouts', 'active') dlg = self.dialog_layout_save(self, names) if dlg.exec_(): name = dlg.combo_box.currentText() if name in names: answer = QMessageBox.warning(self, _("Warning"), _("Layout <b>%s</b> will be \ overwritten. Do you want to \ continue?") % name, QMessageBox.Yes | QMessageBox.No) index = order.index(name) else: answer = True if None in names: index = names.index(None) names[index] = name else: index = len(names) names.append(name) order.append(name) # Always make active a new layout even if it overwrites an inactive # layout if name not in active: active.append(name) if answer: self.save_current_window_settings('layout_{}/'.format(index), section='quick_layouts') set_('quick_layouts', 'names', names) set_('quick_layouts', 'order', order) set_('quick_layouts', 'active', active) self.quick_layout_set_menu()
[ "def", "quick_layout_save", "(", "self", ")", ":", "get", "=", "CONF", ".", "get", "set_", "=", "CONF", ".", "set", "names", "=", "get", "(", "'quick_layouts'", ",", "'names'", ")", "order", "=", "get", "(", "'quick_layouts'", ",", "'order'", ")", "act...
Save layout dialog
[ "Save", "layout", "dialog" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L1913-L1954
30,890
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.quick_layout_settings
def quick_layout_settings(self): """Layout settings dialog""" get = CONF.get set_ = CONF.set section = 'quick_layouts' names = get(section, 'names') order = get(section, 'order') active = get(section, 'active') dlg = self.dialog_layout_settings(self, names, order, active) if dlg.exec_(): set_(section, 'names', dlg.names) set_(section, 'order', dlg.order) set_(section, 'active', dlg.active) self.quick_layout_set_menu()
python
def quick_layout_settings(self): """Layout settings dialog""" get = CONF.get set_ = CONF.set section = 'quick_layouts' names = get(section, 'names') order = get(section, 'order') active = get(section, 'active') dlg = self.dialog_layout_settings(self, names, order, active) if dlg.exec_(): set_(section, 'names', dlg.names) set_(section, 'order', dlg.order) set_(section, 'active', dlg.active) self.quick_layout_set_menu()
[ "def", "quick_layout_settings", "(", "self", ")", ":", "get", "=", "CONF", ".", "get", "set_", "=", "CONF", ".", "set", "section", "=", "'quick_layouts'", "names", "=", "get", "(", "section", ",", "'names'", ")", "order", "=", "get", "(", "section", ",...
Layout settings dialog
[ "Layout", "settings", "dialog" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L1956-L1972
30,891
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow._update_show_toolbars_action
def _update_show_toolbars_action(self): """Update the text displayed in the menu entry.""" if self.toolbars_visible: text = _("Hide toolbars") tip = _("Hide toolbars") else: text = _("Show toolbars") tip = _("Show toolbars") self.show_toolbars_action.setText(text) self.show_toolbars_action.setToolTip(tip)
python
def _update_show_toolbars_action(self): """Update the text displayed in the menu entry.""" if self.toolbars_visible: text = _("Hide toolbars") tip = _("Hide toolbars") else: text = _("Show toolbars") tip = _("Show toolbars") self.show_toolbars_action.setText(text) self.show_toolbars_action.setToolTip(tip)
[ "def", "_update_show_toolbars_action", "(", "self", ")", ":", "if", "self", ".", "toolbars_visible", ":", "text", "=", "_", "(", "\"Hide toolbars\"", ")", "tip", "=", "_", "(", "\"Hide toolbars\"", ")", "else", ":", "text", "=", "_", "(", "\"Show toolbars\""...
Update the text displayed in the menu entry.
[ "Update", "the", "text", "displayed", "in", "the", "menu", "entry", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2017-L2026
30,892
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.save_visible_toolbars
def save_visible_toolbars(self): """Saves the name of the visible toolbars in the .ini file.""" toolbars = [] for toolbar in self.visible_toolbars: toolbars.append(toolbar.objectName()) CONF.set('main', 'last_visible_toolbars', toolbars)
python
def save_visible_toolbars(self): """Saves the name of the visible toolbars in the .ini file.""" toolbars = [] for toolbar in self.visible_toolbars: toolbars.append(toolbar.objectName()) CONF.set('main', 'last_visible_toolbars', toolbars)
[ "def", "save_visible_toolbars", "(", "self", ")", ":", "toolbars", "=", "[", "]", "for", "toolbar", "in", "self", ".", "visible_toolbars", ":", "toolbars", ".", "append", "(", "toolbar", ".", "objectName", "(", ")", ")", "CONF", ".", "set", "(", "'main'"...
Saves the name of the visible toolbars in the .ini file.
[ "Saves", "the", "name", "of", "the", "visible", "toolbars", "in", "the", ".", "ini", "file", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2028-L2033
30,893
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.get_visible_toolbars
def get_visible_toolbars(self): """Collects the visible toolbars.""" toolbars = [] for toolbar in self.toolbarslist: if toolbar.toggleViewAction().isChecked(): toolbars.append(toolbar) self.visible_toolbars = toolbars
python
def get_visible_toolbars(self): """Collects the visible toolbars.""" toolbars = [] for toolbar in self.toolbarslist: if toolbar.toggleViewAction().isChecked(): toolbars.append(toolbar) self.visible_toolbars = toolbars
[ "def", "get_visible_toolbars", "(", "self", ")", ":", "toolbars", "=", "[", "]", "for", "toolbar", "in", "self", ".", "toolbarslist", ":", "if", "toolbar", ".", "toggleViewAction", "(", ")", ".", "isChecked", "(", ")", ":", "toolbars", ".", "append", "("...
Collects the visible toolbars.
[ "Collects", "the", "visible", "toolbars", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2035-L2041
30,894
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.valid_project
def valid_project(self): """Handle an invalid active project.""" try: path = self.projects.get_active_project_path() except AttributeError: return if bool(path): if not self.projects.is_valid_project(path): if path: QMessageBox.critical( self, _('Error'), _("<b>{}</b> is no longer a valid Spyder project! " "Since it is the current active project, it will " "be closed automatically.").format(path)) self.projects.close_project()
python
def valid_project(self): """Handle an invalid active project.""" try: path = self.projects.get_active_project_path() except AttributeError: return if bool(path): if not self.projects.is_valid_project(path): if path: QMessageBox.critical( self, _('Error'), _("<b>{}</b> is no longer a valid Spyder project! " "Since it is the current active project, it will " "be closed automatically.").format(path)) self.projects.close_project()
[ "def", "valid_project", "(", "self", ")", ":", "try", ":", "path", "=", "self", ".", "projects", ".", "get_active_project_path", "(", ")", "except", "AttributeError", ":", "return", "if", "bool", "(", "path", ")", ":", "if", "not", "self", ".", "projects...
Handle an invalid active project.
[ "Handle", "an", "invalid", "active", "project", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2086-L2102
30,895
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.show_shortcuts
def show_shortcuts(self, menu): """Show action shortcuts in menu""" for element in getattr(self, menu + '_menu_actions'): if element and isinstance(element, QAction): if element._shown_shortcut is not None: element.setShortcut(element._shown_shortcut)
python
def show_shortcuts(self, menu): """Show action shortcuts in menu""" for element in getattr(self, menu + '_menu_actions'): if element and isinstance(element, QAction): if element._shown_shortcut is not None: element.setShortcut(element._shown_shortcut)
[ "def", "show_shortcuts", "(", "self", ",", "menu", ")", ":", "for", "element", "in", "getattr", "(", "self", ",", "menu", "+", "'_menu_actions'", ")", ":", "if", "element", "and", "isinstance", "(", "element", ",", "QAction", ")", ":", "if", "element", ...
Show action shortcuts in menu
[ "Show", "action", "shortcuts", "in", "menu" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2113-L2118
30,896
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.hide_shortcuts
def hide_shortcuts(self, menu): """Hide action shortcuts in menu""" for element in getattr(self, menu + '_menu_actions'): if element and isinstance(element, QAction): if element._shown_shortcut is not None: element.setShortcut(QKeySequence())
python
def hide_shortcuts(self, menu): """Hide action shortcuts in menu""" for element in getattr(self, menu + '_menu_actions'): if element and isinstance(element, QAction): if element._shown_shortcut is not None: element.setShortcut(QKeySequence())
[ "def", "hide_shortcuts", "(", "self", ",", "menu", ")", ":", "for", "element", "in", "getattr", "(", "self", ",", "menu", "+", "'_menu_actions'", ")", ":", "if", "element", "and", "isinstance", "(", "element", ",", "QAction", ")", ":", "if", "element", ...
Hide action shortcuts in menu
[ "Hide", "action", "shortcuts", "in", "menu" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2120-L2125
30,897
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.update_edit_menu
def update_edit_menu(self): """Update edit menu""" widget, textedit_properties = self.get_focus_widget_properties() if textedit_properties is None: # widget is not an editor/console return # !!! Below this line, widget is expected to be a QPlainTextEdit # instance console, not_readonly, readwrite_editor = textedit_properties # Editor has focus and there is no file opened in it if not console and not_readonly and not self.editor.is_file_opened(): return # Disabling all actions to begin with for child in self.edit_menu.actions(): child.setEnabled(False) self.selectall_action.setEnabled(True) # Undo, redo self.undo_action.setEnabled( readwrite_editor \ and widget.document().isUndoAvailable() ) self.redo_action.setEnabled( readwrite_editor \ and widget.document().isRedoAvailable() ) # Copy, cut, paste, delete has_selection = widget.has_selected_text() self.copy_action.setEnabled(has_selection) self.cut_action.setEnabled(has_selection and not_readonly) self.paste_action.setEnabled(not_readonly) # Comment, uncomment, indent, unindent... if not console and not_readonly: # This is the editor and current file is writable for action in self.editor.edit_menu_actions: action.setEnabled(True)
python
def update_edit_menu(self): """Update edit menu""" widget, textedit_properties = self.get_focus_widget_properties() if textedit_properties is None: # widget is not an editor/console return # !!! Below this line, widget is expected to be a QPlainTextEdit # instance console, not_readonly, readwrite_editor = textedit_properties # Editor has focus and there is no file opened in it if not console and not_readonly and not self.editor.is_file_opened(): return # Disabling all actions to begin with for child in self.edit_menu.actions(): child.setEnabled(False) self.selectall_action.setEnabled(True) # Undo, redo self.undo_action.setEnabled( readwrite_editor \ and widget.document().isUndoAvailable() ) self.redo_action.setEnabled( readwrite_editor \ and widget.document().isRedoAvailable() ) # Copy, cut, paste, delete has_selection = widget.has_selected_text() self.copy_action.setEnabled(has_selection) self.cut_action.setEnabled(has_selection and not_readonly) self.paste_action.setEnabled(not_readonly) # Comment, uncomment, indent, unindent... if not console and not_readonly: # This is the editor and current file is writable for action in self.editor.edit_menu_actions: action.setEnabled(True)
[ "def", "update_edit_menu", "(", "self", ")", ":", "widget", ",", "textedit_properties", "=", "self", ".", "get_focus_widget_properties", "(", ")", "if", "textedit_properties", "is", "None", ":", "# widget is not an editor/console\r", "return", "# !!! Below this line, widg...
Update edit menu
[ "Update", "edit", "menu" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2143-L2178
30,898
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.update_search_menu
def update_search_menu(self): """Update search menu""" # Disabling all actions except the last one # (which is Find in files) to begin with for child in self.search_menu.actions()[:-1]: child.setEnabled(False) widget, textedit_properties = self.get_focus_widget_properties() if textedit_properties is None: # widget is not an editor/console return # !!! Below this line, widget is expected to be a QPlainTextEdit # instance console, not_readonly, readwrite_editor = textedit_properties # Find actions only trigger an effect in the Editor if not console: for action in self.search_menu.actions(): try: action.setEnabled(True) except RuntimeError: pass # Disable the replace action for read-only files self.search_menu_actions[3].setEnabled(readwrite_editor)
python
def update_search_menu(self): """Update search menu""" # Disabling all actions except the last one # (which is Find in files) to begin with for child in self.search_menu.actions()[:-1]: child.setEnabled(False) widget, textedit_properties = self.get_focus_widget_properties() if textedit_properties is None: # widget is not an editor/console return # !!! Below this line, widget is expected to be a QPlainTextEdit # instance console, not_readonly, readwrite_editor = textedit_properties # Find actions only trigger an effect in the Editor if not console: for action in self.search_menu.actions(): try: action.setEnabled(True) except RuntimeError: pass # Disable the replace action for read-only files self.search_menu_actions[3].setEnabled(readwrite_editor)
[ "def", "update_search_menu", "(", "self", ")", ":", "# Disabling all actions except the last one\r", "# (which is Find in files) to begin with\r", "for", "child", "in", "self", ".", "search_menu", ".", "actions", "(", ")", "[", ":", "-", "1", "]", ":", "child", ".",...
Update search menu
[ "Update", "search", "menu" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2180-L2204
30,899
spyder-ide/spyder
spyder/app/mainwindow.py
MainWindow.set_splash
def set_splash(self, message): """Set splash message""" if self.splash is None: return if message: logger.info(message) self.splash.show() self.splash.showMessage(message, Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.white)) QApplication.processEvents()
python
def set_splash(self, message): """Set splash message""" if self.splash is None: return if message: logger.info(message) self.splash.show() self.splash.showMessage(message, Qt.AlignBottom | Qt.AlignCenter | Qt.AlignAbsolute, QColor(Qt.white)) QApplication.processEvents()
[ "def", "set_splash", "(", "self", ",", "message", ")", ":", "if", "self", ".", "splash", "is", "None", ":", "return", "if", "message", ":", "logger", ".", "info", "(", "message", ")", "self", ".", "splash", ".", "show", "(", ")", "self", ".", "spla...
Set splash message
[ "Set", "splash", "message" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2255-L2264