repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.get_dirname | def get_dirname(self, index):
"""Return dirname associated with *index*"""
fname = self.get_filename(index)
if fname:
if osp.isdir(fname):
return fname
else:
return osp.dirname(fname) | python | def get_dirname(self, index):
"""Return dirname associated with *index*"""
fname = self.get_filename(index)
if fname:
if osp.isdir(fname):
return fname
else:
return osp.dirname(fname) | [
"def",
"get_dirname",
"(",
"self",
",",
"index",
")",
":",
"fname",
"=",
"self",
".",
"get_filename",
"(",
"index",
")",
"if",
"fname",
":",
"if",
"osp",
".",
"isdir",
"(",
"fname",
")",
":",
"return",
"fname",
"else",
":",
"return",
"osp",
".",
"d... | Return dirname associated with *index* | [
"Return",
"dirname",
"associated",
"with",
"*",
"index",
"*"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L228-L235 | train |
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
... | 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
... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.setup_common_actions | def setup_common_actions(self):
"""Setup context menu common actions"""
# Filters
filters_action = create_action(self, _("Edit filename filters..."),
None, ima.icon('filter'),
triggered=self.edit_filter)
... | python | def setup_common_actions(self):
"""Setup context menu common actions"""
# Filters
filters_action = create_action(self, _("Edit filename filters..."),
None, ima.icon('filter'),
triggered=self.edit_filter)
... | [
"def",
"setup_common_actions",
"(",
"self",
")",
":",
"# Filters\r",
"filters_action",
"=",
"create_action",
"(",
"self",
",",
"_",
"(",
"\"Edit filename filters...\"",
")",
",",
"None",
",",
"ima",
".",
"icon",
"(",
"'filter'",
")",
",",
"triggered",
"=",
"... | Setup context menu common actions | [
"Setup",
"context",
"menu",
"common",
"actions"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L257-L276 | train |
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,
", "... | python | def edit_filter(self):
"""Edit name filters"""
filters, valid = QInputDialog.getText(self, _('Edit filename filters'),
_('Name filters:'),
QLineEdit.Normal,
", "... | [
"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 | train |
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 | train |
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:
... | 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:
... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.create_file_manage_actions | def create_file_manage_actions(self, fnames):
"""Return file management actions"""
only_files = all([osp.isfile(_fn) for _fn in fnames])
only_modules = all([osp.splitext(_fn)[1] in ('.py', '.pyw', '.ipy')
for _fn in fnames])
only_notebooks = all([osp.spli... | python | def create_file_manage_actions(self, fnames):
"""Return file management actions"""
only_files = all([osp.isfile(_fn) for _fn in fnames])
only_modules = all([osp.splitext(_fn)[1] in ('.py', '.pyw', '.ipy')
for _fn in fnames])
only_notebooks = all([osp.spli... | [
"def",
"create_file_manage_actions",
"(",
"self",
",",
"fnames",
")",
":",
"only_files",
"=",
"all",
"(",
"[",
"osp",
".",
"isfile",
"(",
"_fn",
")",
"for",
"_fn",
"in",
"fnames",
"]",
")",
"only_modules",
"=",
"all",
"(",
"[",
"osp",
".",
"splitext",
... | Return file management actions | [
"Return",
"file",
"management",
"actions"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L324-L412 | train |
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")
ac... | 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")
ac... | [
"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 | train |
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
... | 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
... | [
"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 | train |
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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.keyPressEvent | def keyPressEvent(self, event):
"""Reimplement Qt method"""
if event.key() in (Qt.Key_Enter, Qt.Key_Return):
self.clicked()
elif event.key() == Qt.Key_F2:
self.rename()
elif event.key() == Qt.Key_Delete:
self.delete()
elif event.key() =... | python | def keyPressEvent(self, event):
"""Reimplement Qt method"""
if event.key() in (Qt.Key_Enter, Qt.Key_Return):
self.clicked()
elif event.key() == Qt.Key_F2:
self.rename()
elif event.key() == Qt.Key_Delete:
self.delete()
elif event.key() =... | [
"def",
"keyPressEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"key",
"(",
")",
"in",
"(",
"Qt",
".",
"Key_Enter",
",",
"Qt",
".",
"Key_Return",
")",
":",
"self",
".",
"clicked",
"(",
")",
"elif",
"event",
".",
"key",
"(",
")",
... | Reimplement Qt method | [
"Reimplement",
"Qt",
"method"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L490-L501 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.mouseReleaseEvent | def mouseReleaseEvent(self, event):
"""Reimplement Qt method."""
QTreeView.mouseReleaseEvent(self, event)
if self.single_click_to_open:
self.clicked() | python | def mouseReleaseEvent(self, event):
"""Reimplement Qt method."""
QTreeView.mouseReleaseEvent(self, event)
if self.single_click_to_open:
self.clicked() | [
"def",
"mouseReleaseEvent",
"(",
"self",
",",
"event",
")",
":",
"QTreeView",
".",
"mouseReleaseEvent",
"(",
"self",
",",
"event",
")",
"if",
"self",
".",
"single_click_to_open",
":",
"self",
".",
"clicked",
"(",
")"
] | Reimplement Qt method. | [
"Reimplement",
"Qt",
"method",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L508-L512 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.clicked | def clicked(self):
"""Selected item was double-clicked or enter/return was pressed"""
fnames = self.get_selected_filenames()
for fname in fnames:
if osp.isdir(fname):
self.directory_clicked(fname)
else:
self.open([fname]) | python | def clicked(self):
"""Selected item was double-clicked or enter/return was pressed"""
fnames = self.get_selected_filenames()
for fname in fnames:
if osp.isdir(fname):
self.directory_clicked(fname)
else:
self.open([fname]) | [
"def",
"clicked",
"(",
"self",
")",
":",
"fnames",
"=",
"self",
".",
"get_selected_filenames",
"(",
")",
"for",
"fname",
"in",
"fnames",
":",
"if",
"osp",
".",
"isdir",
"(",
"fname",
")",
":",
"self",
".",
"directory_clicked",
"(",
"fname",
")",
"else"... | Selected item was double-clicked or enter/return was pressed | [
"Selected",
"item",
"was",
"double",
"-",
"clicked",
"or",
"enter",
"/",
"return",
"was",
"pressed"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L515-L522 | train |
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 | train |
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 | train |
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... | 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... | [
"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 | train |
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 | train |
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... | 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... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.open_interpreter | def open_interpreter(self, fnames):
"""Open interpreter"""
for path in sorted(fnames):
self.sig_open_interpreter.emit(path) | python | def open_interpreter(self, fnames):
"""Open interpreter"""
for path in sorted(fnames):
self.sig_open_interpreter.emit(path) | [
"def",
"open_interpreter",
"(",
"self",
",",
"fnames",
")",
":",
"for",
"path",
"in",
"sorted",
"(",
"fnames",
")",
":",
"self",
".",
"sig_open_interpreter",
".",
"emit",
"(",
"path",
")"
] | Open interpreter | [
"Open",
"interpreter"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L578-L581 | train |
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 | train |
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 p... | 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 p... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.delete_file | def delete_file(self, fname, multiple, yes_to_all):
"""Delete file"""
if multiple:
buttons = QMessageBox.Yes|QMessageBox.YesToAll| \
QMessageBox.No|QMessageBox.Cancel
else:
buttons = QMessageBox.Yes|QMessageBox.No
if yes_to_all is None... | python | def delete_file(self, fname, multiple, yes_to_all):
"""Delete file"""
if multiple:
buttons = QMessageBox.Yes|QMessageBox.YesToAll| \
QMessageBox.No|QMessageBox.Cancel
else:
buttons = QMessageBox.Yes|QMessageBox.No
if yes_to_all is None... | [
"def",
"delete_file",
"(",
"self",
",",
"fname",
",",
"multiple",
",",
"yes_to_all",
")",
":",
"if",
"multiple",
":",
"buttons",
"=",
"QMessageBox",
".",
"Yes",
"|",
"QMessageBox",
".",
"YesToAll",
"|",
"QMessageBox",
".",
"No",
"|",
"QMessageBox",
".",
... | Delete file | [
"Delete",
"file"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L604-L636 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.delete | def delete(self, fnames=None):
"""Delete files"""
if fnames is None:
fnames = self.get_selected_filenames()
multiple = len(fnames) > 1
yes_to_all = None
for fname in fnames:
spyproject_path = osp.join(fname,'.spyproject')
if osp.isdir(f... | python | def delete(self, fnames=None):
"""Delete files"""
if fnames is None:
fnames = self.get_selected_filenames()
multiple = len(fnames) > 1
yes_to_all = None
for fname in fnames:
spyproject_path = osp.join(fname,'.spyproject')
if osp.isdir(f... | [
"def",
"delete",
"(",
"self",
",",
"fnames",
"=",
"None",
")",
":",
"if",
"fnames",
"is",
"None",
":",
"fnames",
"=",
"self",
".",
"get_selected_filenames",
"(",
")",
"multiple",
"=",
"len",
"(",
"fnames",
")",
">",
"1",
"yes_to_all",
"=",
"None",
"f... | Delete files | [
"Delete",
"files"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L639-L659 | train |
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... | 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... | [
"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 | train |
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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.rename_file | def rename_file(self, fname):
"""Rename file"""
path, valid = QInputDialog.getText(self, _('Rename'),
_('New name:'), QLineEdit.Normal,
osp.basename(fname))
if valid:
path = osp.join(osp.dirname(fname), to_text_string(... | python | def rename_file(self, fname):
"""Rename file"""
path, valid = QInputDialog.getText(self, _('Rename'),
_('New name:'), QLineEdit.Normal,
osp.basename(fname))
if valid:
path = osp.join(osp.dirname(fname), to_text_string(... | [
"def",
"rename_file",
"(",
"self",
",",
"fname",
")",
":",
"path",
",",
"valid",
"=",
"QInputDialog",
".",
"getText",
"(",
"self",
",",
"_",
"(",
"'Rename'",
")",
",",
"_",
"(",
"'New name:'",
")",
",",
"QLineEdit",
".",
"Normal",
",",
"osp",
".",
... | Rename file | [
"Rename",
"file"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L682-L709 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.rename | def rename(self, fnames=None):
"""Rename files"""
if fnames is None:
fnames = self.get_selected_filenames()
if not isinstance(fnames, (tuple, list)):
fnames = [fnames]
for fname in fnames:
self.rename_file(fname) | python | def rename(self, fnames=None):
"""Rename files"""
if fnames is None:
fnames = self.get_selected_filenames()
if not isinstance(fnames, (tuple, list)):
fnames = [fnames]
for fname in fnames:
self.rename_file(fname) | [
"def",
"rename",
"(",
"self",
",",
"fnames",
"=",
"None",
")",
":",
"if",
"fnames",
"is",
"None",
":",
"fnames",
"=",
"self",
".",
"get_selected_filenames",
"(",
")",
"if",
"not",
"isinstance",
"(",
"fnames",
",",
"(",
"tuple",
",",
"list",
")",
")",... | Rename files | [
"Rename",
"files"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L719-L726 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.move | def move(self, fnames=None, directory=None):
"""Move files/directories"""
if fnames is None:
fnames = self.get_selected_filenames()
orig = fixpath(osp.dirname(fnames[0]))
while True:
self.redirect_stdio.emit(False)
if directory is None:
... | python | def move(self, fnames=None, directory=None):
"""Move files/directories"""
if fnames is None:
fnames = self.get_selected_filenames()
orig = fixpath(osp.dirname(fnames[0]))
while True:
self.redirect_stdio.emit(False)
if directory is None:
... | [
"def",
"move",
"(",
"self",
",",
"fnames",
"=",
"None",
",",
"directory",
"=",
"None",
")",
":",
"if",
"fnames",
"is",
"None",
":",
"fnames",
"=",
"self",
".",
"get_selected_filenames",
"(",
")",
"orig",
"=",
"fixpath",
"(",
"osp",
".",
"dirname",
"(... | Move files/directories | [
"Move",
"files",
"/",
"directories"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L729-L756 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.create_new_folder | def create_new_folder(self, current_path, title, subtitle, is_package):
"""Create new folder"""
if current_path is None:
current_path = ''
if osp.isfile(current_path):
current_path = osp.dirname(current_path)
name, valid = QInputDialog.getText(self, title, s... | python | def create_new_folder(self, current_path, title, subtitle, is_package):
"""Create new folder"""
if current_path is None:
current_path = ''
if osp.isfile(current_path):
current_path = osp.dirname(current_path)
name, valid = QInputDialog.getText(self, title, s... | [
"def",
"create_new_folder",
"(",
"self",
",",
"current_path",
",",
"title",
",",
"subtitle",
",",
"is_package",
")",
":",
"if",
"current_path",
"is",
"None",
":",
"current_path",
"=",
"''",
"if",
"osp",
".",
"isfile",
"(",
"current_path",
")",
":",
"curren... | Create new folder | [
"Create",
"new",
"folder"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L758-L789 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.new_folder | def new_folder(self, basedir):
"""New folder"""
title = _('New folder')
subtitle = _('Folder name:')
self.create_new_folder(basedir, title, subtitle, is_package=False) | python | def new_folder(self, basedir):
"""New folder"""
title = _('New folder')
subtitle = _('Folder name:')
self.create_new_folder(basedir, title, subtitle, is_package=False) | [
"def",
"new_folder",
"(",
"self",
",",
"basedir",
")",
":",
"title",
"=",
"_",
"(",
"'New folder'",
")",
"subtitle",
"=",
"_",
"(",
"'Folder name:'",
")",
"self",
".",
"create_new_folder",
"(",
"basedir",
",",
"title",
",",
"subtitle",
",",
"is_package",
... | New folder | [
"New",
"folder"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L791-L795 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.new_package | def new_package(self, basedir):
"""New package"""
title = _('New package')
subtitle = _('Package name:')
self.create_new_folder(basedir, title, subtitle, is_package=True) | python | def new_package(self, basedir):
"""New package"""
title = _('New package')
subtitle = _('Package name:')
self.create_new_folder(basedir, title, subtitle, is_package=True) | [
"def",
"new_package",
"(",
"self",
",",
"basedir",
")",
":",
"title",
"=",
"_",
"(",
"'New package'",
")",
"subtitle",
"=",
"_",
"(",
"'Package name:'",
")",
"self",
".",
"create_new_folder",
"(",
"basedir",
",",
"title",
",",
"subtitle",
",",
"is_package"... | New package | [
"New",
"package"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L797-L801 | train |
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_std... | 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_std... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.new_file | def new_file(self, basedir):
"""New file"""
title = _("New file")
filters = _("All files")+" (*)"
def create_func(fname):
"""File creation callback"""
if osp.splitext(fname)[1] in ('.py', '.pyw', '.ipy'):
create_script(fname)
el... | python | def new_file(self, basedir):
"""New file"""
title = _("New file")
filters = _("All files")+" (*)"
def create_func(fname):
"""File creation callback"""
if osp.splitext(fname)[1] in ('.py', '.pyw', '.ipy'):
create_script(fname)
el... | [
"def",
"new_file",
"(",
"self",
",",
"basedir",
")",
":",
"title",
"=",
"_",
"(",
"\"New file\"",
")",
"filters",
"=",
"_",
"(",
"\"All files\"",
")",
"+",
"\" (*)\"",
"def",
"create_func",
"(",
"fname",
")",
":",
"\"\"\"File creation callback\"\"\"",
"if",
... | New file | [
"New",
"file"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L823-L836 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.new_module | def new_module(self, basedir):
"""New module"""
title = _("New module")
filters = _("Python scripts")+" (*.py *.pyw *.ipy)"
def create_func(fname):
self.sig_create_module.emit(fname)
self.create_new_file(basedir, title, filters, create_func) | python | def new_module(self, basedir):
"""New module"""
title = _("New module")
filters = _("Python scripts")+" (*.py *.pyw *.ipy)"
def create_func(fname):
self.sig_create_module.emit(fname)
self.create_new_file(basedir, title, filters, create_func) | [
"def",
"new_module",
"(",
"self",
",",
"basedir",
")",
":",
"title",
"=",
"_",
"(",
"\"New module\"",
")",
"filters",
"=",
"_",
"(",
"\"Python scripts\"",
")",
"+",
"\" (*.py *.pyw *.ipy)\"",
"def",
"create_func",
"(",
"fname",
")",
":",
"self",
".",
"sig_... | New module | [
"New",
"module"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L838-L846 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.copy_path | def copy_path(self, fnames=None, method="absolute"):
"""Copy absolute or relative path to given file(s)/folders(s)."""
cb = QApplication.clipboard()
explorer_dir = self.fsmodel.rootPath()
if fnames is None:
fnames = self.get_selected_filenames()
if not isinstanc... | python | def copy_path(self, fnames=None, method="absolute"):
"""Copy absolute or relative path to given file(s)/folders(s)."""
cb = QApplication.clipboard()
explorer_dir = self.fsmodel.rootPath()
if fnames is None:
fnames = self.get_selected_filenames()
if not isinstanc... | [
"def",
"copy_path",
"(",
"self",
",",
"fnames",
"=",
"None",
",",
"method",
"=",
"\"absolute\"",
")",
":",
"cb",
"=",
"QApplication",
".",
"clipboard",
"(",
")",
"explorer_dir",
"=",
"self",
".",
"fsmodel",
".",
"rootPath",
"(",
")",
"if",
"fnames",
"i... | Copy absolute or relative path to given file(s)/folders(s). | [
"Copy",
"absolute",
"or",
"relative",
"path",
"to",
"given",
"file",
"(",
"s",
")",
"/",
"folders",
"(",
"s",
")",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L851-L885 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.copy_file_clipboard | def copy_file_clipboard(self, fnames=None):
"""Copy file(s)/folders(s) to clipboard."""
if fnames is None:
fnames = self.get_selected_filenames()
if not isinstance(fnames, (tuple, list)):
fnames = [fnames]
try:
file_content = QMimeData()
... | python | def copy_file_clipboard(self, fnames=None):
"""Copy file(s)/folders(s) to clipboard."""
if fnames is None:
fnames = self.get_selected_filenames()
if not isinstance(fnames, (tuple, list)):
fnames = [fnames]
try:
file_content = QMimeData()
... | [
"def",
"copy_file_clipboard",
"(",
"self",
",",
"fnames",
"=",
"None",
")",
":",
"if",
"fnames",
"is",
"None",
":",
"fnames",
"=",
"self",
".",
"get_selected_filenames",
"(",
")",
"if",
"not",
"isinstance",
"(",
"fnames",
",",
"(",
"tuple",
",",
"list",
... | Copy file(s)/folders(s) to clipboard. | [
"Copy",
"file",
"(",
"s",
")",
"/",
"folders",
"(",
"s",
")",
"to",
"clipboard",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L898-L914 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.save_file_clipboard | def save_file_clipboard(self, fnames=None):
"""Paste file from clipboard into file/project explorer directory."""
if fnames is None:
fnames = self.get_selected_filenames()
if not isinstance(fnames, (tuple, list)):
fnames = [fnames]
if len(fnames) >= 1:
... | python | def save_file_clipboard(self, fnames=None):
"""Paste file from clipboard into file/project explorer directory."""
if fnames is None:
fnames = self.get_selected_filenames()
if not isinstance(fnames, (tuple, list)):
fnames = [fnames]
if len(fnames) >= 1:
... | [
"def",
"save_file_clipboard",
"(",
"self",
",",
"fnames",
"=",
"None",
")",
":",
"if",
"fnames",
"is",
"None",
":",
"fnames",
"=",
"self",
".",
"get_selected_filenames",
"(",
")",
"if",
"not",
"isinstance",
"(",
"fnames",
",",
"(",
"tuple",
",",
"list",
... | Paste file from clipboard into file/project explorer directory. | [
"Paste",
"file",
"from",
"clipboard",
"into",
"file",
"/",
"project",
"explorer",
"directory",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L917-L1001 | train |
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=... | 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=... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.vcs_command | def vcs_command(self, fnames, action):
"""VCS action (commit, browse)"""
try:
for path in sorted(fnames):
vcs.run_vcs_tool(path, action)
except vcs.ActionToolNotFound as error:
msg = _("For %s support, please install one of the<br/> "
... | python | def vcs_command(self, fnames, action):
"""VCS action (commit, browse)"""
try:
for path in sorted(fnames):
vcs.run_vcs_tool(path, action)
except vcs.ActionToolNotFound as error:
msg = _("For %s support, please install one of the<br/> "
... | [
"def",
"vcs_command",
"(",
"self",
",",
"fnames",
",",
"action",
")",
":",
"try",
":",
"for",
"path",
"in",
"sorted",
"(",
"fnames",
")",
":",
"vcs",
".",
"run_vcs_tool",
"(",
"path",
",",
"action",
")",
"except",
"vcs",
".",
"ActionToolNotFound",
"as"... | VCS action (commit, browse) | [
"VCS",
"action",
"(",
"commit",
"browse",
")"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1033-L1044 | train |
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 | train |
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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.save_expanded_state | def save_expanded_state(self):
"""Save all items expanded state"""
model = self.model()
# If model is not installed, 'model' will be None: this happens when
# using the Project Explorer without having selected a workspace yet
if model is not None:
self.__expande... | python | def save_expanded_state(self):
"""Save all items expanded state"""
model = self.model()
# If model is not installed, 'model' will be None: this happens when
# using the Project Explorer without having selected a workspace yet
if model is not None:
self.__expande... | [
"def",
"save_expanded_state",
"(",
"self",
")",
":",
"model",
"=",
"self",
".",
"model",
"(",
")",
"# If model is not installed, 'model' will be None: this happens when\r",
"# using the Project Explorer without having selected a workspace yet\r",
"if",
"model",
"is",
"not",
"No... | Save all items expanded state | [
"Save",
"all",
"items",
"expanded",
"state"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1075-L1084 | train |
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 = os... | 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 = os... | [
"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 | train |
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... | 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... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | DirView.restore_expanded_state | def restore_expanded_state(self):
"""Restore all items expanded state"""
if self.__expanded_state is not None:
# In the old project explorer, the expanded state was a dictionnary:
if isinstance(self.__expanded_state, list):
self.fsmodel.directoryLoaded.connec... | python | def restore_expanded_state(self):
"""Restore all items expanded state"""
if self.__expanded_state is not None:
# In the old project explorer, the expanded state was a dictionnary:
if isinstance(self.__expanded_state, list):
self.fsmodel.directoryLoaded.connec... | [
"def",
"restore_expanded_state",
"(",
"self",
")",
":",
"if",
"self",
".",
"__expanded_state",
"is",
"not",
"None",
":",
"# In the old project explorer, the expanded state was a dictionnary:\r",
"if",
"isinstance",
"(",
"self",
".",
"__expanded_state",
",",
"list",
")",... | Restore all items expanded state | [
"Restore",
"all",
"items",
"expanded",
"state"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1117-L1125 | train |
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 | train |
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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | ProxyModel.sort | def sort(self, column, order=Qt.AscendingOrder):
"""Reimplement Qt method"""
self.sourceModel().sort(column, order) | python | def sort(self, column, order=Qt.AscendingOrder):
"""Reimplement Qt method"""
self.sourceModel().sort(column, order) | [
"def",
"sort",
"(",
"self",
",",
"column",
",",
"order",
"=",
"Qt",
".",
"AscendingOrder",
")",
":",
"self",
".",
"sourceModel",
"(",
")",
".",
"sort",
"(",
"column",
",",
"order",
")"
] | Reimplement Qt method | [
"Reimplement",
"Qt",
"method"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1147-L1149 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | ProxyModel.filterAcceptsRow | def filterAcceptsRow(self, row, parent_index):
"""Reimplement Qt method"""
if self.root_path is None:
return True
index = self.sourceModel().index(row, 0, parent_index)
path = osp.normcase(osp.normpath(
to_text_string(self.sourceModel().filePath(index))))
... | python | def filterAcceptsRow(self, row, parent_index):
"""Reimplement Qt method"""
if self.root_path is None:
return True
index = self.sourceModel().index(row, 0, parent_index)
path = osp.normcase(osp.normpath(
to_text_string(self.sourceModel().filePath(index))))
... | [
"def",
"filterAcceptsRow",
"(",
"self",
",",
"row",
",",
"parent_index",
")",
":",
"if",
"self",
".",
"root_path",
"is",
"None",
":",
"return",
"True",
"index",
"=",
"self",
".",
"sourceModel",
"(",
")",
".",
"index",
"(",
"row",
",",
"0",
",",
"pare... | Reimplement Qt method | [
"Reimplement",
"Qt",
"method"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1151-L1166 | train |
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 QSortF... | 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 QSortF... | [
"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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | ExplorerTreeWidget.setup_common_actions | def setup_common_actions(self):
"""Setup context menu common actions"""
actions = super(ExplorerTreeWidget, self).setup_common_actions()
if self.show_cd_only is None:
# Enabling the 'show current directory only' option but do not
# allow the user to disable it
... | python | def setup_common_actions(self):
"""Setup context menu common actions"""
actions = super(ExplorerTreeWidget, self).setup_common_actions()
if self.show_cd_only is None:
# Enabling the 'show current directory only' option but do not
# allow the user to disable it
... | [
"def",
"setup_common_actions",
"(",
"self",
")",
":",
"actions",
"=",
"super",
"(",
"ExplorerTreeWidget",
",",
"self",
")",
".",
"setup_common_actions",
"(",
")",
"if",
"self",
".",
"show_cd_only",
"is",
"None",
":",
"# Enabling the 'show current directory only' opt... | Setup context menu common actions | [
"Setup",
"context",
"menu",
"common",
"actions"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1257-L1272 | train |
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(s... | 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(s... | [
"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 | train |
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 ... | 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 ... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | ExplorerTreeWidget.refresh | def refresh(self, new_path=None, force_current=False):
"""Refresh widget
force=False: won't refresh widget if path has not changed"""
if new_path is None:
new_path = getcwd_or_home()
if force_current:
index = self.set_current_folder(new_path)
se... | python | def refresh(self, new_path=None, force_current=False):
"""Refresh widget
force=False: won't refresh widget if path has not changed"""
if new_path is None:
new_path = getcwd_or_home()
if force_current:
index = self.set_current_folder(new_path)
se... | [
"def",
"refresh",
"(",
"self",
",",
"new_path",
"=",
"None",
",",
"force_current",
"=",
"False",
")",
":",
"if",
"new_path",
"is",
"None",
":",
"new_path",
"=",
"getcwd_or_home",
"(",
")",
"if",
"force_current",
":",
"index",
"=",
"self",
".",
"set_curre... | Refresh widget
force=False: won't refresh widget if path has not changed | [
"Refresh",
"widget",
"force",
"=",
"False",
":",
"won",
"t",
"refresh",
"widget",
"if",
"path",
"has",
"not",
"changed"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1299-L1313 | train |
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 | train |
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_... | 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_... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | ExplorerTreeWidget.chdir | def chdir(self, directory=None, browsing_history=False):
"""Set directory as working directory"""
if directory is not None:
directory = osp.abspath(to_text_string(directory))
if browsing_history:
directory = self.history[self.histindex]
elif directory in sel... | python | def chdir(self, directory=None, browsing_history=False):
"""Set directory as working directory"""
if directory is not None:
directory = osp.abspath(to_text_string(directory))
if browsing_history:
directory = self.history[self.histindex]
elif directory in sel... | [
"def",
"chdir",
"(",
"self",
",",
"directory",
"=",
"None",
",",
"browsing_history",
"=",
"False",
")",
":",
"if",
"directory",
"is",
"not",
"None",
":",
"directory",
"=",
"osp",
".",
"abspath",
"(",
"to_text_string",
"(",
"directory",
")",
")",
"if",
... | Set directory as working directory | [
"Set",
"directory",
"as",
"working",
"directory"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L1348-L1385 | train |
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.ToolButtonTextBesideIco... | 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.ToolButtonTextBesideIco... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/breakpoints/widgets/breakpointsgui.py | BreakpointTableModel.set_data | def set_data(self, data):
"""Set model data"""
self._data = data
keys = list(data.keys())
self.breakpoints = []
for key in keys:
bp_list = data[key]
if bp_list:
for item in data[key]:
self.breakpoints.append((ke... | python | def set_data(self, data):
"""Set model data"""
self._data = data
keys = list(data.keys())
self.breakpoints = []
for key in keys:
bp_list = data[key]
if bp_list:
for item in data[key]:
self.breakpoints.append((ke... | [
"def",
"set_data",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_data",
"=",
"data",
"keys",
"=",
"list",
"(",
"data",
".",
"keys",
"(",
")",
")",
"self",
".",
"breakpoints",
"=",
"[",
"]",
"for",
"key",
"in",
"keys",
":",
"bp_list",
"=",
... | Set model data | [
"Set",
"model",
"data"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/breakpoints/widgets/breakpointsgui.py#L57-L67 | train |
spyder-ide/spyder | spyder/plugins/breakpoints/widgets/breakpointsgui.py | BreakpointTableModel.sort | def sort(self, column, order=Qt.DescendingOrder):
"""Overriding sort method"""
if column == 0:
self.breakpoints.sort(
key=lambda breakpoint: breakpoint[1])
self.breakpoints.sort(
key=lambda breakpoint: osp.basename(breakpoint[0]))
el... | python | def sort(self, column, order=Qt.DescendingOrder):
"""Overriding sort method"""
if column == 0:
self.breakpoints.sort(
key=lambda breakpoint: breakpoint[1])
self.breakpoints.sort(
key=lambda breakpoint: osp.basename(breakpoint[0]))
el... | [
"def",
"sort",
"(",
"self",
",",
"column",
",",
"order",
"=",
"Qt",
".",
"DescendingOrder",
")",
":",
"if",
"column",
"==",
"0",
":",
"self",
".",
"breakpoints",
".",
"sort",
"(",
"key",
"=",
"lambda",
"breakpoint",
":",
"breakpoint",
"[",
"1",
"]",
... | Overriding sort method | [
"Overriding",
"sort",
"method"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/breakpoints/widgets/breakpointsgui.py#L77-L90 | train |
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_qvaria... | 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_qvaria... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/breakpoints/widgets/breakpointsgui.py | BreakpointTableView.setup_table | def setup_table(self):
"""Setup table"""
self.horizontalHeader().setStretchLastSection(True)
self.adjust_columns()
self.columnAt(0)
# Sorting columns
self.setSortingEnabled(False)
self.sortByColumn(0, Qt.DescendingOrder) | python | def setup_table(self):
"""Setup table"""
self.horizontalHeader().setStretchLastSection(True)
self.adjust_columns()
self.columnAt(0)
# Sorting columns
self.setSortingEnabled(False)
self.sortByColumn(0, Qt.DescendingOrder) | [
"def",
"setup_table",
"(",
"self",
")",
":",
"self",
".",
"horizontalHeader",
"(",
")",
".",
"setStretchLastSection",
"(",
"True",
")",
"self",
".",
"adjust_columns",
"(",
")",
"self",
".",
"columnAt",
"(",
"0",
")",
"# Sorting columns\r",
"self",
".",
"se... | Setup table | [
"Setup",
"table"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/breakpoints/widgets/breakpointsgui.py#L152-L159 | train |
spyder-ide/spyder | spyder/plugins/breakpoints/widgets/breakpointsgui.py | BreakpointTableView.mouseDoubleClickEvent | def mouseDoubleClickEvent(self, event):
"""Reimplement Qt method"""
index_clicked = self.indexAt(event.pos())
if self.model.breakpoints:
filename = self.model.breakpoints[index_clicked.row()][0]
line_number_str = self.model.breakpoints[index_clicked.row()][1]
... | python | def mouseDoubleClickEvent(self, event):
"""Reimplement Qt method"""
index_clicked = self.indexAt(event.pos())
if self.model.breakpoints:
filename = self.model.breakpoints[index_clicked.row()][0]
line_number_str = self.model.breakpoints[index_clicked.row()][1]
... | [
"def",
"mouseDoubleClickEvent",
"(",
"self",
",",
"event",
")",
":",
"index_clicked",
"=",
"self",
".",
"indexAt",
"(",
"event",
".",
"pos",
"(",
")",
")",
"if",
"self",
".",
"model",
".",
"breakpoints",
":",
"filename",
"=",
"self",
".",
"model",
".",... | Reimplement Qt method | [
"Reimplement",
"Qt",
"method"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/breakpoints/widgets/breakpointsgui.py#L166-L174 | train |
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]:... | 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]:... | [
"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 | train |
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.... | 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.... | [
"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 | train |
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 la... | 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 la... | [
"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 | train |
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 dem... | 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 dem... | [
"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 | train |
spyder-ide/spyder | spyder/plugins/editor/lsp/manager.py | LSPManager.generate_python_config | def generate_python_config(self):
"""
Update Python server configuration with the options saved in our
config system.
"""
python_config = PYTHON_CONFIG.copy()
# Server options
cmd = self.get_option('advanced/command_launch')
host = self.get_option('advanc... | python | def generate_python_config(self):
"""
Update Python server configuration with the options saved in our
config system.
"""
python_config = PYTHON_CONFIG.copy()
# Server options
cmd = self.get_option('advanced/command_launch')
host = self.get_option('advanc... | [
"def",
"generate_python_config",
"(",
"self",
")",
":",
"python_config",
"=",
"PYTHON_CONFIG",
".",
"copy",
"(",
")",
"# Server options",
"cmd",
"=",
"self",
".",
"get_option",
"(",
"'advanced/command_launch'",
")",
"host",
"=",
"self",
".",
"get_option",
"(",
... | Update Python server configuration with the options saved in our
config system. | [
"Update",
"Python",
"server",
"configuration",
"with",
"the",
"options",
"saved",
"in",
"our",
"config",
"system",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/manager.py#L230-L326 | train |
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,
... | 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,
... | [
"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 | train |
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 t... | 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 t... | [
"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 | train |
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:
... | 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:
... | [
"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 | train |
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 s... | 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 s... | [
"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 | train |
spyder-ide/spyder | spyder/utils/encoding.py | get_coding | def get_coding(text, force_chardet=False):
"""
Function to get the coding of a text.
@param text text to inspect (string)
@return coding string
"""
if not force_chardet:
for line in text.splitlines()[:2]:
try:
result = CODING_RE.search(to_text_string(... | python | def get_coding(text, force_chardet=False):
"""
Function to get the coding of a text.
@param text text to inspect (string)
@return coding string
"""
if not force_chardet:
for line in text.splitlines()[:2]:
try:
result = CODING_RE.search(to_text_string(... | [
"def",
"get_coding",
"(",
"text",
",",
"force_chardet",
"=",
"False",
")",
":",
"if",
"not",
"force_chardet",
":",
"for",
"line",
"in",
"text",
".",
"splitlines",
"(",
")",
"[",
":",
"2",
"]",
":",
"try",
":",
"result",
"=",
"CODING_RE",
".",
"search... | Function to get the coding of a text.
@param text text to inspect (string)
@return coding string | [
"Function",
"to",
"get",
"the",
"coding",
"of",
"a",
"text",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/encoding.py#L107-L140 | train |
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 ... | 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 ... | [
"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 | train |
spyder-ide/spyder | spyder/utils/encoding.py | to_unicode | def to_unicode(string):
"""Convert a string to unicode"""
if not is_unicode(string):
for codec in CODECS:
try:
unic = to_text_string(string, codec)
except UnicodeError:
pass
except TypeError:
break
... | python | def to_unicode(string):
"""Convert a string to unicode"""
if not is_unicode(string):
for codec in CODECS:
try:
unic = to_text_string(string, codec)
except UnicodeError:
pass
except TypeError:
break
... | [
"def",
"to_unicode",
"(",
"string",
")",
":",
"if",
"not",
"is_unicode",
"(",
"string",
")",
":",
"for",
"codec",
"in",
"CODECS",
":",
"try",
":",
"unic",
"=",
"to_text_string",
"(",
"string",
",",
"codec",
")",
"except",
"UnicodeError",
":",
"pass",
"... | Convert a string to unicode | [
"Convert",
"a",
"string",
"to",
"unicode"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/encoding.py#L213-L225 | train |
spyder-ide/spyder | spyder/utils/encoding.py | write | def write(text, filename, encoding='utf-8', mode='wb'):
"""
Write 'text' to file ('filename') assuming 'encoding' in an atomic way
Return (eventually new) encoding
"""
text, encoding = encode(text, encoding)
if 'a' in mode:
with open(filename, mode) as textfile:
textf... | python | def write(text, filename, encoding='utf-8', mode='wb'):
"""
Write 'text' to file ('filename') assuming 'encoding' in an atomic way
Return (eventually new) encoding
"""
text, encoding = encode(text, encoding)
if 'a' in mode:
with open(filename, mode) as textfile:
textf... | [
"def",
"write",
"(",
"text",
",",
"filename",
",",
"encoding",
"=",
"'utf-8'",
",",
"mode",
"=",
"'wb'",
")",
":",
"text",
",",
"encoding",
"=",
"encode",
"(",
"text",
",",
"encoding",
")",
"if",
"'a'",
"in",
"mode",
":",
"with",
"open",
"(",
"file... | Write 'text' to file ('filename') assuming 'encoding' in an atomic way
Return (eventually new) encoding | [
"Write",
"text",
"to",
"file",
"(",
"filename",
")",
"assuming",
"encoding",
"in",
"an",
"atomic",
"way",
"Return",
"(",
"eventually",
"new",
")",
"encoding"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/encoding.py#L228-L242 | train |
spyder-ide/spyder | spyder/utils/encoding.py | writelines | def writelines(lines, filename, encoding='utf-8', mode='wb'):
"""
Write 'lines' to file ('filename') assuming 'encoding'
Return (eventually new) encoding
"""
return write(os.linesep.join(lines), filename, encoding, mode) | python | def writelines(lines, filename, encoding='utf-8', mode='wb'):
"""
Write 'lines' to file ('filename') assuming 'encoding'
Return (eventually new) encoding
"""
return write(os.linesep.join(lines), filename, encoding, mode) | [
"def",
"writelines",
"(",
"lines",
",",
"filename",
",",
"encoding",
"=",
"'utf-8'",
",",
"mode",
"=",
"'wb'",
")",
":",
"return",
"write",
"(",
"os",
".",
"linesep",
".",
"join",
"(",
"lines",
")",
",",
"filename",
",",
"encoding",
",",
"mode",
")"
... | Write 'lines' to file ('filename') assuming 'encoding'
Return (eventually new) encoding | [
"Write",
"lines",
"to",
"file",
"(",
"filename",
")",
"assuming",
"encoding",
"Return",
"(",
"eventually",
"new",
")",
"encoding"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/encoding.py#L245-L250 | train |
spyder-ide/spyder | spyder/utils/encoding.py | read | def read(filename, encoding='utf-8'):
"""
Read text from file ('filename')
Return text and encoding
"""
text, encoding = decode( open(filename, 'rb').read() )
return text, encoding | python | def read(filename, encoding='utf-8'):
"""
Read text from file ('filename')
Return text and encoding
"""
text, encoding = decode( open(filename, 'rb').read() )
return text, encoding | [
"def",
"read",
"(",
"filename",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"text",
",",
"encoding",
"=",
"decode",
"(",
"open",
"(",
"filename",
",",
"'rb'",
")",
".",
"read",
"(",
")",
")",
"return",
"text",
",",
"encoding"
] | Read text from file ('filename')
Return text and encoding | [
"Read",
"text",
"from",
"file",
"(",
"filename",
")",
"Return",
"text",
"and",
"encoding"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/encoding.py#L252-L258 | train |
spyder-ide/spyder | spyder/utils/encoding.py | readlines | def readlines(filename, encoding='utf-8'):
"""
Read lines from file ('filename')
Return lines and encoding
"""
text, encoding = read(filename, encoding)
return text.split(os.linesep), encoding | python | def readlines(filename, encoding='utf-8'):
"""
Read lines from file ('filename')
Return lines and encoding
"""
text, encoding = read(filename, encoding)
return text.split(os.linesep), encoding | [
"def",
"readlines",
"(",
"filename",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"text",
",",
"encoding",
"=",
"read",
"(",
"filename",
",",
"encoding",
")",
"return",
"text",
".",
"split",
"(",
"os",
".",
"linesep",
")",
",",
"encoding"
] | Read lines from file ('filename')
Return lines and encoding | [
"Read",
"lines",
"from",
"file",
"(",
"filename",
")",
"Return",
"lines",
"and",
"encoding"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/encoding.py#L260-L266 | train |
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:
... | 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:
... | [
"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 | train |
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 | train |
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_extensio... | 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_extensio... | [
"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 | train |
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
e... | 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
e... | [
"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 | train |
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 gt... | 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 gt... | [
"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 | train |
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
... | 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
... | [
"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 | train |
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 | train |
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 | train |
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 | train |
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(pathli... | 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(pathli... | [
"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 | train |
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)
sel... | 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)
sel... | [
"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 | train |
spyder-ide/spyder | setup.py | get_package_data | def get_package_data(name, extlist):
"""Return data files for package *name* with extensions in *extlist*"""
flist = []
# Workaround to replace os.path.relpath (not available until Python 2.6):
offset = len(name)+len(os.pathsep)
for dirpath, _dirnames, filenames in os.walk(name):
for fname i... | python | def get_package_data(name, extlist):
"""Return data files for package *name* with extensions in *extlist*"""
flist = []
# Workaround to replace os.path.relpath (not available until Python 2.6):
offset = len(name)+len(os.pathsep)
for dirpath, _dirnames, filenames in os.walk(name):
for fname i... | [
"def",
"get_package_data",
"(",
"name",
",",
"extlist",
")",
":",
"flist",
"=",
"[",
"]",
"# Workaround to replace os.path.relpath (not available until Python 2.6):",
"offset",
"=",
"len",
"(",
"name",
")",
"+",
"len",
"(",
"os",
".",
"pathsep",
")",
"for",
"dir... | Return data files for package *name* with extensions in *extlist* | [
"Return",
"data",
"files",
"for",
"package",
"*",
"name",
"*",
"with",
"extensions",
"in",
"*",
"extlist",
"*"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/setup.py#L63-L72 | train |
spyder-ide/spyder | setup.py | get_subpackages | def get_subpackages(name):
"""Return subpackages of package *name*"""
splist = []
for dirpath, _dirnames, _filenames in os.walk(name):
if osp.isfile(osp.join(dirpath, '__init__.py')):
splist.append(".".join(dirpath.split(os.sep)))
return splist | python | def get_subpackages(name):
"""Return subpackages of package *name*"""
splist = []
for dirpath, _dirnames, _filenames in os.walk(name):
if osp.isfile(osp.join(dirpath, '__init__.py')):
splist.append(".".join(dirpath.split(os.sep)))
return splist | [
"def",
"get_subpackages",
"(",
"name",
")",
":",
"splist",
"=",
"[",
"]",
"for",
"dirpath",
",",
"_dirnames",
",",
"_filenames",
"in",
"os",
".",
"walk",
"(",
"name",
")",
":",
"if",
"osp",
".",
"isfile",
"(",
"osp",
".",
"join",
"(",
"dirpath",
",... | Return subpackages of package *name* | [
"Return",
"subpackages",
"of",
"package",
"*",
"name",
"*"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/setup.py#L75-L81 | train |
spyder-ide/spyder | spyder/app/mainwindow.py | get_python_doc_path | def get_python_doc_path():
"""
Return Python documentation path
(Windows: return the PythonXX.chm path if available)
"""
if os.name == 'nt':
doc_path = osp.join(sys.prefix, "Doc")
if not osp.isdir(doc_path):
return
python_chm = [path for path in os.listdi... | python | def get_python_doc_path():
"""
Return Python documentation path
(Windows: return the PythonXX.chm path if available)
"""
if os.name == 'nt':
doc_path = osp.join(sys.prefix, "Doc")
if not osp.isdir(doc_path):
return
python_chm = [path for path in os.listdi... | [
"def",
"get_python_doc_path",
"(",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"doc_path",
"=",
"osp",
".",
"join",
"(",
"sys",
".",
"prefix",
",",
"\"Doc\"",
")",
"if",
"not",
"osp",
".",
"isdir",
"(",
"doc_path",
")",
":",
"return",
"py... | Return Python documentation path
(Windows: return the PythonXX.chm path if available) | [
"Return",
"Python",
"documentation",
"path",
"(",
"Windows",
":",
"return",
"the",
"PythonXX",
".",
"chm",
"path",
"if",
"available",
")"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L192-L210 | train |
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.setSceneGraphBa... | 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.setSceneGraphBa... | [
"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 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.