id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1 value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
31,200 | spyder-ide/spyder | spyder/plugins/console/widgets/console.py | ConsoleBaseWidget.set_pythonshell_font | def set_pythonshell_font(self, font=None):
"""Python Shell only"""
if font is None:
font = QFont()
for style in self.font_styles:
style.apply_style(font=font,
is_default=style is self.default_style)
self.ansi_handler.set_base_format(self.default_style.format) | python | def set_pythonshell_font(self, font=None):
"""Python Shell only"""
if font is None:
font = QFont()
for style in self.font_styles:
style.apply_style(font=font,
is_default=style is self.default_style)
self.ansi_handler.set_base_format(self.default_style.format) | [
"def",
"set_pythonshell_font",
"(",
"self",
",",
"font",
"=",
"None",
")",
":",
"if",
"font",
"is",
"None",
":",
"font",
"=",
"QFont",
"(",
")",
"for",
"style",
"in",
"self",
".",
"font_styles",
":",
"style",
".",
"apply_style",
"(",
"font",
"=",
"fo... | Python Shell only | [
"Python",
"Shell",
"only"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/widgets/console.py#L291-L298 |
31,201 | spyder-ide/spyder | spyder/plugins/pylint/plugin.py | Pylint.get_plugin_icon | def get_plugin_icon(self):
"""Return widget icon"""
path = osp.join(self.PLUGIN_PATH, self.IMG_PATH)
return ima.icon('pylint', icon_path=path) | python | def get_plugin_icon(self):
"""Return widget icon"""
path = osp.join(self.PLUGIN_PATH, self.IMG_PATH)
return ima.icon('pylint', icon_path=path) | [
"def",
"get_plugin_icon",
"(",
"self",
")",
":",
"path",
"=",
"osp",
".",
"join",
"(",
"self",
".",
"PLUGIN_PATH",
",",
"self",
".",
"IMG_PATH",
")",
"return",
"ima",
".",
"icon",
"(",
"'pylint'",
",",
"icon_path",
"=",
"path",
")"
] | Return widget icon | [
"Return",
"widget",
"icon"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/pylint/plugin.py#L75-L78 |
31,202 | spyder-ide/spyder | spyder/plugins/pylint/plugin.py | Pylint.run_pylint | def run_pylint(self):
"""Run pylint code analysis"""
if (self.get_option('save_before', True)
and not self.main.editor.save()):
return
self.switch_to_plugin()
self.analyze(self.main.editor.get_current_filename()) | python | def run_pylint(self):
"""Run pylint code analysis"""
if (self.get_option('save_before', True)
and not self.main.editor.save()):
return
self.switch_to_plugin()
self.analyze(self.main.editor.get_current_filename()) | [
"def",
"run_pylint",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"get_option",
"(",
"'save_before'",
",",
"True",
")",
"and",
"not",
"self",
".",
"main",
".",
"editor",
".",
"save",
"(",
")",
")",
":",
"return",
"self",
".",
"switch_to_plugin",
"(... | Run pylint code analysis | [
"Run",
"pylint",
"code",
"analysis"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/pylint/plugin.py#L138-L144 |
31,203 | spyder-ide/spyder | spyder/preferences/appearance.py | AppearanceConfigPage.set_font | def set_font(self, font, option):
"""Set global font used in Spyder."""
# Update fonts in all plugins
set_font(font, option=option)
plugins = self.main.widgetlist + self.main.thirdparty_plugins
for plugin in plugins:
plugin.update_font() | python | def set_font(self, font, option):
"""Set global font used in Spyder."""
# Update fonts in all plugins
set_font(font, option=option)
plugins = self.main.widgetlist + self.main.thirdparty_plugins
for plugin in plugins:
plugin.update_font() | [
"def",
"set_font",
"(",
"self",
",",
"font",
",",
"option",
")",
":",
"# Update fonts in all plugins",
"set_font",
"(",
"font",
",",
"option",
"=",
"option",
")",
"plugins",
"=",
"self",
".",
"main",
".",
"widgetlist",
"+",
"self",
".",
"main",
".",
"thi... | Set global font used in Spyder. | [
"Set",
"global",
"font",
"used",
"in",
"Spyder",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L182-L188 |
31,204 | spyder-ide/spyder | spyder/preferences/appearance.py | AppearanceConfigPage.update_combobox | def update_combobox(self):
"""Recreates the combobox contents."""
index = self.current_scheme_index
self.schemes_combobox.blockSignals(True)
names = self.get_option("names")
try:
names.pop(names.index(u'Custom'))
except ValueError:
pass
custom_names = self.get_option("custom_names", [])
# Useful for retrieving the actual data
for n in names + custom_names:
self.scheme_choices_dict[self.get_option('{0}/name'.format(n))] = n
if custom_names:
choices = names + [None] + custom_names
else:
choices = names
combobox = self.schemes_combobox
combobox.clear()
for name in choices:
if name is None:
continue
combobox.addItem(self.get_option('{0}/name'.format(name)), name)
if custom_names:
combobox.insertSeparator(len(names))
self.schemes_combobox.blockSignals(False)
self.schemes_combobox.setCurrentIndex(index) | python | def update_combobox(self):
"""Recreates the combobox contents."""
index = self.current_scheme_index
self.schemes_combobox.blockSignals(True)
names = self.get_option("names")
try:
names.pop(names.index(u'Custom'))
except ValueError:
pass
custom_names = self.get_option("custom_names", [])
# Useful for retrieving the actual data
for n in names + custom_names:
self.scheme_choices_dict[self.get_option('{0}/name'.format(n))] = n
if custom_names:
choices = names + [None] + custom_names
else:
choices = names
combobox = self.schemes_combobox
combobox.clear()
for name in choices:
if name is None:
continue
combobox.addItem(self.get_option('{0}/name'.format(name)), name)
if custom_names:
combobox.insertSeparator(len(names))
self.schemes_combobox.blockSignals(False)
self.schemes_combobox.setCurrentIndex(index) | [
"def",
"update_combobox",
"(",
"self",
")",
":",
"index",
"=",
"self",
".",
"current_scheme_index",
"self",
".",
"schemes_combobox",
".",
"blockSignals",
"(",
"True",
")",
"names",
"=",
"self",
".",
"get_option",
"(",
"\"names\"",
")",
"try",
":",
"names",
... | Recreates the combobox contents. | [
"Recreates",
"the",
"combobox",
"contents",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L255-L287 |
31,205 | spyder-ide/spyder | spyder/preferences/appearance.py | AppearanceConfigPage.update_buttons | def update_buttons(self):
"""Updates the enable status of delete and reset buttons."""
current_scheme = self.current_scheme
names = self.get_option("names")
try:
names.pop(names.index(u'Custom'))
except ValueError:
pass
delete_enabled = current_scheme not in names
self.delete_button.setEnabled(delete_enabled)
self.reset_button.setEnabled(not delete_enabled) | python | def update_buttons(self):
"""Updates the enable status of delete and reset buttons."""
current_scheme = self.current_scheme
names = self.get_option("names")
try:
names.pop(names.index(u'Custom'))
except ValueError:
pass
delete_enabled = current_scheme not in names
self.delete_button.setEnabled(delete_enabled)
self.reset_button.setEnabled(not delete_enabled) | [
"def",
"update_buttons",
"(",
"self",
")",
":",
"current_scheme",
"=",
"self",
".",
"current_scheme",
"names",
"=",
"self",
".",
"get_option",
"(",
"\"names\"",
")",
"try",
":",
"names",
".",
"pop",
"(",
"names",
".",
"index",
"(",
"u'Custom'",
")",
")",... | Updates the enable status of delete and reset buttons. | [
"Updates",
"the",
"enable",
"status",
"of",
"delete",
"and",
"reset",
"buttons",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L289-L299 |
31,206 | spyder-ide/spyder | spyder/preferences/appearance.py | AppearanceConfigPage.update_preview | def update_preview(self, index=None, scheme_name=None):
"""
Update the color scheme of the preview editor and adds text.
Note
----
'index' is needed, because this is triggered by a signal that sends
the selected index.
"""
text = ('"""A string"""\n\n'
'# A comment\n\n'
'# %% A cell\n\n'
'class Foo(object):\n'
' def __init__(self):\n'
' bar = 42\n'
' print(bar)\n'
)
show_blanks = CONF.get('editor', 'blank_spaces')
update_scrollbar = CONF.get('editor', 'scroll_past_end')
if scheme_name is None:
scheme_name = self.current_scheme
self.preview_editor.setup_editor(linenumbers=True,
markers=True,
tab_mode=False,
font=get_font(),
show_blanks=show_blanks,
color_scheme=scheme_name,
scroll_past_end=update_scrollbar)
self.preview_editor.set_text(text)
self.preview_editor.set_language('Python') | python | def update_preview(self, index=None, scheme_name=None):
"""
Update the color scheme of the preview editor and adds text.
Note
----
'index' is needed, because this is triggered by a signal that sends
the selected index.
"""
text = ('"""A string"""\n\n'
'# A comment\n\n'
'# %% A cell\n\n'
'class Foo(object):\n'
' def __init__(self):\n'
' bar = 42\n'
' print(bar)\n'
)
show_blanks = CONF.get('editor', 'blank_spaces')
update_scrollbar = CONF.get('editor', 'scroll_past_end')
if scheme_name is None:
scheme_name = self.current_scheme
self.preview_editor.setup_editor(linenumbers=True,
markers=True,
tab_mode=False,
font=get_font(),
show_blanks=show_blanks,
color_scheme=scheme_name,
scroll_past_end=update_scrollbar)
self.preview_editor.set_text(text)
self.preview_editor.set_language('Python') | [
"def",
"update_preview",
"(",
"self",
",",
"index",
"=",
"None",
",",
"scheme_name",
"=",
"None",
")",
":",
"text",
"=",
"(",
"'\"\"\"A string\"\"\"\\n\\n'",
"'# A comment\\n\\n'",
"'# %% A cell\\n\\n'",
"'class Foo(object):\\n'",
"' def __init__(self):\\n'",
"' ... | Update the color scheme of the preview editor and adds text.
Note
----
'index' is needed, because this is triggered by a signal that sends
the selected index. | [
"Update",
"the",
"color",
"scheme",
"of",
"the",
"preview",
"editor",
"and",
"adds",
"text",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L301-L330 |
31,207 | spyder-ide/spyder | spyder/preferences/appearance.py | AppearanceConfigPage.create_new_scheme | def create_new_scheme(self):
"""Creates a new color scheme with a custom name."""
names = self.get_option('names')
custom_names = self.get_option('custom_names', [])
# Get the available number this new color scheme
counter = len(custom_names) - 1
custom_index = [int(n.split('-')[-1]) for n in custom_names]
for i in range(len(custom_names)):
if custom_index[i] != i:
counter = i - 1
break
custom_name = "custom-{0}".format(counter+1)
# Add the config settings, based on the current one.
custom_names.append(custom_name)
self.set_option('custom_names', custom_names)
for key in syntaxhighlighters.COLOR_SCHEME_KEYS:
name = "{0}/{1}".format(custom_name, key)
default_name = "{0}/{1}".format(self.current_scheme, key)
option = self.get_option(default_name)
self.set_option(name, option)
self.set_option('{0}/name'.format(custom_name), custom_name)
# Now they need to be loaded! how to make a partial load_from_conf?
dlg = self.scheme_editor_dialog
dlg.add_color_scheme_stack(custom_name, custom=True)
dlg.set_scheme(custom_name)
self.load_from_conf()
if dlg.exec_():
# This is needed to have the custom name updated on the combobox
name = dlg.get_scheme_name()
self.set_option('{0}/name'.format(custom_name), name)
# The +1 is needed because of the separator in the combobox
index = (names + custom_names).index(custom_name) + 1
self.update_combobox()
self.schemes_combobox.setCurrentIndex(index)
else:
# Delete the config ....
custom_names.remove(custom_name)
self.set_option('custom_names', custom_names)
dlg.delete_color_scheme_stack(custom_name) | python | def create_new_scheme(self):
"""Creates a new color scheme with a custom name."""
names = self.get_option('names')
custom_names = self.get_option('custom_names', [])
# Get the available number this new color scheme
counter = len(custom_names) - 1
custom_index = [int(n.split('-')[-1]) for n in custom_names]
for i in range(len(custom_names)):
if custom_index[i] != i:
counter = i - 1
break
custom_name = "custom-{0}".format(counter+1)
# Add the config settings, based on the current one.
custom_names.append(custom_name)
self.set_option('custom_names', custom_names)
for key in syntaxhighlighters.COLOR_SCHEME_KEYS:
name = "{0}/{1}".format(custom_name, key)
default_name = "{0}/{1}".format(self.current_scheme, key)
option = self.get_option(default_name)
self.set_option(name, option)
self.set_option('{0}/name'.format(custom_name), custom_name)
# Now they need to be loaded! how to make a partial load_from_conf?
dlg = self.scheme_editor_dialog
dlg.add_color_scheme_stack(custom_name, custom=True)
dlg.set_scheme(custom_name)
self.load_from_conf()
if dlg.exec_():
# This is needed to have the custom name updated on the combobox
name = dlg.get_scheme_name()
self.set_option('{0}/name'.format(custom_name), name)
# The +1 is needed because of the separator in the combobox
index = (names + custom_names).index(custom_name) + 1
self.update_combobox()
self.schemes_combobox.setCurrentIndex(index)
else:
# Delete the config ....
custom_names.remove(custom_name)
self.set_option('custom_names', custom_names)
dlg.delete_color_scheme_stack(custom_name) | [
"def",
"create_new_scheme",
"(",
"self",
")",
":",
"names",
"=",
"self",
".",
"get_option",
"(",
"'names'",
")",
"custom_names",
"=",
"self",
".",
"get_option",
"(",
"'custom_names'",
",",
"[",
"]",
")",
"# Get the available number this new color scheme",
"counter... | Creates a new color scheme with a custom name. | [
"Creates",
"a",
"new",
"color",
"scheme",
"with",
"a",
"custom",
"name",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L334-L377 |
31,208 | spyder-ide/spyder | spyder/preferences/appearance.py | AppearanceConfigPage.edit_scheme | def edit_scheme(self):
"""Edit current scheme."""
dlg = self.scheme_editor_dialog
dlg.set_scheme(self.current_scheme)
if dlg.exec_():
# Update temp scheme to reflect instant edits on the preview
temporal_color_scheme = dlg.get_edited_color_scheme()
for key in temporal_color_scheme:
option = "temp/{0}".format(key)
value = temporal_color_scheme[key]
self.set_option(option, value)
self.update_preview(scheme_name='temp') | python | def edit_scheme(self):
"""Edit current scheme."""
dlg = self.scheme_editor_dialog
dlg.set_scheme(self.current_scheme)
if dlg.exec_():
# Update temp scheme to reflect instant edits on the preview
temporal_color_scheme = dlg.get_edited_color_scheme()
for key in temporal_color_scheme:
option = "temp/{0}".format(key)
value = temporal_color_scheme[key]
self.set_option(option, value)
self.update_preview(scheme_name='temp') | [
"def",
"edit_scheme",
"(",
"self",
")",
":",
"dlg",
"=",
"self",
".",
"scheme_editor_dialog",
"dlg",
".",
"set_scheme",
"(",
"self",
".",
"current_scheme",
")",
"if",
"dlg",
".",
"exec_",
"(",
")",
":",
"# Update temp scheme to reflect instant edits on the preview... | Edit current scheme. | [
"Edit",
"current",
"scheme",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L379-L391 |
31,209 | spyder-ide/spyder | spyder/preferences/appearance.py | AppearanceConfigPage.delete_scheme | def delete_scheme(self):
"""Deletes the currently selected custom color scheme."""
scheme_name = self.current_scheme
answer = QMessageBox.warning(self, _("Warning"),
_("Are you sure you want to delete "
"this scheme?"),
QMessageBox.Yes | QMessageBox.No)
if answer == QMessageBox.Yes:
# Put the combobox in Spyder by default, when deleting a scheme
names = self.get_option('names')
self.set_scheme('spyder')
self.schemes_combobox.setCurrentIndex(names.index('spyder'))
self.set_option('selected', 'spyder')
# Delete from custom_names
custom_names = self.get_option('custom_names', [])
if scheme_name in custom_names:
custom_names.remove(scheme_name)
self.set_option('custom_names', custom_names)
# Delete config options
for key in syntaxhighlighters.COLOR_SCHEME_KEYS:
option = "{0}/{1}".format(scheme_name, key)
CONF.remove_option(self.CONF_SECTION, option)
CONF.remove_option(self.CONF_SECTION,
"{0}/name".format(scheme_name))
self.update_combobox()
self.update_preview() | python | def delete_scheme(self):
"""Deletes the currently selected custom color scheme."""
scheme_name = self.current_scheme
answer = QMessageBox.warning(self, _("Warning"),
_("Are you sure you want to delete "
"this scheme?"),
QMessageBox.Yes | QMessageBox.No)
if answer == QMessageBox.Yes:
# Put the combobox in Spyder by default, when deleting a scheme
names = self.get_option('names')
self.set_scheme('spyder')
self.schemes_combobox.setCurrentIndex(names.index('spyder'))
self.set_option('selected', 'spyder')
# Delete from custom_names
custom_names = self.get_option('custom_names', [])
if scheme_name in custom_names:
custom_names.remove(scheme_name)
self.set_option('custom_names', custom_names)
# Delete config options
for key in syntaxhighlighters.COLOR_SCHEME_KEYS:
option = "{0}/{1}".format(scheme_name, key)
CONF.remove_option(self.CONF_SECTION, option)
CONF.remove_option(self.CONF_SECTION,
"{0}/name".format(scheme_name))
self.update_combobox()
self.update_preview() | [
"def",
"delete_scheme",
"(",
"self",
")",
":",
"scheme_name",
"=",
"self",
".",
"current_scheme",
"answer",
"=",
"QMessageBox",
".",
"warning",
"(",
"self",
",",
"_",
"(",
"\"Warning\"",
")",
",",
"_",
"(",
"\"Are you sure you want to delete \"",
"\"this scheme?... | Deletes the currently selected custom color scheme. | [
"Deletes",
"the",
"currently",
"selected",
"custom",
"color",
"scheme",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L393-L422 |
31,210 | spyder-ide/spyder | spyder/preferences/appearance.py | AppearanceConfigPage.reset_to_default | def reset_to_default(self):
"""Restore initial values for default color schemes."""
# Checks that this is indeed a default scheme
scheme = self.current_scheme
names = self.get_option('names')
if scheme in names:
for key in syntaxhighlighters.COLOR_SCHEME_KEYS:
option = "{0}/{1}".format(scheme, key)
value = CONF.get_default(self.CONF_SECTION, option)
self.set_option(option, value)
self.load_from_conf() | python | def reset_to_default(self):
"""Restore initial values for default color schemes."""
# Checks that this is indeed a default scheme
scheme = self.current_scheme
names = self.get_option('names')
if scheme in names:
for key in syntaxhighlighters.COLOR_SCHEME_KEYS:
option = "{0}/{1}".format(scheme, key)
value = CONF.get_default(self.CONF_SECTION, option)
self.set_option(option, value)
self.load_from_conf() | [
"def",
"reset_to_default",
"(",
"self",
")",
":",
"# Checks that this is indeed a default scheme",
"scheme",
"=",
"self",
".",
"current_scheme",
"names",
"=",
"self",
".",
"get_option",
"(",
"'names'",
")",
"if",
"scheme",
"in",
"names",
":",
"for",
"key",
"in",... | Restore initial values for default color schemes. | [
"Restore",
"initial",
"values",
"for",
"default",
"color",
"schemes",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L432-L443 |
31,211 | spyder-ide/spyder | spyder/preferences/appearance.py | SchemeEditor.set_scheme | def set_scheme(self, scheme_name):
"""Set the current stack by 'scheme_name'."""
self.stack.setCurrentIndex(self.order.index(scheme_name))
self.last_used_scheme = scheme_name | python | def set_scheme(self, scheme_name):
"""Set the current stack by 'scheme_name'."""
self.stack.setCurrentIndex(self.order.index(scheme_name))
self.last_used_scheme = scheme_name | [
"def",
"set_scheme",
"(",
"self",
",",
"scheme_name",
")",
":",
"self",
".",
"stack",
".",
"setCurrentIndex",
"(",
"self",
".",
"order",
".",
"index",
"(",
"scheme_name",
")",
")",
"self",
".",
"last_used_scheme",
"=",
"scheme_name"
] | Set the current stack by 'scheme_name'. | [
"Set",
"the",
"current",
"stack",
"by",
"scheme_name",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L476-L479 |
31,212 | spyder-ide/spyder | spyder/preferences/appearance.py | SchemeEditor.get_edited_color_scheme | def get_edited_color_scheme(self):
"""
Get the values of the last edited color scheme to be used in an instant
preview in the preview editor, without using `apply`.
"""
color_scheme = {}
scheme_name = self.last_used_scheme
for key in self.widgets[scheme_name]:
items = self.widgets[scheme_name][key]
if len(items) == 1:
# ColorLayout
value = items[0].text()
else:
# ColorLayout + checkboxes
value = (items[0].text(), items[1].isChecked(),
items[2].isChecked())
color_scheme[key] = value
return color_scheme | python | def get_edited_color_scheme(self):
"""
Get the values of the last edited color scheme to be used in an instant
preview in the preview editor, without using `apply`.
"""
color_scheme = {}
scheme_name = self.last_used_scheme
for key in self.widgets[scheme_name]:
items = self.widgets[scheme_name][key]
if len(items) == 1:
# ColorLayout
value = items[0].text()
else:
# ColorLayout + checkboxes
value = (items[0].text(), items[1].isChecked(),
items[2].isChecked())
color_scheme[key] = value
return color_scheme | [
"def",
"get_edited_color_scheme",
"(",
"self",
")",
":",
"color_scheme",
"=",
"{",
"}",
"scheme_name",
"=",
"self",
".",
"last_used_scheme",
"for",
"key",
"in",
"self",
".",
"widgets",
"[",
"scheme_name",
"]",
":",
"items",
"=",
"self",
".",
"widgets",
"["... | Get the values of the last edited color scheme to be used in an instant
preview in the preview editor, without using `apply`. | [
"Get",
"the",
"values",
"of",
"the",
"last",
"edited",
"color",
"scheme",
"to",
"be",
"used",
"in",
"an",
"instant",
"preview",
"in",
"the",
"preview",
"editor",
"without",
"using",
"apply",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L488-L509 |
31,213 | spyder-ide/spyder | spyder/preferences/appearance.py | SchemeEditor.add_color_scheme_stack | def add_color_scheme_stack(self, scheme_name, custom=False):
"""Add a stack for a given scheme and connects the CONF values."""
color_scheme_groups = [
(_('Text'), ["normal", "comment", "string", "number", "keyword",
"builtin", "definition", "instance", ]),
(_('Highlight'), ["currentcell", "currentline", "occurrence",
"matched_p", "unmatched_p", "ctrlclick"]),
(_('Background'), ["background", "sideareas"])
]
parent = self.parent
line_edit = parent.create_lineedit(_("Scheme name:"),
'{0}/name'.format(scheme_name))
self.widgets[scheme_name] = {}
# Widget setup
line_edit.label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
self.setWindowTitle(_('Color scheme editor'))
# Layout
name_layout = QHBoxLayout()
name_layout.addWidget(line_edit.label)
name_layout.addWidget(line_edit.textbox)
self.scheme_name_textbox[scheme_name] = line_edit.textbox
if not custom:
line_edit.textbox.setDisabled(True)
if not self.isVisible():
line_edit.setVisible(False)
cs_layout = QVBoxLayout()
cs_layout.addLayout(name_layout)
h_layout = QHBoxLayout()
v_layout = QVBoxLayout()
for index, item in enumerate(color_scheme_groups):
group_name, keys = item
group_layout = QGridLayout()
for row, key in enumerate(keys):
option = "{0}/{1}".format(scheme_name, key)
value = self.parent.get_option(option)
name = syntaxhighlighters.COLOR_SCHEME_KEYS[key]
if is_text_string(value):
label, clayout = parent.create_coloredit(
name,
option,
without_layout=True,
)
label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
group_layout.addWidget(label, row+1, 0)
group_layout.addLayout(clayout, row+1, 1)
# Needed to update temp scheme to obtain instant preview
self.widgets[scheme_name][key] = [clayout]
else:
label, clayout, cb_bold, cb_italic = parent.create_scedit(
name,
option,
without_layout=True,
)
label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
group_layout.addWidget(label, row+1, 0)
group_layout.addLayout(clayout, row+1, 1)
group_layout.addWidget(cb_bold, row+1, 2)
group_layout.addWidget(cb_italic, row+1, 3)
# Needed to update temp scheme to obtain instant preview
self.widgets[scheme_name][key] = [clayout, cb_bold,
cb_italic]
group_box = QGroupBox(group_name)
group_box.setLayout(group_layout)
if index == 0:
h_layout.addWidget(group_box)
else:
v_layout.addWidget(group_box)
h_layout.addLayout(v_layout)
cs_layout.addLayout(h_layout)
stackitem = QWidget()
stackitem.setLayout(cs_layout)
self.stack.addWidget(stackitem)
self.order.append(scheme_name) | python | def add_color_scheme_stack(self, scheme_name, custom=False):
"""Add a stack for a given scheme and connects the CONF values."""
color_scheme_groups = [
(_('Text'), ["normal", "comment", "string", "number", "keyword",
"builtin", "definition", "instance", ]),
(_('Highlight'), ["currentcell", "currentline", "occurrence",
"matched_p", "unmatched_p", "ctrlclick"]),
(_('Background'), ["background", "sideareas"])
]
parent = self.parent
line_edit = parent.create_lineedit(_("Scheme name:"),
'{0}/name'.format(scheme_name))
self.widgets[scheme_name] = {}
# Widget setup
line_edit.label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
self.setWindowTitle(_('Color scheme editor'))
# Layout
name_layout = QHBoxLayout()
name_layout.addWidget(line_edit.label)
name_layout.addWidget(line_edit.textbox)
self.scheme_name_textbox[scheme_name] = line_edit.textbox
if not custom:
line_edit.textbox.setDisabled(True)
if not self.isVisible():
line_edit.setVisible(False)
cs_layout = QVBoxLayout()
cs_layout.addLayout(name_layout)
h_layout = QHBoxLayout()
v_layout = QVBoxLayout()
for index, item in enumerate(color_scheme_groups):
group_name, keys = item
group_layout = QGridLayout()
for row, key in enumerate(keys):
option = "{0}/{1}".format(scheme_name, key)
value = self.parent.get_option(option)
name = syntaxhighlighters.COLOR_SCHEME_KEYS[key]
if is_text_string(value):
label, clayout = parent.create_coloredit(
name,
option,
without_layout=True,
)
label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
group_layout.addWidget(label, row+1, 0)
group_layout.addLayout(clayout, row+1, 1)
# Needed to update temp scheme to obtain instant preview
self.widgets[scheme_name][key] = [clayout]
else:
label, clayout, cb_bold, cb_italic = parent.create_scedit(
name,
option,
without_layout=True,
)
label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
group_layout.addWidget(label, row+1, 0)
group_layout.addLayout(clayout, row+1, 1)
group_layout.addWidget(cb_bold, row+1, 2)
group_layout.addWidget(cb_italic, row+1, 3)
# Needed to update temp scheme to obtain instant preview
self.widgets[scheme_name][key] = [clayout, cb_bold,
cb_italic]
group_box = QGroupBox(group_name)
group_box.setLayout(group_layout)
if index == 0:
h_layout.addWidget(group_box)
else:
v_layout.addWidget(group_box)
h_layout.addLayout(v_layout)
cs_layout.addLayout(h_layout)
stackitem = QWidget()
stackitem.setLayout(cs_layout)
self.stack.addWidget(stackitem)
self.order.append(scheme_name) | [
"def",
"add_color_scheme_stack",
"(",
"self",
",",
"scheme_name",
",",
"custom",
"=",
"False",
")",
":",
"color_scheme_groups",
"=",
"[",
"(",
"_",
"(",
"'Text'",
")",
",",
"[",
"\"normal\"",
",",
"\"comment\"",
",",
"\"string\"",
",",
"\"number\"",
",",
"... | Add a stack for a given scheme and connects the CONF values. | [
"Add",
"a",
"stack",
"for",
"a",
"given",
"scheme",
"and",
"connects",
"the",
"CONF",
"values",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L513-L601 |
31,214 | spyder-ide/spyder | spyder/preferences/appearance.py | SchemeEditor.delete_color_scheme_stack | def delete_color_scheme_stack(self, scheme_name):
"""Remove stack widget by 'scheme_name'."""
self.set_scheme(scheme_name)
widget = self.stack.currentWidget()
self.stack.removeWidget(widget)
index = self.order.index(scheme_name)
self.order.pop(index) | python | def delete_color_scheme_stack(self, scheme_name):
"""Remove stack widget by 'scheme_name'."""
self.set_scheme(scheme_name)
widget = self.stack.currentWidget()
self.stack.removeWidget(widget)
index = self.order.index(scheme_name)
self.order.pop(index) | [
"def",
"delete_color_scheme_stack",
"(",
"self",
",",
"scheme_name",
")",
":",
"self",
".",
"set_scheme",
"(",
"scheme_name",
")",
"widget",
"=",
"self",
".",
"stack",
".",
"currentWidget",
"(",
")",
"self",
".",
"stack",
".",
"removeWidget",
"(",
"widget",
... | Remove stack widget by 'scheme_name'. | [
"Remove",
"stack",
"widget",
"by",
"scheme_name",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/appearance.py#L603-L609 |
31,215 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.switch_to_plugin | def switch_to_plugin(self):
"""Switch to plugin."""
# Unmaxizime currently maximized plugin
if (self.main.last_plugin is not None and
self.main.last_plugin.ismaximized and
self.main.last_plugin is not self):
self.main.maximize_dockwidget()
# Show plugin only if it was already visible
if self.get_option('visible_if_project_open'):
if not self.toggle_view_action.isChecked():
self.toggle_view_action.setChecked(True)
self.visibility_changed(True) | python | def switch_to_plugin(self):
"""Switch to plugin."""
# Unmaxizime currently maximized plugin
if (self.main.last_plugin is not None and
self.main.last_plugin.ismaximized and
self.main.last_plugin is not self):
self.main.maximize_dockwidget()
# Show plugin only if it was already visible
if self.get_option('visible_if_project_open'):
if not self.toggle_view_action.isChecked():
self.toggle_view_action.setChecked(True)
self.visibility_changed(True) | [
"def",
"switch_to_plugin",
"(",
"self",
")",
":",
"# Unmaxizime currently maximized plugin\r",
"if",
"(",
"self",
".",
"main",
".",
"last_plugin",
"is",
"not",
"None",
"and",
"self",
".",
"main",
".",
"last_plugin",
".",
"ismaximized",
"and",
"self",
".",
"mai... | Switch to plugin. | [
"Switch",
"to",
"plugin",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L178-L190 |
31,216 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.update_project_actions | def update_project_actions(self):
"""Update actions of the Projects menu"""
if self.recent_projects:
self.clear_recent_projects_action.setEnabled(True)
else:
self.clear_recent_projects_action.setEnabled(False)
active = bool(self.get_active_project_path())
self.close_project_action.setEnabled(active)
self.delete_project_action.setEnabled(active)
self.edit_project_preferences_action.setEnabled(active) | python | def update_project_actions(self):
"""Update actions of the Projects menu"""
if self.recent_projects:
self.clear_recent_projects_action.setEnabled(True)
else:
self.clear_recent_projects_action.setEnabled(False)
active = bool(self.get_active_project_path())
self.close_project_action.setEnabled(active)
self.delete_project_action.setEnabled(active)
self.edit_project_preferences_action.setEnabled(active) | [
"def",
"update_project_actions",
"(",
"self",
")",
":",
"if",
"self",
".",
"recent_projects",
":",
"self",
".",
"clear_recent_projects_action",
".",
"setEnabled",
"(",
"True",
")",
"else",
":",
"self",
".",
"clear_recent_projects_action",
".",
"setEnabled",
"(",
... | Update actions of the Projects menu | [
"Update",
"actions",
"of",
"the",
"Projects",
"menu"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L218-L228 |
31,217 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.edit_project_preferences | def edit_project_preferences(self):
"""Edit Spyder active project preferences"""
from spyder.plugins.projects.confpage import ProjectPreferences
if self.project_active:
active_project = self.project_list[0]
dlg = ProjectPreferences(self, active_project)
# dlg.size_change.connect(self.set_project_prefs_size)
# if self.projects_prefs_dialog_size is not None:
# dlg.resize(self.projects_prefs_dialog_size)
dlg.show()
# dlg.check_all_settings()
# dlg.pages_widget.currentChanged.connect(self.__preference_page_changed)
dlg.exec_() | python | def edit_project_preferences(self):
"""Edit Spyder active project preferences"""
from spyder.plugins.projects.confpage import ProjectPreferences
if self.project_active:
active_project = self.project_list[0]
dlg = ProjectPreferences(self, active_project)
# dlg.size_change.connect(self.set_project_prefs_size)
# if self.projects_prefs_dialog_size is not None:
# dlg.resize(self.projects_prefs_dialog_size)
dlg.show()
# dlg.check_all_settings()
# dlg.pages_widget.currentChanged.connect(self.__preference_page_changed)
dlg.exec_() | [
"def",
"edit_project_preferences",
"(",
"self",
")",
":",
"from",
"spyder",
".",
"plugins",
".",
"projects",
".",
"confpage",
"import",
"ProjectPreferences",
"if",
"self",
".",
"project_active",
":",
"active_project",
"=",
"self",
".",
"project_list",
"[",
"0",
... | Edit Spyder active project preferences | [
"Edit",
"Spyder",
"active",
"project",
"preferences"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L230-L242 |
31,218 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.create_new_project | def create_new_project(self):
"""Create new project"""
self.switch_to_plugin()
active_project = self.current_active_project
dlg = ProjectDialog(self)
dlg.sig_project_creation_requested.connect(self._create_project)
dlg.sig_project_creation_requested.connect(self.sig_project_created)
if dlg.exec_():
if (active_project is None
and self.get_option('visible_if_project_open')):
self.show_explorer()
self.sig_pythonpath_changed.emit()
self.restart_consoles() | python | def create_new_project(self):
"""Create new project"""
self.switch_to_plugin()
active_project = self.current_active_project
dlg = ProjectDialog(self)
dlg.sig_project_creation_requested.connect(self._create_project)
dlg.sig_project_creation_requested.connect(self.sig_project_created)
if dlg.exec_():
if (active_project is None
and self.get_option('visible_if_project_open')):
self.show_explorer()
self.sig_pythonpath_changed.emit()
self.restart_consoles() | [
"def",
"create_new_project",
"(",
"self",
")",
":",
"self",
".",
"switch_to_plugin",
"(",
")",
"active_project",
"=",
"self",
".",
"current_active_project",
"dlg",
"=",
"ProjectDialog",
"(",
"self",
")",
"dlg",
".",
"sig_project_creation_requested",
".",
"connect"... | Create new project | [
"Create",
"new",
"project"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L245-L257 |
31,219 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.open_project | def open_project(self, path=None, restart_consoles=True,
save_previous_files=True):
"""Open the project located in `path`"""
self.switch_to_plugin()
if path is None:
basedir = get_home_dir()
path = getexistingdirectory(parent=self,
caption=_("Open project"),
basedir=basedir)
path = encoding.to_unicode_from_fs(path)
if not self.is_valid_project(path):
if path:
QMessageBox.critical(self, _('Error'),
_("<b>%s</b> is not a Spyder project!") % path)
return
else:
path = encoding.to_unicode_from_fs(path)
self.add_to_recent(path)
# A project was not open before
if self.current_active_project is None:
if save_previous_files and self.main.editor is not None:
self.main.editor.save_open_files()
if self.main.editor is not None:
self.main.editor.set_option('last_working_dir',
getcwd_or_home())
if self.get_option('visible_if_project_open'):
self.show_explorer()
else:
# We are switching projects
if self.main.editor is not None:
self.set_project_filenames(
self.main.editor.get_open_filenames())
self.current_active_project = EmptyProject(path)
self.latest_project = EmptyProject(path)
self.set_option('current_project_path', self.get_active_project_path())
self.setup_menu_actions()
self.sig_project_loaded.emit(path)
self.sig_pythonpath_changed.emit()
if restart_consoles:
self.restart_consoles() | python | def open_project(self, path=None, restart_consoles=True,
save_previous_files=True):
"""Open the project located in `path`"""
self.switch_to_plugin()
if path is None:
basedir = get_home_dir()
path = getexistingdirectory(parent=self,
caption=_("Open project"),
basedir=basedir)
path = encoding.to_unicode_from_fs(path)
if not self.is_valid_project(path):
if path:
QMessageBox.critical(self, _('Error'),
_("<b>%s</b> is not a Spyder project!") % path)
return
else:
path = encoding.to_unicode_from_fs(path)
self.add_to_recent(path)
# A project was not open before
if self.current_active_project is None:
if save_previous_files and self.main.editor is not None:
self.main.editor.save_open_files()
if self.main.editor is not None:
self.main.editor.set_option('last_working_dir',
getcwd_or_home())
if self.get_option('visible_if_project_open'):
self.show_explorer()
else:
# We are switching projects
if self.main.editor is not None:
self.set_project_filenames(
self.main.editor.get_open_filenames())
self.current_active_project = EmptyProject(path)
self.latest_project = EmptyProject(path)
self.set_option('current_project_path', self.get_active_project_path())
self.setup_menu_actions()
self.sig_project_loaded.emit(path)
self.sig_pythonpath_changed.emit()
if restart_consoles:
self.restart_consoles() | [
"def",
"open_project",
"(",
"self",
",",
"path",
"=",
"None",
",",
"restart_consoles",
"=",
"True",
",",
"save_previous_files",
"=",
"True",
")",
":",
"self",
".",
"switch_to_plugin",
"(",
")",
"if",
"path",
"is",
"None",
":",
"basedir",
"=",
"get_home_dir... | Open the project located in `path` | [
"Open",
"the",
"project",
"located",
"in",
"path"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L265-L309 |
31,220 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.close_project | def close_project(self):
"""
Close current project and return to a window without an active
project
"""
if self.current_active_project:
self.switch_to_plugin()
if self.main.editor is not None:
self.set_project_filenames(
self.main.editor.get_open_filenames())
path = self.current_active_project.root_path
self.current_active_project = None
self.set_option('current_project_path', None)
self.setup_menu_actions()
self.sig_project_closed.emit(path)
self.sig_pythonpath_changed.emit()
if self.dockwidget is not None:
self.set_option('visible_if_project_open',
self.dockwidget.isVisible())
self.dockwidget.close()
self.explorer.clear()
self.restart_consoles() | python | def close_project(self):
"""
Close current project and return to a window without an active
project
"""
if self.current_active_project:
self.switch_to_plugin()
if self.main.editor is not None:
self.set_project_filenames(
self.main.editor.get_open_filenames())
path = self.current_active_project.root_path
self.current_active_project = None
self.set_option('current_project_path', None)
self.setup_menu_actions()
self.sig_project_closed.emit(path)
self.sig_pythonpath_changed.emit()
if self.dockwidget is not None:
self.set_option('visible_if_project_open',
self.dockwidget.isVisible())
self.dockwidget.close()
self.explorer.clear()
self.restart_consoles() | [
"def",
"close_project",
"(",
"self",
")",
":",
"if",
"self",
".",
"current_active_project",
":",
"self",
".",
"switch_to_plugin",
"(",
")",
"if",
"self",
".",
"main",
".",
"editor",
"is",
"not",
"None",
":",
"self",
".",
"set_project_filenames",
"(",
"self... | Close current project and return to a window without an active
project | [
"Close",
"current",
"project",
"and",
"return",
"to",
"a",
"window",
"without",
"an",
"active",
"project"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L311-L335 |
31,221 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.delete_project | def delete_project(self):
"""
Delete the current project without deleting the files in the directory.
"""
if self.current_active_project:
self.switch_to_plugin()
path = self.current_active_project.root_path
buttons = QMessageBox.Yes | QMessageBox.No
answer = QMessageBox.warning(
self,
_("Delete"),
_("Do you really want to delete <b>{filename}</b>?<br><br>"
"<b>Note:</b> This action will only delete the project. "
"Its files are going to be preserved on disk."
).format(filename=osp.basename(path)),
buttons)
if answer == QMessageBox.Yes:
try:
self.close_project()
shutil.rmtree(osp.join(path, '.spyproject'))
except EnvironmentError as error:
QMessageBox.critical(
self,
_("Project Explorer"),
_("<b>Unable to delete <i>{varpath}</i></b>"
"<br><br>The error message was:<br>{error}"
).format(varpath=path, error=to_text_string(error))) | python | def delete_project(self):
"""
Delete the current project without deleting the files in the directory.
"""
if self.current_active_project:
self.switch_to_plugin()
path = self.current_active_project.root_path
buttons = QMessageBox.Yes | QMessageBox.No
answer = QMessageBox.warning(
self,
_("Delete"),
_("Do you really want to delete <b>{filename}</b>?<br><br>"
"<b>Note:</b> This action will only delete the project. "
"Its files are going to be preserved on disk."
).format(filename=osp.basename(path)),
buttons)
if answer == QMessageBox.Yes:
try:
self.close_project()
shutil.rmtree(osp.join(path, '.spyproject'))
except EnvironmentError as error:
QMessageBox.critical(
self,
_("Project Explorer"),
_("<b>Unable to delete <i>{varpath}</i></b>"
"<br><br>The error message was:<br>{error}"
).format(varpath=path, error=to_text_string(error))) | [
"def",
"delete_project",
"(",
"self",
")",
":",
"if",
"self",
".",
"current_active_project",
":",
"self",
".",
"switch_to_plugin",
"(",
")",
"path",
"=",
"self",
".",
"current_active_project",
".",
"root_path",
"buttons",
"=",
"QMessageBox",
".",
"Yes",
"|",
... | Delete the current project without deleting the files in the directory. | [
"Delete",
"the",
"current",
"project",
"without",
"deleting",
"the",
"files",
"in",
"the",
"directory",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L337-L363 |
31,222 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.reopen_last_project | def reopen_last_project(self):
"""
Reopen the active project when Spyder was closed last time, if any
"""
current_project_path = self.get_option('current_project_path',
default=None)
# Needs a safer test of project existence!
if current_project_path and \
self.is_valid_project(current_project_path):
self.open_project(path=current_project_path,
restart_consoles=False,
save_previous_files=False)
self.load_config() | python | def reopen_last_project(self):
"""
Reopen the active project when Spyder was closed last time, if any
"""
current_project_path = self.get_option('current_project_path',
default=None)
# Needs a safer test of project existence!
if current_project_path and \
self.is_valid_project(current_project_path):
self.open_project(path=current_project_path,
restart_consoles=False,
save_previous_files=False)
self.load_config() | [
"def",
"reopen_last_project",
"(",
"self",
")",
":",
"current_project_path",
"=",
"self",
".",
"get_option",
"(",
"'current_project_path'",
",",
"default",
"=",
"None",
")",
"# Needs a safer test of project existence!\r",
"if",
"current_project_path",
"and",
"self",
"."... | Reopen the active project when Spyder was closed last time, if any | [
"Reopen",
"the",
"active",
"project",
"when",
"Spyder",
"was",
"closed",
"last",
"time",
"if",
"any"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L374-L387 |
31,223 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.get_project_filenames | def get_project_filenames(self):
"""Get the list of recent filenames of a project"""
recent_files = []
if self.current_active_project:
recent_files = self.current_active_project.get_recent_files()
elif self.latest_project:
recent_files = self.latest_project.get_recent_files()
return recent_files | python | def get_project_filenames(self):
"""Get the list of recent filenames of a project"""
recent_files = []
if self.current_active_project:
recent_files = self.current_active_project.get_recent_files()
elif self.latest_project:
recent_files = self.latest_project.get_recent_files()
return recent_files | [
"def",
"get_project_filenames",
"(",
"self",
")",
":",
"recent_files",
"=",
"[",
"]",
"if",
"self",
".",
"current_active_project",
":",
"recent_files",
"=",
"self",
".",
"current_active_project",
".",
"get_recent_files",
"(",
")",
"elif",
"self",
".",
"latest_pr... | Get the list of recent filenames of a project | [
"Get",
"the",
"list",
"of",
"recent",
"filenames",
"of",
"a",
"project"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L389-L396 |
31,224 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.set_project_filenames | def set_project_filenames(self, recent_files):
"""Set the list of open file names in a project"""
if (self.current_active_project
and self.is_valid_project(
self.current_active_project.root_path)):
self.current_active_project.set_recent_files(recent_files) | python | def set_project_filenames(self, recent_files):
"""Set the list of open file names in a project"""
if (self.current_active_project
and self.is_valid_project(
self.current_active_project.root_path)):
self.current_active_project.set_recent_files(recent_files) | [
"def",
"set_project_filenames",
"(",
"self",
",",
"recent_files",
")",
":",
"if",
"(",
"self",
".",
"current_active_project",
"and",
"self",
".",
"is_valid_project",
"(",
"self",
".",
"current_active_project",
".",
"root_path",
")",
")",
":",
"self",
".",
"cur... | Set the list of open file names in a project | [
"Set",
"the",
"list",
"of",
"open",
"file",
"names",
"in",
"a",
"project"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L398-L403 |
31,225 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.get_active_project_path | def get_active_project_path(self):
"""Get path of the active project"""
active_project_path = None
if self.current_active_project:
active_project_path = self.current_active_project.root_path
return active_project_path | python | def get_active_project_path(self):
"""Get path of the active project"""
active_project_path = None
if self.current_active_project:
active_project_path = self.current_active_project.root_path
return active_project_path | [
"def",
"get_active_project_path",
"(",
"self",
")",
":",
"active_project_path",
"=",
"None",
"if",
"self",
".",
"current_active_project",
":",
"active_project_path",
"=",
"self",
".",
"current_active_project",
".",
"root_path",
"return",
"active_project_path"
] | Get path of the active project | [
"Get",
"path",
"of",
"the",
"active",
"project"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L405-L410 |
31,226 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.get_pythonpath | def get_pythonpath(self, at_start=False):
"""Get project path as a list to be added to PYTHONPATH"""
if at_start:
current_path = self.get_option('current_project_path',
default=None)
else:
current_path = self.get_active_project_path()
if current_path is None:
return []
else:
return [current_path] | python | def get_pythonpath(self, at_start=False):
"""Get project path as a list to be added to PYTHONPATH"""
if at_start:
current_path = self.get_option('current_project_path',
default=None)
else:
current_path = self.get_active_project_path()
if current_path is None:
return []
else:
return [current_path] | [
"def",
"get_pythonpath",
"(",
"self",
",",
"at_start",
"=",
"False",
")",
":",
"if",
"at_start",
":",
"current_path",
"=",
"self",
".",
"get_option",
"(",
"'current_project_path'",
",",
"default",
"=",
"None",
")",
"else",
":",
"current_path",
"=",
"self",
... | Get project path as a list to be added to PYTHONPATH | [
"Get",
"project",
"path",
"as",
"a",
"list",
"to",
"be",
"added",
"to",
"PYTHONPATH"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L412-L422 |
31,227 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.show_explorer | def show_explorer(self):
"""Show the explorer"""
if self.dockwidget is not None:
if self.dockwidget.isHidden():
self.dockwidget.show()
self.dockwidget.raise_()
self.dockwidget.update() | python | def show_explorer(self):
"""Show the explorer"""
if self.dockwidget is not None:
if self.dockwidget.isHidden():
self.dockwidget.show()
self.dockwidget.raise_()
self.dockwidget.update() | [
"def",
"show_explorer",
"(",
"self",
")",
":",
"if",
"self",
".",
"dockwidget",
"is",
"not",
"None",
":",
"if",
"self",
".",
"dockwidget",
".",
"isHidden",
"(",
")",
":",
"self",
".",
"dockwidget",
".",
"show",
"(",
")",
"self",
".",
"dockwidget",
".... | Show the explorer | [
"Show",
"the",
"explorer"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L465-L471 |
31,228 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.is_valid_project | def is_valid_project(self, path):
"""Check if a directory is a valid Spyder project"""
spy_project_dir = osp.join(path, '.spyproject')
if osp.isdir(path) and osp.isdir(spy_project_dir):
return True
else:
return False | python | def is_valid_project(self, path):
"""Check if a directory is a valid Spyder project"""
spy_project_dir = osp.join(path, '.spyproject')
if osp.isdir(path) and osp.isdir(spy_project_dir):
return True
else:
return False | [
"def",
"is_valid_project",
"(",
"self",
",",
"path",
")",
":",
"spy_project_dir",
"=",
"osp",
".",
"join",
"(",
"path",
",",
"'.spyproject'",
")",
"if",
"osp",
".",
"isdir",
"(",
"path",
")",
"and",
"osp",
".",
"isdir",
"(",
"spy_project_dir",
")",
":"... | Check if a directory is a valid Spyder project | [
"Check",
"if",
"a",
"directory",
"is",
"a",
"valid",
"Spyder",
"project"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L478-L484 |
31,229 | spyder-ide/spyder | spyder/plugins/projects/plugin.py | Projects.add_to_recent | def add_to_recent(self, project):
"""
Add an entry to recent projetcs
We only maintain the list of the 10 most recent projects
"""
if project not in self.recent_projects:
self.recent_projects.insert(0, project)
self.recent_projects = self.recent_projects[:10] | python | def add_to_recent(self, project):
"""
Add an entry to recent projetcs
We only maintain the list of the 10 most recent projects
"""
if project not in self.recent_projects:
self.recent_projects.insert(0, project)
self.recent_projects = self.recent_projects[:10] | [
"def",
"add_to_recent",
"(",
"self",
",",
"project",
")",
":",
"if",
"project",
"not",
"in",
"self",
".",
"recent_projects",
":",
"self",
".",
"recent_projects",
".",
"insert",
"(",
"0",
",",
"project",
")",
"self",
".",
"recent_projects",
"=",
"self",
"... | Add an entry to recent projetcs
We only maintain the list of the 10 most recent projects | [
"Add",
"an",
"entry",
"to",
"recent",
"projetcs",
"We",
"only",
"maintain",
"the",
"list",
"of",
"the",
"10",
"most",
"recent",
"projects"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/projects/plugin.py#L486-L494 |
31,230 | spyder-ide/spyder | spyder/config/gui.py | get_family | def get_family(families):
"""Return the first installed font family in family list"""
if not isinstance(families, list):
families = [ families ]
for family in families:
if font_is_installed(family):
return family
else:
print("Warning: None of the following fonts is installed: %r" % families) # spyder: test-skip
return QFont().family() | python | def get_family(families):
"""Return the first installed font family in family list"""
if not isinstance(families, list):
families = [ families ]
for family in families:
if font_is_installed(family):
return family
else:
print("Warning: None of the following fonts is installed: %r" % families) # spyder: test-skip
return QFont().family() | [
"def",
"get_family",
"(",
"families",
")",
":",
"if",
"not",
"isinstance",
"(",
"families",
",",
"list",
")",
":",
"families",
"=",
"[",
"families",
"]",
"for",
"family",
"in",
"families",
":",
"if",
"font_is_installed",
"(",
"family",
")",
":",
"return"... | Return the first installed font family in family list | [
"Return",
"the",
"first",
"installed",
"font",
"family",
"in",
"family",
"list"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/gui.py#L45-L54 |
31,231 | spyder-ide/spyder | spyder/config/gui.py | get_font | def get_font(section='appearance', option='font', font_size_delta=0):
"""Get console font properties depending on OS and user options"""
font = FONT_CACHE.get((section, option))
if font is None:
families = CONF.get(section, option+"/family", None)
if families is None:
return QFont()
family = get_family(families)
weight = QFont.Normal
italic = CONF.get(section, option+'/italic', False)
if CONF.get(section, option+'/bold', False):
weight = QFont.Bold
size = CONF.get(section, option+'/size', 9) + font_size_delta
font = QFont(family, size, weight)
font.setItalic(italic)
FONT_CACHE[(section, option)] = font
size = CONF.get(section, option+'/size', 9) + font_size_delta
font.setPointSize(size)
return font | python | def get_font(section='appearance', option='font', font_size_delta=0):
"""Get console font properties depending on OS and user options"""
font = FONT_CACHE.get((section, option))
if font is None:
families = CONF.get(section, option+"/family", None)
if families is None:
return QFont()
family = get_family(families)
weight = QFont.Normal
italic = CONF.get(section, option+'/italic', False)
if CONF.get(section, option+'/bold', False):
weight = QFont.Bold
size = CONF.get(section, option+'/size', 9) + font_size_delta
font = QFont(family, size, weight)
font.setItalic(italic)
FONT_CACHE[(section, option)] = font
size = CONF.get(section, option+'/size', 9) + font_size_delta
font.setPointSize(size)
return font | [
"def",
"get_font",
"(",
"section",
"=",
"'appearance'",
",",
"option",
"=",
"'font'",
",",
"font_size_delta",
"=",
"0",
")",
":",
"font",
"=",
"FONT_CACHE",
".",
"get",
"(",
"(",
"section",
",",
"option",
")",
")",
"if",
"font",
"is",
"None",
":",
"f... | Get console font properties depending on OS and user options | [
"Get",
"console",
"font",
"properties",
"depending",
"on",
"OS",
"and",
"user",
"options"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/gui.py#L59-L83 |
31,232 | spyder-ide/spyder | spyder/config/gui.py | config_shortcut | def config_shortcut(action, context, name, parent):
"""
Create a Shortcut namedtuple for a widget
The data contained in this tuple will be registered in
our shortcuts preferences page
"""
keystr = get_shortcut(context, name)
qsc = QShortcut(QKeySequence(keystr), parent, action)
qsc.setContext(Qt.WidgetWithChildrenShortcut)
sc = Shortcut(data=(qsc, context, name))
return sc | python | def config_shortcut(action, context, name, parent):
"""
Create a Shortcut namedtuple for a widget
The data contained in this tuple will be registered in
our shortcuts preferences page
"""
keystr = get_shortcut(context, name)
qsc = QShortcut(QKeySequence(keystr), parent, action)
qsc.setContext(Qt.WidgetWithChildrenShortcut)
sc = Shortcut(data=(qsc, context, name))
return sc | [
"def",
"config_shortcut",
"(",
"action",
",",
"context",
",",
"name",
",",
"parent",
")",
":",
"keystr",
"=",
"get_shortcut",
"(",
"context",
",",
"name",
")",
"qsc",
"=",
"QShortcut",
"(",
"QKeySequence",
"(",
"keystr",
")",
",",
"parent",
",",
"action"... | Create a Shortcut namedtuple for a widget
The data contained in this tuple will be registered in
our shortcuts preferences page | [
"Create",
"a",
"Shortcut",
"namedtuple",
"for",
"a",
"widget",
"The",
"data",
"contained",
"in",
"this",
"tuple",
"will",
"be",
"registered",
"in",
"our",
"shortcuts",
"preferences",
"page"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/gui.py#L116-L127 |
31,233 | spyder-ide/spyder | spyder/config/gui.py | iter_shortcuts | def iter_shortcuts():
"""Iterate over keyboard shortcuts."""
for context_name, keystr in CONF.items('shortcuts'):
context, name = context_name.split("/", 1)
yield context, name, keystr | python | def iter_shortcuts():
"""Iterate over keyboard shortcuts."""
for context_name, keystr in CONF.items('shortcuts'):
context, name = context_name.split("/", 1)
yield context, name, keystr | [
"def",
"iter_shortcuts",
"(",
")",
":",
"for",
"context_name",
",",
"keystr",
"in",
"CONF",
".",
"items",
"(",
"'shortcuts'",
")",
":",
"context",
",",
"name",
"=",
"context_name",
".",
"split",
"(",
"\"/\"",
",",
"1",
")",
"yield",
"context",
",",
"na... | Iterate over keyboard shortcuts. | [
"Iterate",
"over",
"keyboard",
"shortcuts",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/gui.py#L130-L134 |
31,234 | spyder-ide/spyder | spyder/config/gui.py | get_color_scheme | def get_color_scheme(name):
"""Get syntax color scheme"""
color_scheme = {}
for key in sh.COLOR_SCHEME_KEYS:
color_scheme[key] = CONF.get("appearance", "%s/%s" % (name, key))
return color_scheme | python | def get_color_scheme(name):
"""Get syntax color scheme"""
color_scheme = {}
for key in sh.COLOR_SCHEME_KEYS:
color_scheme[key] = CONF.get("appearance", "%s/%s" % (name, key))
return color_scheme | [
"def",
"get_color_scheme",
"(",
"name",
")",
":",
"color_scheme",
"=",
"{",
"}",
"for",
"key",
"in",
"sh",
".",
"COLOR_SCHEME_KEYS",
":",
"color_scheme",
"[",
"key",
"]",
"=",
"CONF",
".",
"get",
"(",
"\"appearance\"",
",",
"\"%s/%s\"",
"%",
"(",
"name",... | Get syntax color scheme | [
"Get",
"syntax",
"color",
"scheme"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/gui.py#L142-L147 |
31,235 | spyder-ide/spyder | spyder/config/gui.py | set_color_scheme | def set_color_scheme(name, color_scheme, replace=True):
"""Set syntax color scheme"""
section = "appearance"
names = CONF.get("appearance", "names", [])
for key in sh.COLOR_SCHEME_KEYS:
option = "%s/%s" % (name, key)
value = CONF.get(section, option, default=None)
if value is None or replace or name not in names:
CONF.set(section, option, color_scheme[key])
names.append(to_text_string(name))
CONF.set(section, "names", sorted(list(set(names)))) | python | def set_color_scheme(name, color_scheme, replace=True):
"""Set syntax color scheme"""
section = "appearance"
names = CONF.get("appearance", "names", [])
for key in sh.COLOR_SCHEME_KEYS:
option = "%s/%s" % (name, key)
value = CONF.get(section, option, default=None)
if value is None or replace or name not in names:
CONF.set(section, option, color_scheme[key])
names.append(to_text_string(name))
CONF.set(section, "names", sorted(list(set(names)))) | [
"def",
"set_color_scheme",
"(",
"name",
",",
"color_scheme",
",",
"replace",
"=",
"True",
")",
":",
"section",
"=",
"\"appearance\"",
"names",
"=",
"CONF",
".",
"get",
"(",
"\"appearance\"",
",",
"\"names\"",
",",
"[",
"]",
")",
"for",
"key",
"in",
"sh",... | Set syntax color scheme | [
"Set",
"syntax",
"color",
"scheme"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/gui.py#L150-L160 |
31,236 | spyder-ide/spyder | spyder/config/gui.py | set_default_color_scheme | def set_default_color_scheme(name, replace=True):
"""Reset color scheme to default values"""
assert name in sh.COLOR_SCHEME_NAMES
set_color_scheme(name, sh.get_color_scheme(name), replace=replace) | python | def set_default_color_scheme(name, replace=True):
"""Reset color scheme to default values"""
assert name in sh.COLOR_SCHEME_NAMES
set_color_scheme(name, sh.get_color_scheme(name), replace=replace) | [
"def",
"set_default_color_scheme",
"(",
"name",
",",
"replace",
"=",
"True",
")",
":",
"assert",
"name",
"in",
"sh",
".",
"COLOR_SCHEME_NAMES",
"set_color_scheme",
"(",
"name",
",",
"sh",
".",
"get_color_scheme",
"(",
"name",
")",
",",
"replace",
"=",
"repla... | Reset color scheme to default values | [
"Reset",
"color",
"scheme",
"to",
"default",
"values"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/gui.py#L163-L166 |
31,237 | spyder-ide/spyder | spyder/config/gui.py | is_dark_font_color | def is_dark_font_color(color_scheme):
"""Check if the font color used in the color scheme is dark."""
color_scheme = get_color_scheme(color_scheme)
font_color, fon_fw, fon_fs = color_scheme['normal']
return dark_color(font_color) | python | def is_dark_font_color(color_scheme):
"""Check if the font color used in the color scheme is dark."""
color_scheme = get_color_scheme(color_scheme)
font_color, fon_fw, fon_fs = color_scheme['normal']
return dark_color(font_color) | [
"def",
"is_dark_font_color",
"(",
"color_scheme",
")",
":",
"color_scheme",
"=",
"get_color_scheme",
"(",
"color_scheme",
")",
"font_color",
",",
"fon_fw",
",",
"fon_fs",
"=",
"color_scheme",
"[",
"'normal'",
"]",
"return",
"dark_color",
"(",
"font_color",
")"
] | Check if the font color used in the color scheme is dark. | [
"Check",
"if",
"the",
"font",
"color",
"used",
"in",
"the",
"color",
"scheme",
"is",
"dark",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/gui.py#L169-L173 |
31,238 | spyder-ide/spyder | spyder/widgets/dock.py | TabFilter.eventFilter | def eventFilter(self, obj, event):
"""Filter mouse press events.
Events that are captured and not propagated return True. Events that
are not captured and are propagated return False.
"""
event_type = event.type()
if event_type == QEvent.MouseButtonPress:
self.tab_pressed(event)
return False
return False | python | def eventFilter(self, obj, event):
"""Filter mouse press events.
Events that are captured and not propagated return True. Events that
are not captured and are propagated return False.
"""
event_type = event.type()
if event_type == QEvent.MouseButtonPress:
self.tab_pressed(event)
return False
return False | [
"def",
"eventFilter",
"(",
"self",
",",
"obj",
",",
"event",
")",
":",
"event_type",
"=",
"event",
".",
"type",
"(",
")",
"if",
"event_type",
"==",
"QEvent",
".",
"MouseButtonPress",
":",
"self",
".",
"tab_pressed",
"(",
"event",
")",
"return",
"False",
... | Filter mouse press events.
Events that are captured and not propagated return True. Events that
are not captured and are propagated return False. | [
"Filter",
"mouse",
"press",
"events",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/dock.py#L32-L42 |
31,239 | spyder-ide/spyder | spyder/widgets/dock.py | TabFilter.tab_pressed | def tab_pressed(self, event):
"""Method called when a tab from a QTabBar has been pressed."""
self.from_index = self.dock_tabbar.tabAt(event.pos())
self.dock_tabbar.setCurrentIndex(self.from_index)
if event.button() == Qt.RightButton:
if self.from_index == -1:
self.show_nontab_menu(event)
else:
self.show_tab_menu(event) | python | def tab_pressed(self, event):
"""Method called when a tab from a QTabBar has been pressed."""
self.from_index = self.dock_tabbar.tabAt(event.pos())
self.dock_tabbar.setCurrentIndex(self.from_index)
if event.button() == Qt.RightButton:
if self.from_index == -1:
self.show_nontab_menu(event)
else:
self.show_tab_menu(event) | [
"def",
"tab_pressed",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"from_index",
"=",
"self",
".",
"dock_tabbar",
".",
"tabAt",
"(",
"event",
".",
"pos",
"(",
")",
")",
"self",
".",
"dock_tabbar",
".",
"setCurrentIndex",
"(",
"self",
".",
"from_in... | Method called when a tab from a QTabBar has been pressed. | [
"Method",
"called",
"when",
"a",
"tab",
"from",
"a",
"QTabBar",
"has",
"been",
"pressed",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/dock.py#L44-L53 |
31,240 | spyder-ide/spyder | spyder/widgets/dock.py | TabFilter.show_nontab_menu | def show_nontab_menu(self, event):
"""Show the context menu assigned to nontabs section."""
menu = self.main.createPopupMenu()
menu.exec_(self.dock_tabbar.mapToGlobal(event.pos())) | python | def show_nontab_menu(self, event):
"""Show the context menu assigned to nontabs section."""
menu = self.main.createPopupMenu()
menu.exec_(self.dock_tabbar.mapToGlobal(event.pos())) | [
"def",
"show_nontab_menu",
"(",
"self",
",",
"event",
")",
":",
"menu",
"=",
"self",
".",
"main",
".",
"createPopupMenu",
"(",
")",
"menu",
".",
"exec_",
"(",
"self",
".",
"dock_tabbar",
".",
"mapToGlobal",
"(",
"event",
".",
"pos",
"(",
")",
")",
")... | Show the context menu assigned to nontabs section. | [
"Show",
"the",
"context",
"menu",
"assigned",
"to",
"nontabs",
"section",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/dock.py#L59-L62 |
31,241 | spyder-ide/spyder | spyder/widgets/dock.py | SpyderDockWidget.install_tab_event_filter | def install_tab_event_filter(self, value):
"""
Install an event filter to capture mouse events in the tabs of a
QTabBar holding tabified dockwidgets.
"""
dock_tabbar = None
tabbars = self.main.findChildren(QTabBar)
for tabbar in tabbars:
for tab in range(tabbar.count()):
title = tabbar.tabText(tab)
if title == self.title:
dock_tabbar = tabbar
break
if dock_tabbar is not None:
self.dock_tabbar = dock_tabbar
# Install filter only once per QTabBar
if getattr(self.dock_tabbar, 'filter', None) is None:
self.dock_tabbar.filter = TabFilter(self.dock_tabbar,
self.main)
self.dock_tabbar.installEventFilter(self.dock_tabbar.filter) | python | def install_tab_event_filter(self, value):
"""
Install an event filter to capture mouse events in the tabs of a
QTabBar holding tabified dockwidgets.
"""
dock_tabbar = None
tabbars = self.main.findChildren(QTabBar)
for tabbar in tabbars:
for tab in range(tabbar.count()):
title = tabbar.tabText(tab)
if title == self.title:
dock_tabbar = tabbar
break
if dock_tabbar is not None:
self.dock_tabbar = dock_tabbar
# Install filter only once per QTabBar
if getattr(self.dock_tabbar, 'filter', None) is None:
self.dock_tabbar.filter = TabFilter(self.dock_tabbar,
self.main)
self.dock_tabbar.installEventFilter(self.dock_tabbar.filter) | [
"def",
"install_tab_event_filter",
"(",
"self",
",",
"value",
")",
":",
"dock_tabbar",
"=",
"None",
"tabbars",
"=",
"self",
".",
"main",
".",
"findChildren",
"(",
"QTabBar",
")",
"for",
"tabbar",
"in",
"tabbars",
":",
"for",
"tab",
"in",
"range",
"(",
"t... | Install an event filter to capture mouse events in the tabs of a
QTabBar holding tabified dockwidgets. | [
"Install",
"an",
"event",
"filter",
"to",
"capture",
"mouse",
"events",
"in",
"the",
"tabs",
"of",
"a",
"QTabBar",
"holding",
"tabified",
"dockwidgets",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/dock.py#L208-L227 |
31,242 | spyder-ide/spyder | spyder/plugins/editor/utils/bookmarks.py | _load_all_bookmarks | def _load_all_bookmarks():
"""Load all bookmarks from config."""
slots = CONF.get('editor', 'bookmarks', {})
for slot_num in list(slots.keys()):
if not osp.isfile(slots[slot_num][0]):
slots.pop(slot_num)
return slots | python | def _load_all_bookmarks():
"""Load all bookmarks from config."""
slots = CONF.get('editor', 'bookmarks', {})
for slot_num in list(slots.keys()):
if not osp.isfile(slots[slot_num][0]):
slots.pop(slot_num)
return slots | [
"def",
"_load_all_bookmarks",
"(",
")",
":",
"slots",
"=",
"CONF",
".",
"get",
"(",
"'editor'",
",",
"'bookmarks'",
",",
"{",
"}",
")",
"for",
"slot_num",
"in",
"list",
"(",
"slots",
".",
"keys",
"(",
")",
")",
":",
"if",
"not",
"osp",
".",
"isfile... | Load all bookmarks from config. | [
"Load",
"all",
"bookmarks",
"from",
"config",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/bookmarks.py#L17-L23 |
31,243 | spyder-ide/spyder | spyder/plugins/editor/utils/bookmarks.py | load_bookmarks | def load_bookmarks(filename):
"""Load all bookmarks for a specific file from config."""
bookmarks = _load_all_bookmarks()
return {k: v for k, v in bookmarks.items() if v[0] == filename} | python | def load_bookmarks(filename):
"""Load all bookmarks for a specific file from config."""
bookmarks = _load_all_bookmarks()
return {k: v for k, v in bookmarks.items() if v[0] == filename} | [
"def",
"load_bookmarks",
"(",
"filename",
")",
":",
"bookmarks",
"=",
"_load_all_bookmarks",
"(",
")",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"bookmarks",
".",
"items",
"(",
")",
"if",
"v",
"[",
"0",
"]",
"==",
"filename",
"}"
] | Load all bookmarks for a specific file from config. | [
"Load",
"all",
"bookmarks",
"for",
"a",
"specific",
"file",
"from",
"config",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/bookmarks.py#L26-L29 |
31,244 | spyder-ide/spyder | spyder/plugins/editor/utils/bookmarks.py | load_bookmarks_without_file | def load_bookmarks_without_file(filename):
"""Load all bookmarks but those from a specific file."""
bookmarks = _load_all_bookmarks()
return {k: v for k, v in bookmarks.items() if v[0] != filename} | python | def load_bookmarks_without_file(filename):
"""Load all bookmarks but those from a specific file."""
bookmarks = _load_all_bookmarks()
return {k: v for k, v in bookmarks.items() if v[0] != filename} | [
"def",
"load_bookmarks_without_file",
"(",
"filename",
")",
":",
"bookmarks",
"=",
"_load_all_bookmarks",
"(",
")",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"bookmarks",
".",
"items",
"(",
")",
"if",
"v",
"[",
"0",
"]",
"!=",
"filename... | Load all bookmarks but those from a specific file. | [
"Load",
"all",
"bookmarks",
"but",
"those",
"from",
"a",
"specific",
"file",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/bookmarks.py#L32-L35 |
31,245 | spyder-ide/spyder | spyder/plugins/editor/utils/bookmarks.py | save_bookmarks | def save_bookmarks(filename, bookmarks):
"""Save all bookmarks from specific file to config."""
if not osp.isfile(filename):
return
slots = load_bookmarks_without_file(filename)
for slot_num, content in bookmarks.items():
slots[slot_num] = [filename, content[0], content[1]]
CONF.set('editor', 'bookmarks', slots) | python | def save_bookmarks(filename, bookmarks):
"""Save all bookmarks from specific file to config."""
if not osp.isfile(filename):
return
slots = load_bookmarks_without_file(filename)
for slot_num, content in bookmarks.items():
slots[slot_num] = [filename, content[0], content[1]]
CONF.set('editor', 'bookmarks', slots) | [
"def",
"save_bookmarks",
"(",
"filename",
",",
"bookmarks",
")",
":",
"if",
"not",
"osp",
".",
"isfile",
"(",
"filename",
")",
":",
"return",
"slots",
"=",
"load_bookmarks_without_file",
"(",
"filename",
")",
"for",
"slot_num",
",",
"content",
"in",
"bookmar... | Save all bookmarks from specific file to config. | [
"Save",
"all",
"bookmarks",
"from",
"specific",
"file",
"to",
"config",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/bookmarks.py#L38-L45 |
31,246 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.report_open_file | def report_open_file(self, options):
"""Request to start a LSP server to attend a language."""
filename = options['filename']
logger.debug('Call LSP for %s' % filename)
language = options['language']
callback = options['codeeditor']
stat = self.main.lspmanager.start_client(language.lower())
self.main.lspmanager.register_file(
language.lower(), filename, callback)
if stat:
if language.lower() in self.lsp_editor_settings:
self.lsp_server_ready(
language.lower(), self.lsp_editor_settings[
language.lower()])
else:
editor = self.get_current_editor()
editor.lsp_ready = False | python | def report_open_file(self, options):
"""Request to start a LSP server to attend a language."""
filename = options['filename']
logger.debug('Call LSP for %s' % filename)
language = options['language']
callback = options['codeeditor']
stat = self.main.lspmanager.start_client(language.lower())
self.main.lspmanager.register_file(
language.lower(), filename, callback)
if stat:
if language.lower() in self.lsp_editor_settings:
self.lsp_server_ready(
language.lower(), self.lsp_editor_settings[
language.lower()])
else:
editor = self.get_current_editor()
editor.lsp_ready = False | [
"def",
"report_open_file",
"(",
"self",
",",
"options",
")",
":",
"filename",
"=",
"options",
"[",
"'filename'",
"]",
"logger",
".",
"debug",
"(",
"'Call LSP for %s'",
"%",
"filename",
")",
"language",
"=",
"options",
"[",
"'language'",
"]",
"callback",
"=",... | Request to start a LSP server to attend a language. | [
"Request",
"to",
"start",
"a",
"LSP",
"server",
"to",
"attend",
"a",
"language",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L275-L291 |
31,247 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.register_lsp_server_settings | def register_lsp_server_settings(self, settings, language):
"""Register LSP server settings."""
self.lsp_editor_settings[language] = settings
logger.debug('LSP server settings for {!s} are: {!r}'.format(
language, settings))
self.lsp_server_ready(language, self.lsp_editor_settings[language]) | python | def register_lsp_server_settings(self, settings, language):
"""Register LSP server settings."""
self.lsp_editor_settings[language] = settings
logger.debug('LSP server settings for {!s} are: {!r}'.format(
language, settings))
self.lsp_server_ready(language, self.lsp_editor_settings[language]) | [
"def",
"register_lsp_server_settings",
"(",
"self",
",",
"settings",
",",
"language",
")",
":",
"self",
".",
"lsp_editor_settings",
"[",
"language",
"]",
"=",
"settings",
"logger",
".",
"debug",
"(",
"'LSP server settings for {!s} are: {!r}'",
".",
"format",
"(",
... | Register LSP server settings. | [
"Register",
"LSP",
"server",
"settings",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L294-L299 |
31,248 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.lsp_server_ready | def lsp_server_ready(self, language, configuration):
"""Notify all stackeditors about LSP server availability."""
for editorstack in self.editorstacks:
editorstack.notify_server_ready(language, configuration) | python | def lsp_server_ready(self, language, configuration):
"""Notify all stackeditors about LSP server availability."""
for editorstack in self.editorstacks:
editorstack.notify_server_ready(language, configuration) | [
"def",
"lsp_server_ready",
"(",
"self",
",",
"language",
",",
"configuration",
")",
":",
"for",
"editorstack",
"in",
"self",
".",
"editorstacks",
":",
"editorstack",
".",
"notify_server_ready",
"(",
"language",
",",
"configuration",
")"
] | Notify all stackeditors about LSP server availability. | [
"Notify",
"all",
"stackeditors",
"about",
"LSP",
"server",
"availability",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L301-L304 |
31,249 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.received_sig_option_changed | def received_sig_option_changed(self, option, value):
"""
Called when sig_option_changed is received.
If option being changed is autosave_mapping, then synchronize new
mapping with all editor stacks except the sender.
"""
if option == 'autosave_mapping':
for editorstack in self.editorstacks:
if editorstack != self.sender():
editorstack.autosave_mapping = value
self.sig_option_changed.emit(option, value) | python | def received_sig_option_changed(self, option, value):
"""
Called when sig_option_changed is received.
If option being changed is autosave_mapping, then synchronize new
mapping with all editor stacks except the sender.
"""
if option == 'autosave_mapping':
for editorstack in self.editorstacks:
if editorstack != self.sender():
editorstack.autosave_mapping = value
self.sig_option_changed.emit(option, value) | [
"def",
"received_sig_option_changed",
"(",
"self",
",",
"option",
",",
"value",
")",
":",
"if",
"option",
"==",
"'autosave_mapping'",
":",
"for",
"editorstack",
"in",
"self",
".",
"editorstacks",
":",
"if",
"editorstack",
"!=",
"self",
".",
"sender",
"(",
")... | Called when sig_option_changed is received.
If option being changed is autosave_mapping, then synchronize new
mapping with all editor stacks except the sender. | [
"Called",
"when",
"sig_option_changed",
"is",
"received",
".",
"If",
"option",
"being",
"changed",
"is",
"autosave_mapping",
"then",
"synchronize",
"new",
"mapping",
"with",
"all",
"editor",
"stacks",
"except",
"the",
"sender",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1020-L1031 |
31,250 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.unregister_editorstack | def unregister_editorstack(self, editorstack):
"""Removing editorstack only if it's not the last remaining"""
self.remove_last_focus_editorstack(editorstack)
if len(self.editorstacks) > 1:
index = self.editorstacks.index(editorstack)
self.editorstacks.pop(index)
return True
else:
# editorstack was not removed!
return False | python | def unregister_editorstack(self, editorstack):
"""Removing editorstack only if it's not the last remaining"""
self.remove_last_focus_editorstack(editorstack)
if len(self.editorstacks) > 1:
index = self.editorstacks.index(editorstack)
self.editorstacks.pop(index)
return True
else:
# editorstack was not removed!
return False | [
"def",
"unregister_editorstack",
"(",
"self",
",",
"editorstack",
")",
":",
"self",
".",
"remove_last_focus_editorstack",
"(",
"editorstack",
")",
"if",
"len",
"(",
"self",
".",
"editorstacks",
")",
">",
"1",
":",
"index",
"=",
"self",
".",
"editorstacks",
"... | Removing editorstack only if it's not the last remaining | [
"Removing",
"editorstack",
"only",
"if",
"it",
"s",
"not",
"the",
"last",
"remaining"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1202-L1211 |
31,251 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.setup_other_windows | def setup_other_windows(self):
"""Setup toolbars and menus for 'New window' instances"""
self.toolbar_list = ((_("File toolbar"), "file_toolbar",
self.main.file_toolbar_actions),
(_("Search toolbar"), "search_toolbar",
self.main.search_menu_actions),
(_("Source toolbar"), "source_toolbar",
self.main.source_toolbar_actions),
(_("Run toolbar"), "run_toolbar",
self.main.run_toolbar_actions),
(_("Debug toolbar"), "debug_toolbar",
self.main.debug_toolbar_actions),
(_("Edit toolbar"), "edit_toolbar",
self.main.edit_toolbar_actions))
self.menu_list = ((_("&File"), self.main.file_menu_actions),
(_("&Edit"), self.main.edit_menu_actions),
(_("&Search"), self.main.search_menu_actions),
(_("Sour&ce"), self.main.source_menu_actions),
(_("&Run"), self.main.run_menu_actions),
(_("&Tools"), self.main.tools_menu_actions),
(_("&View"), []),
(_("&Help"), self.main.help_menu_actions))
# Create pending new windows:
for layout_settings in self.editorwindows_to_be_created:
win = self.create_new_window()
win.set_layout_settings(layout_settings) | python | def setup_other_windows(self):
"""Setup toolbars and menus for 'New window' instances"""
self.toolbar_list = ((_("File toolbar"), "file_toolbar",
self.main.file_toolbar_actions),
(_("Search toolbar"), "search_toolbar",
self.main.search_menu_actions),
(_("Source toolbar"), "source_toolbar",
self.main.source_toolbar_actions),
(_("Run toolbar"), "run_toolbar",
self.main.run_toolbar_actions),
(_("Debug toolbar"), "debug_toolbar",
self.main.debug_toolbar_actions),
(_("Edit toolbar"), "edit_toolbar",
self.main.edit_toolbar_actions))
self.menu_list = ((_("&File"), self.main.file_menu_actions),
(_("&Edit"), self.main.edit_menu_actions),
(_("&Search"), self.main.search_menu_actions),
(_("Sour&ce"), self.main.source_menu_actions),
(_("&Run"), self.main.run_menu_actions),
(_("&Tools"), self.main.tools_menu_actions),
(_("&View"), []),
(_("&Help"), self.main.help_menu_actions))
# Create pending new windows:
for layout_settings in self.editorwindows_to_be_created:
win = self.create_new_window()
win.set_layout_settings(layout_settings) | [
"def",
"setup_other_windows",
"(",
"self",
")",
":",
"self",
".",
"toolbar_list",
"=",
"(",
"(",
"_",
"(",
"\"File toolbar\"",
")",
",",
"\"file_toolbar\"",
",",
"self",
".",
"main",
".",
"file_toolbar_actions",
")",
",",
"(",
"_",
"(",
"\"Search toolbar\"",... | Setup toolbars and menus for 'New window' instances | [
"Setup",
"toolbars",
"and",
"menus",
"for",
"New",
"window",
"instances"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1245-L1271 |
31,252 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.refresh_save_all_action | def refresh_save_all_action(self):
"""Enable 'Save All' if there are files to be saved"""
editorstack = self.get_current_editorstack()
if editorstack:
state = any(finfo.editor.document().isModified() or finfo.newly_created
for finfo in editorstack.data)
self.save_all_action.setEnabled(state) | python | def refresh_save_all_action(self):
"""Enable 'Save All' if there are files to be saved"""
editorstack = self.get_current_editorstack()
if editorstack:
state = any(finfo.editor.document().isModified() or finfo.newly_created
for finfo in editorstack.data)
self.save_all_action.setEnabled(state) | [
"def",
"refresh_save_all_action",
"(",
"self",
")",
":",
"editorstack",
"=",
"self",
".",
"get_current_editorstack",
"(",
")",
"if",
"editorstack",
":",
"state",
"=",
"any",
"(",
"finfo",
".",
"editor",
".",
"document",
"(",
")",
".",
"isModified",
"(",
")... | Enable 'Save All' if there are files to be saved | [
"Enable",
"Save",
"All",
"if",
"there",
"are",
"files",
"to",
"be",
"saved"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1373-L1379 |
31,253 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.update_warning_menu | def update_warning_menu(self):
"""Update warning list menu"""
editor = self.get_current_editor()
check_results = editor.get_current_warnings()
self.warning_menu.clear()
filename = self.get_current_filename()
for message, line_number in check_results:
error = 'syntax' in message
text = message[:1].upper() + message[1:]
icon = ima.icon('error') if error else ima.icon('warning')
slot = lambda _checked, _l=line_number: self.load(filename, goto=_l)
action = create_action(self, text=text, icon=icon, triggered=slot)
self.warning_menu.addAction(action) | python | def update_warning_menu(self):
"""Update warning list menu"""
editor = self.get_current_editor()
check_results = editor.get_current_warnings()
self.warning_menu.clear()
filename = self.get_current_filename()
for message, line_number in check_results:
error = 'syntax' in message
text = message[:1].upper() + message[1:]
icon = ima.icon('error') if error else ima.icon('warning')
slot = lambda _checked, _l=line_number: self.load(filename, goto=_l)
action = create_action(self, text=text, icon=icon, triggered=slot)
self.warning_menu.addAction(action) | [
"def",
"update_warning_menu",
"(",
"self",
")",
":",
"editor",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"check_results",
"=",
"editor",
".",
"get_current_warnings",
"(",
")",
"self",
".",
"warning_menu",
".",
"clear",
"(",
")",
"filename",
"=",
"sel... | Update warning list menu | [
"Update",
"warning",
"list",
"menu"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1381-L1393 |
31,254 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.update_todo_menu | def update_todo_menu(self):
"""Update todo list menu"""
editorstack = self.get_current_editorstack()
results = editorstack.get_todo_results()
self.todo_menu.clear()
filename = self.get_current_filename()
for text, line0 in results:
icon = ima.icon('todo')
slot = lambda _checked, _l=line0: self.load(filename, goto=_l)
action = create_action(self, text=text, icon=icon, triggered=slot)
self.todo_menu.addAction(action)
self.update_todo_actions() | python | def update_todo_menu(self):
"""Update todo list menu"""
editorstack = self.get_current_editorstack()
results = editorstack.get_todo_results()
self.todo_menu.clear()
filename = self.get_current_filename()
for text, line0 in results:
icon = ima.icon('todo')
slot = lambda _checked, _l=line0: self.load(filename, goto=_l)
action = create_action(self, text=text, icon=icon, triggered=slot)
self.todo_menu.addAction(action)
self.update_todo_actions() | [
"def",
"update_todo_menu",
"(",
"self",
")",
":",
"editorstack",
"=",
"self",
".",
"get_current_editorstack",
"(",
")",
"results",
"=",
"editorstack",
".",
"get_todo_results",
"(",
")",
"self",
".",
"todo_menu",
".",
"clear",
"(",
")",
"filename",
"=",
"self... | Update todo list menu | [
"Update",
"todo",
"list",
"menu"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1395-L1406 |
31,255 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.todo_results_changed | def todo_results_changed(self):
"""
Synchronize todo results between editorstacks
Refresh todo list navigation buttons
"""
editorstack = self.get_current_editorstack()
results = editorstack.get_todo_results()
index = editorstack.get_stack_index()
if index != -1:
filename = editorstack.data[index].filename
for other_editorstack in self.editorstacks:
if other_editorstack is not editorstack:
other_editorstack.set_todo_results(filename, results)
self.update_todo_actions() | python | def todo_results_changed(self):
"""
Synchronize todo results between editorstacks
Refresh todo list navigation buttons
"""
editorstack = self.get_current_editorstack()
results = editorstack.get_todo_results()
index = editorstack.get_stack_index()
if index != -1:
filename = editorstack.data[index].filename
for other_editorstack in self.editorstacks:
if other_editorstack is not editorstack:
other_editorstack.set_todo_results(filename, results)
self.update_todo_actions() | [
"def",
"todo_results_changed",
"(",
"self",
")",
":",
"editorstack",
"=",
"self",
".",
"get_current_editorstack",
"(",
")",
"results",
"=",
"editorstack",
".",
"get_todo_results",
"(",
")",
"index",
"=",
"editorstack",
".",
"get_stack_index",
"(",
")",
"if",
"... | Synchronize todo results between editorstacks
Refresh todo list navigation buttons | [
"Synchronize",
"todo",
"results",
"between",
"editorstacks",
"Refresh",
"todo",
"list",
"navigation",
"buttons"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1408-L1421 |
31,256 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.save_bookmarks | def save_bookmarks(self, filename, bookmarks):
"""Receive bookmark changes and save them."""
filename = to_text_string(filename)
bookmarks = to_text_string(bookmarks)
filename = osp.normpath(osp.abspath(filename))
bookmarks = eval(bookmarks)
save_bookmarks(filename, bookmarks) | python | def save_bookmarks(self, filename, bookmarks):
"""Receive bookmark changes and save them."""
filename = to_text_string(filename)
bookmarks = to_text_string(bookmarks)
filename = osp.normpath(osp.abspath(filename))
bookmarks = eval(bookmarks)
save_bookmarks(filename, bookmarks) | [
"def",
"save_bookmarks",
"(",
"self",
",",
"filename",
",",
"bookmarks",
")",
":",
"filename",
"=",
"to_text_string",
"(",
"filename",
")",
"bookmarks",
"=",
"to_text_string",
"(",
"bookmarks",
")",
"filename",
"=",
"osp",
".",
"normpath",
"(",
"osp",
".",
... | Receive bookmark changes and save them. | [
"Receive",
"bookmark",
"changes",
"and",
"save",
"them",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1508-L1514 |
31,257 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.__load_temp_file | def __load_temp_file(self):
"""Load temporary file from a text file in user home directory"""
if not osp.isfile(self.TEMPFILE_PATH):
# Creating temporary file
default = ['# -*- coding: utf-8 -*-',
'"""', _("Spyder Editor"), '',
_("This is a temporary script file."),
'"""', '', '']
text = os.linesep.join([encoding.to_unicode(qstr)
for qstr in default])
try:
encoding.write(to_text_string(text), self.TEMPFILE_PATH,
'utf-8')
except EnvironmentError:
self.new()
return
self.load(self.TEMPFILE_PATH) | python | def __load_temp_file(self):
"""Load temporary file from a text file in user home directory"""
if not osp.isfile(self.TEMPFILE_PATH):
# Creating temporary file
default = ['# -*- coding: utf-8 -*-',
'"""', _("Spyder Editor"), '',
_("This is a temporary script file."),
'"""', '', '']
text = os.linesep.join([encoding.to_unicode(qstr)
for qstr in default])
try:
encoding.write(to_text_string(text), self.TEMPFILE_PATH,
'utf-8')
except EnvironmentError:
self.new()
return
self.load(self.TEMPFILE_PATH) | [
"def",
"__load_temp_file",
"(",
"self",
")",
":",
"if",
"not",
"osp",
".",
"isfile",
"(",
"self",
".",
"TEMPFILE_PATH",
")",
":",
"# Creating temporary file\r",
"default",
"=",
"[",
"'# -*- coding: utf-8 -*-'",
",",
"'\"\"\"'",
",",
"_",
"(",
"\"Spyder Editor\""... | Load temporary file from a text file in user home directory | [
"Load",
"temporary",
"file",
"from",
"a",
"text",
"file",
"in",
"user",
"home",
"directory"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1517-L1534 |
31,258 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.__set_workdir | def __set_workdir(self):
"""Set current script directory as working directory"""
fname = self.get_current_filename()
if fname is not None:
directory = osp.dirname(osp.abspath(fname))
self.open_dir.emit(directory) | python | def __set_workdir(self):
"""Set current script directory as working directory"""
fname = self.get_current_filename()
if fname is not None:
directory = osp.dirname(osp.abspath(fname))
self.open_dir.emit(directory) | [
"def",
"__set_workdir",
"(",
"self",
")",
":",
"fname",
"=",
"self",
".",
"get_current_filename",
"(",
")",
"if",
"fname",
"is",
"not",
"None",
":",
"directory",
"=",
"osp",
".",
"dirname",
"(",
"osp",
".",
"abspath",
"(",
"fname",
")",
")",
"self",
... | Set current script directory as working directory | [
"Set",
"current",
"script",
"directory",
"as",
"working",
"directory"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1537-L1542 |
31,259 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.__add_recent_file | def __add_recent_file(self, fname):
"""Add to recent file list"""
if fname is None:
return
if fname in self.recent_files:
self.recent_files.remove(fname)
self.recent_files.insert(0, fname)
if len(self.recent_files) > self.get_option('max_recent_files'):
self.recent_files.pop(-1) | python | def __add_recent_file(self, fname):
"""Add to recent file list"""
if fname is None:
return
if fname in self.recent_files:
self.recent_files.remove(fname)
self.recent_files.insert(0, fname)
if len(self.recent_files) > self.get_option('max_recent_files'):
self.recent_files.pop(-1) | [
"def",
"__add_recent_file",
"(",
"self",
",",
"fname",
")",
":",
"if",
"fname",
"is",
"None",
":",
"return",
"if",
"fname",
"in",
"self",
".",
"recent_files",
":",
"self",
".",
"recent_files",
".",
"remove",
"(",
"fname",
")",
"self",
".",
"recent_files"... | Add to recent file list | [
"Add",
"to",
"recent",
"file",
"list"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1544-L1552 |
31,260 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.update_recent_file_menu | def update_recent_file_menu(self):
"""Update recent file menu"""
recent_files = []
for fname in self.recent_files:
if self.is_file_opened(fname) is None and osp.isfile(fname):
recent_files.append(fname)
self.recent_file_menu.clear()
if recent_files:
for fname in recent_files:
action = create_action(self, fname,
icon=ima.icon('FileIcon'),
triggered=self.load)
action.setData(to_qvariant(fname))
self.recent_file_menu.addAction(action)
self.clear_recent_action.setEnabled(len(recent_files) > 0)
add_actions(self.recent_file_menu, (None, self.max_recent_action,
self.clear_recent_action)) | python | def update_recent_file_menu(self):
"""Update recent file menu"""
recent_files = []
for fname in self.recent_files:
if self.is_file_opened(fname) is None and osp.isfile(fname):
recent_files.append(fname)
self.recent_file_menu.clear()
if recent_files:
for fname in recent_files:
action = create_action(self, fname,
icon=ima.icon('FileIcon'),
triggered=self.load)
action.setData(to_qvariant(fname))
self.recent_file_menu.addAction(action)
self.clear_recent_action.setEnabled(len(recent_files) > 0)
add_actions(self.recent_file_menu, (None, self.max_recent_action,
self.clear_recent_action)) | [
"def",
"update_recent_file_menu",
"(",
"self",
")",
":",
"recent_files",
"=",
"[",
"]",
"for",
"fname",
"in",
"self",
".",
"recent_files",
":",
"if",
"self",
".",
"is_file_opened",
"(",
"fname",
")",
"is",
"None",
"and",
"osp",
".",
"isfile",
"(",
"fname... | Update recent file menu | [
"Update",
"recent",
"file",
"menu"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1652-L1668 |
31,261 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.print_file | def print_file(self):
"""Print current file"""
editor = self.get_current_editor()
filename = self.get_current_filename()
printer = Printer(mode=QPrinter.HighResolution,
header_font=self.get_plugin_font('printer_header'))
printDialog = QPrintDialog(printer, editor)
if editor.has_selected_text():
printDialog.setOption(QAbstractPrintDialog.PrintSelection, True)
self.redirect_stdio.emit(False)
answer = printDialog.exec_()
self.redirect_stdio.emit(True)
if answer == QDialog.Accepted:
self.starting_long_process(_("Printing..."))
printer.setDocName(filename)
editor.print_(printer)
self.ending_long_process() | python | def print_file(self):
"""Print current file"""
editor = self.get_current_editor()
filename = self.get_current_filename()
printer = Printer(mode=QPrinter.HighResolution,
header_font=self.get_plugin_font('printer_header'))
printDialog = QPrintDialog(printer, editor)
if editor.has_selected_text():
printDialog.setOption(QAbstractPrintDialog.PrintSelection, True)
self.redirect_stdio.emit(False)
answer = printDialog.exec_()
self.redirect_stdio.emit(True)
if answer == QDialog.Accepted:
self.starting_long_process(_("Printing..."))
printer.setDocName(filename)
editor.print_(printer)
self.ending_long_process() | [
"def",
"print_file",
"(",
"self",
")",
":",
"editor",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"filename",
"=",
"self",
".",
"get_current_filename",
"(",
")",
"printer",
"=",
"Printer",
"(",
"mode",
"=",
"QPrinter",
".",
"HighResolution",
",",
"he... | Print current file | [
"Print",
"current",
"file"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1831-L1847 |
31,262 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.print_preview | def print_preview(self):
"""Print preview for current file"""
from qtpy.QtPrintSupport import QPrintPreviewDialog
editor = self.get_current_editor()
printer = Printer(mode=QPrinter.HighResolution,
header_font=self.get_plugin_font('printer_header'))
preview = QPrintPreviewDialog(printer, self)
preview.setWindowFlags(Qt.Window)
preview.paintRequested.connect(lambda printer: editor.print_(printer))
self.redirect_stdio.emit(False)
preview.exec_()
self.redirect_stdio.emit(True) | python | def print_preview(self):
"""Print preview for current file"""
from qtpy.QtPrintSupport import QPrintPreviewDialog
editor = self.get_current_editor()
printer = Printer(mode=QPrinter.HighResolution,
header_font=self.get_plugin_font('printer_header'))
preview = QPrintPreviewDialog(printer, self)
preview.setWindowFlags(Qt.Window)
preview.paintRequested.connect(lambda printer: editor.print_(printer))
self.redirect_stdio.emit(False)
preview.exec_()
self.redirect_stdio.emit(True) | [
"def",
"print_preview",
"(",
"self",
")",
":",
"from",
"qtpy",
".",
"QtPrintSupport",
"import",
"QPrintPreviewDialog",
"editor",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"printer",
"=",
"Printer",
"(",
"mode",
"=",
"QPrinter",
".",
"HighResolution",
"... | Print preview for current file | [
"Print",
"preview",
"for",
"current",
"file"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1850-L1862 |
31,263 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.open_last_closed | def open_last_closed(self):
""" Reopens the last closed tab."""
editorstack = self.get_current_editorstack()
last_closed_files = editorstack.get_last_closed_files()
if (len(last_closed_files) > 0):
file_to_open = last_closed_files[0]
last_closed_files.remove(file_to_open)
editorstack.set_last_closed_files(last_closed_files)
self.load(file_to_open) | python | def open_last_closed(self):
""" Reopens the last closed tab."""
editorstack = self.get_current_editorstack()
last_closed_files = editorstack.get_last_closed_files()
if (len(last_closed_files) > 0):
file_to_open = last_closed_files[0]
last_closed_files.remove(file_to_open)
editorstack.set_last_closed_files(last_closed_files)
self.load(file_to_open) | [
"def",
"open_last_closed",
"(",
"self",
")",
":",
"editorstack",
"=",
"self",
".",
"get_current_editorstack",
"(",
")",
"last_closed_files",
"=",
"editorstack",
".",
"get_last_closed_files",
"(",
")",
"if",
"(",
"len",
"(",
"last_closed_files",
")",
">",
"0",
... | Reopens the last closed tab. | [
"Reopens",
"the",
"last",
"closed",
"tab",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1930-L1938 |
31,264 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.close_file_from_name | def close_file_from_name(self, filename):
"""Close file from its name"""
filename = osp.abspath(to_text_string(filename))
index = self.editorstacks[0].has_filename(filename)
if index is not None:
self.editorstacks[0].close_file(index) | python | def close_file_from_name(self, filename):
"""Close file from its name"""
filename = osp.abspath(to_text_string(filename))
index = self.editorstacks[0].has_filename(filename)
if index is not None:
self.editorstacks[0].close_file(index) | [
"def",
"close_file_from_name",
"(",
"self",
",",
"filename",
")",
":",
"filename",
"=",
"osp",
".",
"abspath",
"(",
"to_text_string",
"(",
"filename",
")",
")",
"index",
"=",
"self",
".",
"editorstacks",
"[",
"0",
"]",
".",
"has_filename",
"(",
"filename",... | Close file from its name | [
"Close",
"file",
"from",
"its",
"name"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1941-L1946 |
31,265 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.removed_tree | def removed_tree(self, dirname):
"""Directory was removed in project explorer widget"""
dirname = osp.abspath(to_text_string(dirname))
for fname in self.get_filenames():
if osp.abspath(fname).startswith(dirname):
self.close_file_from_name(fname) | python | def removed_tree(self, dirname):
"""Directory was removed in project explorer widget"""
dirname = osp.abspath(to_text_string(dirname))
for fname in self.get_filenames():
if osp.abspath(fname).startswith(dirname):
self.close_file_from_name(fname) | [
"def",
"removed_tree",
"(",
"self",
",",
"dirname",
")",
":",
"dirname",
"=",
"osp",
".",
"abspath",
"(",
"to_text_string",
"(",
"dirname",
")",
")",
"for",
"fname",
"in",
"self",
".",
"get_filenames",
"(",
")",
":",
"if",
"osp",
".",
"abspath",
"(",
... | Directory was removed in project explorer widget | [
"Directory",
"was",
"removed",
"in",
"project",
"explorer",
"widget"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1952-L1957 |
31,266 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.renamed | def renamed(self, source, dest):
"""File was renamed in file explorer widget or in project explorer"""
filename = osp.abspath(to_text_string(source))
index = self.editorstacks[0].has_filename(filename)
if index is not None:
for editorstack in self.editorstacks:
editorstack.rename_in_data(filename,
new_filename=to_text_string(dest)) | python | def renamed(self, source, dest):
"""File was renamed in file explorer widget or in project explorer"""
filename = osp.abspath(to_text_string(source))
index = self.editorstacks[0].has_filename(filename)
if index is not None:
for editorstack in self.editorstacks:
editorstack.rename_in_data(filename,
new_filename=to_text_string(dest)) | [
"def",
"renamed",
"(",
"self",
",",
"source",
",",
"dest",
")",
":",
"filename",
"=",
"osp",
".",
"abspath",
"(",
"to_text_string",
"(",
"source",
")",
")",
"index",
"=",
"self",
".",
"editorstacks",
"[",
"0",
"]",
".",
"has_filename",
"(",
"filename",... | File was renamed in file explorer widget or in project explorer | [
"File",
"was",
"renamed",
"in",
"file",
"explorer",
"widget",
"or",
"in",
"project",
"explorer"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1959-L1966 |
31,267 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.renamed_tree | def renamed_tree(self, source, dest):
"""Directory was renamed in file explorer or in project explorer."""
dirname = osp.abspath(to_text_string(source))
tofile = to_text_string(dest)
for fname in self.get_filenames():
if osp.abspath(fname).startswith(dirname):
new_filename = fname.replace(dirname, tofile)
self.renamed(source=fname, dest=new_filename) | python | def renamed_tree(self, source, dest):
"""Directory was renamed in file explorer or in project explorer."""
dirname = osp.abspath(to_text_string(source))
tofile = to_text_string(dest)
for fname in self.get_filenames():
if osp.abspath(fname).startswith(dirname):
new_filename = fname.replace(dirname, tofile)
self.renamed(source=fname, dest=new_filename) | [
"def",
"renamed_tree",
"(",
"self",
",",
"source",
",",
"dest",
")",
":",
"dirname",
"=",
"osp",
".",
"abspath",
"(",
"to_text_string",
"(",
"source",
")",
")",
"tofile",
"=",
"to_text_string",
"(",
"dest",
")",
"for",
"fname",
"in",
"self",
".",
"get_... | Directory was renamed in file explorer or in project explorer. | [
"Directory",
"was",
"renamed",
"in",
"file",
"explorer",
"or",
"in",
"project",
"explorer",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L1968-L1975 |
31,268 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.run_winpdb | def run_winpdb(self):
"""Run winpdb to debug current file"""
if self.save():
fname = self.get_current_filename()
runconf = get_run_configuration(fname)
if runconf is None:
args = []
wdir = None
else:
args = runconf.get_arguments().split()
wdir = runconf.get_working_directory()
# Handle the case where wdir comes back as an empty string
# when the working directory dialog checkbox is unchecked.
# (subprocess "cwd" default is None, so empty str
# must be changed to None in this case.)
programs.run_program(WINPDB_PATH, [fname] + args, cwd=wdir or None) | python | def run_winpdb(self):
"""Run winpdb to debug current file"""
if self.save():
fname = self.get_current_filename()
runconf = get_run_configuration(fname)
if runconf is None:
args = []
wdir = None
else:
args = runconf.get_arguments().split()
wdir = runconf.get_working_directory()
# Handle the case where wdir comes back as an empty string
# when the working directory dialog checkbox is unchecked.
# (subprocess "cwd" default is None, so empty str
# must be changed to None in this case.)
programs.run_program(WINPDB_PATH, [fname] + args, cwd=wdir or None) | [
"def",
"run_winpdb",
"(",
"self",
")",
":",
"if",
"self",
".",
"save",
"(",
")",
":",
"fname",
"=",
"self",
".",
"get_current_filename",
"(",
")",
"runconf",
"=",
"get_run_configuration",
"(",
"fname",
")",
"if",
"runconf",
"is",
"None",
":",
"args",
"... | Run winpdb to debug current file | [
"Run",
"winpdb",
"to",
"debug",
"current",
"file"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2051-L2066 |
31,269 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.go_to_line | def go_to_line(self, line=None):
"""Open 'go to line' dialog"""
editorstack = self.get_current_editorstack()
if editorstack is not None:
editorstack.go_to_line(line) | python | def go_to_line(self, line=None):
"""Open 'go to line' dialog"""
editorstack = self.get_current_editorstack()
if editorstack is not None:
editorstack.go_to_line(line) | [
"def",
"go_to_line",
"(",
"self",
",",
"line",
"=",
"None",
")",
":",
"editorstack",
"=",
"self",
".",
"get_current_editorstack",
"(",
")",
"if",
"editorstack",
"is",
"not",
"None",
":",
"editorstack",
".",
"go_to_line",
"(",
"line",
")"
] | Open 'go to line' dialog | [
"Open",
"go",
"to",
"line",
"dialog"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2182-L2186 |
31,270 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.clear_all_breakpoints | def clear_all_breakpoints(self):
"""Clear breakpoints in all files"""
self.switch_to_plugin()
clear_all_breakpoints()
self.breakpoints_saved.emit()
editorstack = self.get_current_editorstack()
if editorstack is not None:
for data in editorstack.data:
data.editor.debugger.clear_breakpoints()
self.refresh_plugin() | python | def clear_all_breakpoints(self):
"""Clear breakpoints in all files"""
self.switch_to_plugin()
clear_all_breakpoints()
self.breakpoints_saved.emit()
editorstack = self.get_current_editorstack()
if editorstack is not None:
for data in editorstack.data:
data.editor.debugger.clear_breakpoints()
self.refresh_plugin() | [
"def",
"clear_all_breakpoints",
"(",
"self",
")",
":",
"self",
".",
"switch_to_plugin",
"(",
")",
"clear_all_breakpoints",
"(",
")",
"self",
".",
"breakpoints_saved",
".",
"emit",
"(",
")",
"editorstack",
"=",
"self",
".",
"get_current_editorstack",
"(",
")",
... | Clear breakpoints in all files | [
"Clear",
"breakpoints",
"in",
"all",
"files"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2205-L2214 |
31,271 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.clear_breakpoint | def clear_breakpoint(self, filename, lineno):
"""Remove a single breakpoint"""
clear_breakpoint(filename, lineno)
self.breakpoints_saved.emit()
editorstack = self.get_current_editorstack()
if editorstack is not None:
index = self.is_file_opened(filename)
if index is not None:
editorstack.data[index].editor.debugger.toogle_breakpoint(
lineno) | python | def clear_breakpoint(self, filename, lineno):
"""Remove a single breakpoint"""
clear_breakpoint(filename, lineno)
self.breakpoints_saved.emit()
editorstack = self.get_current_editorstack()
if editorstack is not None:
index = self.is_file_opened(filename)
if index is not None:
editorstack.data[index].editor.debugger.toogle_breakpoint(
lineno) | [
"def",
"clear_breakpoint",
"(",
"self",
",",
"filename",
",",
"lineno",
")",
":",
"clear_breakpoint",
"(",
"filename",
",",
"lineno",
")",
"self",
".",
"breakpoints_saved",
".",
"emit",
"(",
")",
"editorstack",
"=",
"self",
".",
"get_current_editorstack",
"(",... | Remove a single breakpoint | [
"Remove",
"a",
"single",
"breakpoint"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2216-L2225 |
31,272 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.run_file | def run_file(self, debug=False):
"""Run script inside current interpreter or in a new one"""
editorstack = self.get_current_editorstack()
if editorstack.save():
editor = self.get_current_editor()
fname = osp.abspath(self.get_current_filename())
# Get fname's dirname before we escape the single and double
# quotes (Fixes Issue #6771)
dirname = osp.dirname(fname)
# Escape single and double quotes in fname and dirname
# (Fixes Issue #2158)
fname = fname.replace("'", r"\'").replace('"', r'\"')
dirname = dirname.replace("'", r"\'").replace('"', r'\"')
runconf = get_run_configuration(fname)
if runconf is None:
dialog = RunConfigOneDialog(self)
dialog.size_change.connect(lambda s: self.set_dialog_size(s))
if self.dialog_size is not None:
dialog.resize(self.dialog_size)
dialog.setup(fname)
if CONF.get('run', 'open_at_least_once',
not running_under_pytest()):
# Open Run Config dialog at least once: the first time
# a script is ever run in Spyder, so that the user may
# see it at least once and be conscious that it exists
show_dlg = True
CONF.set('run', 'open_at_least_once', False)
else:
# Open Run Config dialog only
# if ALWAYS_OPEN_FIRST_RUN_OPTION option is enabled
show_dlg = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION)
if show_dlg and not dialog.exec_():
return
runconf = dialog.get_configuration()
args = runconf.get_arguments()
python_args = runconf.get_python_arguments()
interact = runconf.interact
post_mortem = runconf.post_mortem
current = runconf.current
systerm = runconf.systerm
clear_namespace = runconf.clear_namespace
if runconf.file_dir:
wdir = dirname
elif runconf.cw_dir:
wdir = ''
elif osp.isdir(runconf.dir):
wdir = runconf.dir
else:
wdir = ''
python = True # Note: in the future, it may be useful to run
# something in a terminal instead of a Python interp.
self.__last_ec_exec = (fname, wdir, args, interact, debug,
python, python_args, current, systerm,
post_mortem, clear_namespace)
self.re_run_file()
if not interact and not debug:
# If external console dockwidget is hidden, it will be
# raised in top-level and so focus will be given to the
# current external shell automatically
# (see SpyderPluginWidget.visibility_changed method)
editor.setFocus() | python | def run_file(self, debug=False):
"""Run script inside current interpreter or in a new one"""
editorstack = self.get_current_editorstack()
if editorstack.save():
editor = self.get_current_editor()
fname = osp.abspath(self.get_current_filename())
# Get fname's dirname before we escape the single and double
# quotes (Fixes Issue #6771)
dirname = osp.dirname(fname)
# Escape single and double quotes in fname and dirname
# (Fixes Issue #2158)
fname = fname.replace("'", r"\'").replace('"', r'\"')
dirname = dirname.replace("'", r"\'").replace('"', r'\"')
runconf = get_run_configuration(fname)
if runconf is None:
dialog = RunConfigOneDialog(self)
dialog.size_change.connect(lambda s: self.set_dialog_size(s))
if self.dialog_size is not None:
dialog.resize(self.dialog_size)
dialog.setup(fname)
if CONF.get('run', 'open_at_least_once',
not running_under_pytest()):
# Open Run Config dialog at least once: the first time
# a script is ever run in Spyder, so that the user may
# see it at least once and be conscious that it exists
show_dlg = True
CONF.set('run', 'open_at_least_once', False)
else:
# Open Run Config dialog only
# if ALWAYS_OPEN_FIRST_RUN_OPTION option is enabled
show_dlg = CONF.get('run', ALWAYS_OPEN_FIRST_RUN_OPTION)
if show_dlg and not dialog.exec_():
return
runconf = dialog.get_configuration()
args = runconf.get_arguments()
python_args = runconf.get_python_arguments()
interact = runconf.interact
post_mortem = runconf.post_mortem
current = runconf.current
systerm = runconf.systerm
clear_namespace = runconf.clear_namespace
if runconf.file_dir:
wdir = dirname
elif runconf.cw_dir:
wdir = ''
elif osp.isdir(runconf.dir):
wdir = runconf.dir
else:
wdir = ''
python = True # Note: in the future, it may be useful to run
# something in a terminal instead of a Python interp.
self.__last_ec_exec = (fname, wdir, args, interact, debug,
python, python_args, current, systerm,
post_mortem, clear_namespace)
self.re_run_file()
if not interact and not debug:
# If external console dockwidget is hidden, it will be
# raised in top-level and so focus will be given to the
# current external shell automatically
# (see SpyderPluginWidget.visibility_changed method)
editor.setFocus() | [
"def",
"run_file",
"(",
"self",
",",
"debug",
"=",
"False",
")",
":",
"editorstack",
"=",
"self",
".",
"get_current_editorstack",
"(",
")",
"if",
"editorstack",
".",
"save",
"(",
")",
":",
"editor",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"fnam... | Run script inside current interpreter or in a new one | [
"Run",
"script",
"inside",
"current",
"interpreter",
"or",
"in",
"a",
"new",
"one"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2251-L2317 |
31,273 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.debug_file | def debug_file(self):
"""Debug current script"""
self.switch_to_plugin()
current_editor = self.get_current_editor()
if current_editor is not None:
current_editor.sig_debug_start.emit()
self.run_file(debug=True) | python | def debug_file(self):
"""Debug current script"""
self.switch_to_plugin()
current_editor = self.get_current_editor()
if current_editor is not None:
current_editor.sig_debug_start.emit()
self.run_file(debug=True) | [
"def",
"debug_file",
"(",
"self",
")",
":",
"self",
".",
"switch_to_plugin",
"(",
")",
"current_editor",
"=",
"self",
".",
"get_current_editor",
"(",
")",
"if",
"current_editor",
"is",
"not",
"None",
":",
"current_editor",
".",
"sig_debug_start",
".",
"emit",
... | Debug current script | [
"Debug",
"current",
"script"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2323-L2329 |
31,274 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.re_run_file | def re_run_file(self):
"""Re-run last script"""
if self.get_option('save_all_before_run'):
self.save_all()
if self.__last_ec_exec is None:
return
(fname, wdir, args, interact, debug,
python, python_args, current, systerm,
post_mortem, clear_namespace) = self.__last_ec_exec
if not systerm:
self.run_in_current_ipyclient.emit(fname, wdir, args,
debug, post_mortem,
current, clear_namespace)
else:
self.main.open_external_console(fname, wdir, args, interact,
debug, python, python_args,
systerm, post_mortem) | python | def re_run_file(self):
"""Re-run last script"""
if self.get_option('save_all_before_run'):
self.save_all()
if self.__last_ec_exec is None:
return
(fname, wdir, args, interact, debug,
python, python_args, current, systerm,
post_mortem, clear_namespace) = self.__last_ec_exec
if not systerm:
self.run_in_current_ipyclient.emit(fname, wdir, args,
debug, post_mortem,
current, clear_namespace)
else:
self.main.open_external_console(fname, wdir, args, interact,
debug, python, python_args,
systerm, post_mortem) | [
"def",
"re_run_file",
"(",
"self",
")",
":",
"if",
"self",
".",
"get_option",
"(",
"'save_all_before_run'",
")",
":",
"self",
".",
"save_all",
"(",
")",
"if",
"self",
".",
"__last_ec_exec",
"is",
"None",
":",
"return",
"(",
"fname",
",",
"wdir",
",",
"... | Re-run last script | [
"Re",
"-",
"run",
"last",
"script"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2332-L2348 |
31,275 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.save_bookmark | def save_bookmark(self, slot_num):
"""Save current line and position as bookmark."""
bookmarks = CONF.get('editor', 'bookmarks')
editorstack = self.get_current_editorstack()
if slot_num in bookmarks:
filename, line_num, column = bookmarks[slot_num]
if osp.isfile(filename):
index = editorstack.has_filename(filename)
if index is not None:
block = (editorstack.tabs.widget(index).document()
.findBlockByNumber(line_num))
block.userData().bookmarks.remove((slot_num, column))
if editorstack is not None:
self.switch_to_plugin()
editorstack.set_bookmark(slot_num) | python | def save_bookmark(self, slot_num):
"""Save current line and position as bookmark."""
bookmarks = CONF.get('editor', 'bookmarks')
editorstack = self.get_current_editorstack()
if slot_num in bookmarks:
filename, line_num, column = bookmarks[slot_num]
if osp.isfile(filename):
index = editorstack.has_filename(filename)
if index is not None:
block = (editorstack.tabs.widget(index).document()
.findBlockByNumber(line_num))
block.userData().bookmarks.remove((slot_num, column))
if editorstack is not None:
self.switch_to_plugin()
editorstack.set_bookmark(slot_num) | [
"def",
"save_bookmark",
"(",
"self",
",",
"slot_num",
")",
":",
"bookmarks",
"=",
"CONF",
".",
"get",
"(",
"'editor'",
",",
"'bookmarks'",
")",
"editorstack",
"=",
"self",
".",
"get_current_editorstack",
"(",
")",
"if",
"slot_num",
"in",
"bookmarks",
":",
... | Save current line and position as bookmark. | [
"Save",
"current",
"line",
"and",
"position",
"as",
"bookmark",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2376-L2390 |
31,276 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.load_bookmark | def load_bookmark(self, slot_num):
"""Set cursor to bookmarked file and position."""
bookmarks = CONF.get('editor', 'bookmarks')
if slot_num in bookmarks:
filename, line_num, column = bookmarks[slot_num]
else:
return
if not osp.isfile(filename):
self.last_edit_cursor_pos = None
return
self.load(filename)
editor = self.get_current_editor()
if line_num < editor.document().lineCount():
linelength = len(editor.document()
.findBlockByNumber(line_num).text())
if column <= linelength:
editor.go_to_line(line_num + 1, column)
else:
# Last column
editor.go_to_line(line_num + 1, linelength) | python | def load_bookmark(self, slot_num):
"""Set cursor to bookmarked file and position."""
bookmarks = CONF.get('editor', 'bookmarks')
if slot_num in bookmarks:
filename, line_num, column = bookmarks[slot_num]
else:
return
if not osp.isfile(filename):
self.last_edit_cursor_pos = None
return
self.load(filename)
editor = self.get_current_editor()
if line_num < editor.document().lineCount():
linelength = len(editor.document()
.findBlockByNumber(line_num).text())
if column <= linelength:
editor.go_to_line(line_num + 1, column)
else:
# Last column
editor.go_to_line(line_num + 1, linelength) | [
"def",
"load_bookmark",
"(",
"self",
",",
"slot_num",
")",
":",
"bookmarks",
"=",
"CONF",
".",
"get",
"(",
"'editor'",
",",
"'bookmarks'",
")",
"if",
"slot_num",
"in",
"bookmarks",
":",
"filename",
",",
"line_num",
",",
"column",
"=",
"bookmarks",
"[",
"... | Set cursor to bookmarked file and position. | [
"Set",
"cursor",
"to",
"bookmarked",
"file",
"and",
"position",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2393-L2412 |
31,277 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.get_open_filenames | def get_open_filenames(self):
"""Get the list of open files in the current stack"""
editorstack = self.editorstacks[0]
filenames = []
filenames += [finfo.filename for finfo in editorstack.data]
return filenames | python | def get_open_filenames(self):
"""Get the list of open files in the current stack"""
editorstack = self.editorstacks[0]
filenames = []
filenames += [finfo.filename for finfo in editorstack.data]
return filenames | [
"def",
"get_open_filenames",
"(",
"self",
")",
":",
"editorstack",
"=",
"self",
".",
"editorstacks",
"[",
"0",
"]",
"filenames",
"=",
"[",
"]",
"filenames",
"+=",
"[",
"finfo",
".",
"filename",
"for",
"finfo",
"in",
"editorstack",
".",
"data",
"]",
"retu... | Get the list of open files in the current stack | [
"Get",
"the",
"list",
"of",
"open",
"files",
"in",
"the",
"current",
"stack"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2577-L2582 |
31,278 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.set_open_filenames | def set_open_filenames(self):
"""
Set the recent opened files on editor based on active project.
If no project is active, then editor filenames are saved, otherwise
the opened filenames are stored in the project config info.
"""
if self.projects is not None:
if not self.projects.get_active_project():
filenames = self.get_open_filenames()
self.set_option('filenames', filenames) | python | def set_open_filenames(self):
"""
Set the recent opened files on editor based on active project.
If no project is active, then editor filenames are saved, otherwise
the opened filenames are stored in the project config info.
"""
if self.projects is not None:
if not self.projects.get_active_project():
filenames = self.get_open_filenames()
self.set_option('filenames', filenames) | [
"def",
"set_open_filenames",
"(",
"self",
")",
":",
"if",
"self",
".",
"projects",
"is",
"not",
"None",
":",
"if",
"not",
"self",
".",
"projects",
".",
"get_active_project",
"(",
")",
":",
"filenames",
"=",
"self",
".",
"get_open_filenames",
"(",
")",
"s... | Set the recent opened files on editor based on active project.
If no project is active, then editor filenames are saved, otherwise
the opened filenames are stored in the project config info. | [
"Set",
"the",
"recent",
"opened",
"files",
"on",
"editor",
"based",
"on",
"active",
"project",
".",
"If",
"no",
"project",
"is",
"active",
"then",
"editor",
"filenames",
"are",
"saved",
"otherwise",
"the",
"opened",
"filenames",
"are",
"stored",
"in",
"the",... | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2584-L2594 |
31,279 | spyder-ide/spyder | spyder/plugins/editor/plugin.py | Editor.setup_open_files | def setup_open_files(self):
"""
Open the list of saved files per project.
Also open any files that the user selected in the recovery dialog.
"""
self.set_create_new_file_if_empty(False)
active_project_path = None
if self.projects is not None:
active_project_path = self.projects.get_active_project_path()
if active_project_path:
filenames = self.projects.get_project_filenames()
else:
filenames = self.get_option('filenames', default=[])
self.close_all_files()
all_filenames = self.autosave.recover_files_to_open + filenames
if all_filenames and any([osp.isfile(f) for f in all_filenames]):
layout = self.get_option('layout_settings', None)
# Check if no saved layout settings exist, e.g. clean prefs file
# If not, load with default focus/layout, to fix issue #8458 .
if layout:
is_vertical, cfname, clines = layout.get('splitsettings')[0]
if cfname in filenames:
index = filenames.index(cfname)
# First we load the last focused file.
self.load(filenames[index], goto=clines[index], set_focus=True)
# Then we load the files located to the left of the last
# focused file in the tabbar, while keeping the focus on
# the last focused file.
if index > 0:
self.load(filenames[index::-1], goto=clines[index::-1],
set_focus=False, add_where='start')
# Then we load the files located to the right of the last
# focused file in the tabbar, while keeping the focus on
# the last focused file.
if index < (len(filenames) - 1):
self.load(filenames[index+1:], goto=clines[index:],
set_focus=False, add_where='end')
# Finally we load any recovered files at the end of the tabbar,
# while keeping focus on the last focused file.
if self.autosave.recover_files_to_open:
self.load(self.autosave.recover_files_to_open,
set_focus=False, add_where='end')
else:
if filenames:
self.load(filenames, goto=clines)
if self.autosave.recover_files_to_open:
self.load(self.autosave.recover_files_to_open)
else:
if filenames:
self.load(filenames)
if self.autosave.recover_files_to_open:
self.load(self.autosave.recover_files_to_open)
if self.__first_open_files_setup:
self.__first_open_files_setup = False
if layout is not None:
self.editorsplitter.set_layout_settings(
layout,
dont_goto=filenames[0])
win_layout = self.get_option('windows_layout_settings', [])
if win_layout:
for layout_settings in win_layout:
self.editorwindows_to_be_created.append(
layout_settings)
self.set_last_focus_editorstack(self, self.editorstacks[0])
else:
self.__load_temp_file()
self.set_create_new_file_if_empty(True) | python | def setup_open_files(self):
"""
Open the list of saved files per project.
Also open any files that the user selected in the recovery dialog.
"""
self.set_create_new_file_if_empty(False)
active_project_path = None
if self.projects is not None:
active_project_path = self.projects.get_active_project_path()
if active_project_path:
filenames = self.projects.get_project_filenames()
else:
filenames = self.get_option('filenames', default=[])
self.close_all_files()
all_filenames = self.autosave.recover_files_to_open + filenames
if all_filenames and any([osp.isfile(f) for f in all_filenames]):
layout = self.get_option('layout_settings', None)
# Check if no saved layout settings exist, e.g. clean prefs file
# If not, load with default focus/layout, to fix issue #8458 .
if layout:
is_vertical, cfname, clines = layout.get('splitsettings')[0]
if cfname in filenames:
index = filenames.index(cfname)
# First we load the last focused file.
self.load(filenames[index], goto=clines[index], set_focus=True)
# Then we load the files located to the left of the last
# focused file in the tabbar, while keeping the focus on
# the last focused file.
if index > 0:
self.load(filenames[index::-1], goto=clines[index::-1],
set_focus=False, add_where='start')
# Then we load the files located to the right of the last
# focused file in the tabbar, while keeping the focus on
# the last focused file.
if index < (len(filenames) - 1):
self.load(filenames[index+1:], goto=clines[index:],
set_focus=False, add_where='end')
# Finally we load any recovered files at the end of the tabbar,
# while keeping focus on the last focused file.
if self.autosave.recover_files_to_open:
self.load(self.autosave.recover_files_to_open,
set_focus=False, add_where='end')
else:
if filenames:
self.load(filenames, goto=clines)
if self.autosave.recover_files_to_open:
self.load(self.autosave.recover_files_to_open)
else:
if filenames:
self.load(filenames)
if self.autosave.recover_files_to_open:
self.load(self.autosave.recover_files_to_open)
if self.__first_open_files_setup:
self.__first_open_files_setup = False
if layout is not None:
self.editorsplitter.set_layout_settings(
layout,
dont_goto=filenames[0])
win_layout = self.get_option('windows_layout_settings', [])
if win_layout:
for layout_settings in win_layout:
self.editorwindows_to_be_created.append(
layout_settings)
self.set_last_focus_editorstack(self, self.editorstacks[0])
else:
self.__load_temp_file()
self.set_create_new_file_if_empty(True) | [
"def",
"setup_open_files",
"(",
"self",
")",
":",
"self",
".",
"set_create_new_file_if_empty",
"(",
"False",
")",
"active_project_path",
"=",
"None",
"if",
"self",
".",
"projects",
"is",
"not",
"None",
":",
"active_project_path",
"=",
"self",
".",
"projects",
... | Open the list of saved files per project.
Also open any files that the user selected in the recovery dialog. | [
"Open",
"the",
"list",
"of",
"saved",
"files",
"per",
"project",
".",
"Also",
"open",
"any",
"files",
"that",
"the",
"user",
"selected",
"in",
"the",
"recovery",
"dialog",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/plugin.py#L2596-L2666 |
31,280 | spyder-ide/spyder | spyder/plugins/console/utils/interpreter.py | Interpreter.raw_input_replacement | def raw_input_replacement(self, prompt=''):
"""For raw_input builtin function emulation"""
self.widget_proxy.wait_input(prompt)
self.input_condition.acquire()
while not self.widget_proxy.data_available():
self.input_condition.wait()
inp = self.widget_proxy.input_data
self.input_condition.release()
return inp | python | def raw_input_replacement(self, prompt=''):
"""For raw_input builtin function emulation"""
self.widget_proxy.wait_input(prompt)
self.input_condition.acquire()
while not self.widget_proxy.data_available():
self.input_condition.wait()
inp = self.widget_proxy.input_data
self.input_condition.release()
return inp | [
"def",
"raw_input_replacement",
"(",
"self",
",",
"prompt",
"=",
"''",
")",
":",
"self",
".",
"widget_proxy",
".",
"wait_input",
"(",
"prompt",
")",
"self",
".",
"input_condition",
".",
"acquire",
"(",
")",
"while",
"not",
"self",
".",
"widget_proxy",
".",... | For raw_input builtin function emulation | [
"For",
"raw_input",
"builtin",
"function",
"emulation"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L112-L120 |
31,281 | spyder-ide/spyder | spyder/plugins/console/utils/interpreter.py | Interpreter.get_thread_id | def get_thread_id(self):
"""Return thread id"""
if self._id is None:
for thread_id, obj in list(threading._active.items()):
if obj is self:
self._id = thread_id
return self._id | python | def get_thread_id(self):
"""Return thread id"""
if self._id is None:
for thread_id, obj in list(threading._active.items()):
if obj is self:
self._id = thread_id
return self._id | [
"def",
"get_thread_id",
"(",
"self",
")",
":",
"if",
"self",
".",
"_id",
"is",
"None",
":",
"for",
"thread_id",
",",
"obj",
"in",
"list",
"(",
"threading",
".",
"_active",
".",
"items",
"(",
")",
")",
":",
"if",
"obj",
"is",
"self",
":",
"self",
... | Return thread id | [
"Return",
"thread",
"id"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/console/utils/interpreter.py#L247-L253 |
31,282 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/texteditor.py | TextEditor.text_changed | def text_changed(self):
"""Text has changed"""
# Save text as bytes, if it was initially bytes
if self.is_binary:
self.text = to_binary_string(self.edit.toPlainText(), 'utf8')
else:
self.text = to_text_string(self.edit.toPlainText())
if self.btn_save_and_close:
self.btn_save_and_close.setEnabled(True)
self.btn_save_and_close.setAutoDefault(True)
self.btn_save_and_close.setDefault(True) | python | def text_changed(self):
"""Text has changed"""
# Save text as bytes, if it was initially bytes
if self.is_binary:
self.text = to_binary_string(self.edit.toPlainText(), 'utf8')
else:
self.text = to_text_string(self.edit.toPlainText())
if self.btn_save_and_close:
self.btn_save_and_close.setEnabled(True)
self.btn_save_and_close.setAutoDefault(True)
self.btn_save_and_close.setDefault(True) | [
"def",
"text_changed",
"(",
"self",
")",
":",
"# Save text as bytes, if it was initially bytes\r",
"if",
"self",
".",
"is_binary",
":",
"self",
".",
"text",
"=",
"to_binary_string",
"(",
"self",
".",
"edit",
".",
"toPlainText",
"(",
")",
",",
"'utf8'",
")",
"e... | Text has changed | [
"Text",
"has",
"changed"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/texteditor.py#L98-L108 |
31,283 | spyder-ide/spyder | spyder/plugins/editor/lsp/transport/main.py | logger_init | def logger_init(level):
"""
Initialize the logger for this thread.
Sets the log level to ERROR (0), WARNING (1), INFO (2), or DEBUG (3),
depending on the argument `level`.
"""
levellist = [logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG]
handler = logging.StreamHandler()
fmt = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
'-35s %(lineno) -5d: %(message)s')
handler.setFormatter(logging.Formatter(fmt))
logger = logging.root
logger.addHandler(handler)
logger.setLevel(levellist[level]) | python | def logger_init(level):
"""
Initialize the logger for this thread.
Sets the log level to ERROR (0), WARNING (1), INFO (2), or DEBUG (3),
depending on the argument `level`.
"""
levellist = [logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG]
handler = logging.StreamHandler()
fmt = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
'-35s %(lineno) -5d: %(message)s')
handler.setFormatter(logging.Formatter(fmt))
logger = logging.root
logger.addHandler(handler)
logger.setLevel(levellist[level]) | [
"def",
"logger_init",
"(",
"level",
")",
":",
"levellist",
"=",
"[",
"logging",
".",
"ERROR",
",",
"logging",
".",
"WARNING",
",",
"logging",
".",
"INFO",
",",
"logging",
".",
"DEBUG",
"]",
"handler",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"fm... | Initialize the logger for this thread.
Sets the log level to ERROR (0), WARNING (1), INFO (2), or DEBUG (3),
depending on the argument `level`. | [
"Initialize",
"the",
"logger",
"for",
"this",
"thread",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/transport/main.py#L62-L76 |
31,284 | spyder-ide/spyder | spyder/plugins/editor/lsp/transport/main.py | SignalManager.restore | def restore(self):
"""Restore signal handlers to their original settings."""
signal.signal(signal.SIGINT, self.original_sigint)
signal.signal(signal.SIGTERM, self.original_sigterm)
if os.name == 'nt':
signal.signal(signal.SIGBREAK, self.original_sigbreak) | python | def restore(self):
"""Restore signal handlers to their original settings."""
signal.signal(signal.SIGINT, self.original_sigint)
signal.signal(signal.SIGTERM, self.original_sigterm)
if os.name == 'nt':
signal.signal(signal.SIGBREAK, self.original_sigbreak) | [
"def",
"restore",
"(",
"self",
")",
":",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"self",
".",
"original_sigint",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"self",
".",
"original_sigterm",
")",
"if",
"os",
"."... | Restore signal handlers to their original settings. | [
"Restore",
"signal",
"handlers",
"to",
"their",
"original",
"settings",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/transport/main.py#L102-L107 |
31,285 | spyder-ide/spyder | spyder/requirements.py | show_warning | def show_warning(message):
"""Show warning using Tkinter if available"""
try:
# If Tkinter is installed (highly probable), showing an error pop-up
import Tkinter, tkMessageBox
root = Tkinter.Tk()
root.withdraw()
tkMessageBox.showerror("Spyder", message)
except ImportError:
pass
raise RuntimeError(message) | python | def show_warning(message):
"""Show warning using Tkinter if available"""
try:
# If Tkinter is installed (highly probable), showing an error pop-up
import Tkinter, tkMessageBox
root = Tkinter.Tk()
root.withdraw()
tkMessageBox.showerror("Spyder", message)
except ImportError:
pass
raise RuntimeError(message) | [
"def",
"show_warning",
"(",
"message",
")",
":",
"try",
":",
"# If Tkinter is installed (highly probable), showing an error pop-up\r",
"import",
"Tkinter",
",",
"tkMessageBox",
"root",
"=",
"Tkinter",
".",
"Tk",
"(",
")",
"root",
".",
"withdraw",
"(",
")",
"tkMessag... | Show warning using Tkinter if available | [
"Show",
"warning",
"using",
"Tkinter",
"if",
"available"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/requirements.py#L14-L24 |
31,286 | spyder-ide/spyder | spyder/requirements.py | check_qt | def check_qt():
"""Check Qt binding requirements"""
qt_infos = dict(pyqt5=("PyQt5", "5.6"))
try:
import qtpy
package_name, required_ver = qt_infos[qtpy.API]
actual_ver = qtpy.PYQT_VERSION
if LooseVersion(actual_ver) < LooseVersion(required_ver):
show_warning("Please check Spyder installation requirements:\n"
"%s %s+ is required (found v%s)."
% (package_name, required_ver, actual_ver))
except ImportError:
show_warning("Failed to import qtpy.\n"
"Please check Spyder installation requirements:\n\n"
"qtpy 1.2.0+ and\n"
"%s %s+\n\n"
"are required to run Spyder."
% (qt_infos['pyqt5'])) | python | def check_qt():
"""Check Qt binding requirements"""
qt_infos = dict(pyqt5=("PyQt5", "5.6"))
try:
import qtpy
package_name, required_ver = qt_infos[qtpy.API]
actual_ver = qtpy.PYQT_VERSION
if LooseVersion(actual_ver) < LooseVersion(required_ver):
show_warning("Please check Spyder installation requirements:\n"
"%s %s+ is required (found v%s)."
% (package_name, required_ver, actual_ver))
except ImportError:
show_warning("Failed to import qtpy.\n"
"Please check Spyder installation requirements:\n\n"
"qtpy 1.2.0+ and\n"
"%s %s+\n\n"
"are required to run Spyder."
% (qt_infos['pyqt5'])) | [
"def",
"check_qt",
"(",
")",
":",
"qt_infos",
"=",
"dict",
"(",
"pyqt5",
"=",
"(",
"\"PyQt5\"",
",",
"\"5.6\"",
")",
")",
"try",
":",
"import",
"qtpy",
"package_name",
",",
"required_ver",
"=",
"qt_infos",
"[",
"qtpy",
".",
"API",
"]",
"actual_ver",
"=... | Check Qt binding requirements | [
"Check",
"Qt",
"binding",
"requirements"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/requirements.py#L37-L54 |
31,287 | spyder-ide/spyder | spyder/requirements.py | check_spyder_kernels | def check_spyder_kernels():
"""Check spyder-kernel requirement."""
try:
import spyder_kernels
required_ver = '1.0.0'
actual_ver = spyder_kernels.__version__
if LooseVersion(actual_ver) < LooseVersion(required_ver):
show_warning("Please check Spyder installation requirements:\n"
"spyder-kernels >= 1.0 is required (found %s)."
% actual_ver)
except ImportError:
show_warning("Failed to import spyder-kernels.\n"
"Please check Spyder installation requirements:\n\n"
"spyder-kernels >= 1.0 is required") | python | def check_spyder_kernels():
"""Check spyder-kernel requirement."""
try:
import spyder_kernels
required_ver = '1.0.0'
actual_ver = spyder_kernels.__version__
if LooseVersion(actual_ver) < LooseVersion(required_ver):
show_warning("Please check Spyder installation requirements:\n"
"spyder-kernels >= 1.0 is required (found %s)."
% actual_ver)
except ImportError:
show_warning("Failed to import spyder-kernels.\n"
"Please check Spyder installation requirements:\n\n"
"spyder-kernels >= 1.0 is required") | [
"def",
"check_spyder_kernels",
"(",
")",
":",
"try",
":",
"import",
"spyder_kernels",
"required_ver",
"=",
"'1.0.0'",
"actual_ver",
"=",
"spyder_kernels",
".",
"__version__",
"if",
"LooseVersion",
"(",
"actual_ver",
")",
"<",
"LooseVersion",
"(",
"required_ver",
"... | Check spyder-kernel requirement. | [
"Check",
"spyder",
"-",
"kernel",
"requirement",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/requirements.py#L57-L70 |
31,288 | spyder-ide/spyder | spyder/utils/external/lockfile.py | isLocked | def isLocked(name):
"""Determine if the lock of the given name is held or not.
@type name: C{str}
@param name: The filesystem path to the lock to test
@rtype: C{bool}
@return: True if the lock is held, False otherwise.
"""
l = FilesystemLock(name)
result = None
try:
result = l.lock()
finally:
if result:
l.unlock()
return not result | python | def isLocked(name):
"""Determine if the lock of the given name is held or not.
@type name: C{str}
@param name: The filesystem path to the lock to test
@rtype: C{bool}
@return: True if the lock is held, False otherwise.
"""
l = FilesystemLock(name)
result = None
try:
result = l.lock()
finally:
if result:
l.unlock()
return not result | [
"def",
"isLocked",
"(",
"name",
")",
":",
"l",
"=",
"FilesystemLock",
"(",
"name",
")",
"result",
"=",
"None",
"try",
":",
"result",
"=",
"l",
".",
"lock",
"(",
")",
"finally",
":",
"if",
"result",
":",
"l",
".",
"unlock",
"(",
")",
"return",
"no... | Determine if the lock of the given name is held or not.
@type name: C{str}
@param name: The filesystem path to the lock to test
@rtype: C{bool}
@return: True if the lock is held, False otherwise. | [
"Determine",
"if",
"the",
"lock",
"of",
"the",
"given",
"name",
"is",
"held",
"or",
"not",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/external/lockfile.py#L248-L264 |
31,289 | spyder-ide/spyder | spyder/utils/external/lockfile.py | FilesystemLock.lock | def lock(self):
"""
Acquire this lock.
@rtype: C{bool}
@return: True if the lock is acquired, false otherwise.
@raise: Any exception os.symlink() may raise, other than
EEXIST.
"""
clean = True
while True:
try:
symlink(str(os.getpid()), self.name)
except OSError as e:
if _windows and e.errno in (errno.EACCES, errno.EIO):
# The lock is in the middle of being deleted because we're
# on Windows where lock removal isn't atomic. Give up, we
# don't know how long this is going to take.
return False
if e.errno == errno.EEXIST:
try:
pid = readlink(self.name)
except OSError as e:
if e.errno == errno.ENOENT:
# The lock has vanished, try to claim it in the
# next iteration through the loop.
continue
raise
except IOError as e:
if _windows and e.errno == errno.EACCES:
# The lock is in the middle of being
# deleted because we're on Windows where
# lock removal isn't atomic. Give up, we
# don't know how long this is going to
# take.
return False
raise
try:
if kill is not None:
kill(int(pid), 0)
# Verify that the running process corresponds to
# a Spyder one
p = psutil.Process(int(pid))
# Valid names for main script
names = set(['spyder', 'spyder3', 'spyder.exe',
'spyder3.exe', 'bootstrap.py',
'spyder-script.py'])
if running_under_pytest():
names.add('runtests.py')
# Check the first three command line arguments
arguments = set(os.path.basename(arg)
for arg in p.cmdline()[:3])
conditions = [names & arguments]
if not any(conditions):
raise(OSError(errno.ESRCH, 'No such process'))
except OSError as e:
if e.errno == errno.ESRCH:
# The owner has vanished, try to claim it in the
# next iteration through the loop.
try:
rmlink(self.name)
except OSError as e:
if e.errno == errno.ENOENT:
# Another process cleaned up the lock.
# Race them to acquire it in the next
# iteration through the loop.
continue
raise
clean = False
continue
raise
return False
raise
self.locked = True
self.clean = clean
return True | python | def lock(self):
"""
Acquire this lock.
@rtype: C{bool}
@return: True if the lock is acquired, false otherwise.
@raise: Any exception os.symlink() may raise, other than
EEXIST.
"""
clean = True
while True:
try:
symlink(str(os.getpid()), self.name)
except OSError as e:
if _windows and e.errno in (errno.EACCES, errno.EIO):
# The lock is in the middle of being deleted because we're
# on Windows where lock removal isn't atomic. Give up, we
# don't know how long this is going to take.
return False
if e.errno == errno.EEXIST:
try:
pid = readlink(self.name)
except OSError as e:
if e.errno == errno.ENOENT:
# The lock has vanished, try to claim it in the
# next iteration through the loop.
continue
raise
except IOError as e:
if _windows and e.errno == errno.EACCES:
# The lock is in the middle of being
# deleted because we're on Windows where
# lock removal isn't atomic. Give up, we
# don't know how long this is going to
# take.
return False
raise
try:
if kill is not None:
kill(int(pid), 0)
# Verify that the running process corresponds to
# a Spyder one
p = psutil.Process(int(pid))
# Valid names for main script
names = set(['spyder', 'spyder3', 'spyder.exe',
'spyder3.exe', 'bootstrap.py',
'spyder-script.py'])
if running_under_pytest():
names.add('runtests.py')
# Check the first three command line arguments
arguments = set(os.path.basename(arg)
for arg in p.cmdline()[:3])
conditions = [names & arguments]
if not any(conditions):
raise(OSError(errno.ESRCH, 'No such process'))
except OSError as e:
if e.errno == errno.ESRCH:
# The owner has vanished, try to claim it in the
# next iteration through the loop.
try:
rmlink(self.name)
except OSError as e:
if e.errno == errno.ENOENT:
# Another process cleaned up the lock.
# Race them to acquire it in the next
# iteration through the loop.
continue
raise
clean = False
continue
raise
return False
raise
self.locked = True
self.clean = clean
return True | [
"def",
"lock",
"(",
"self",
")",
":",
"clean",
"=",
"True",
"while",
"True",
":",
"try",
":",
"symlink",
"(",
"str",
"(",
"os",
".",
"getpid",
"(",
")",
")",
",",
"self",
".",
"name",
")",
"except",
"OSError",
"as",
"e",
":",
"if",
"_windows",
... | Acquire this lock.
@rtype: C{bool}
@return: True if the lock is acquired, false otherwise.
@raise: Any exception os.symlink() may raise, other than
EEXIST. | [
"Acquire",
"this",
"lock",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/external/lockfile.py#L152-L230 |
31,290 | spyder-ide/spyder | spyder/utils/external/lockfile.py | FilesystemLock.unlock | def unlock(self):
"""
Release this lock.
This deletes the directory with the given name.
@raise: Any exception os.readlink() may raise, or
ValueError if the lock is not owned by this process.
"""
pid = readlink(self.name)
if int(pid) != os.getpid():
raise ValueError("Lock %r not owned by this process" % (self.name,))
rmlink(self.name)
self.locked = False | python | def unlock(self):
"""
Release this lock.
This deletes the directory with the given name.
@raise: Any exception os.readlink() may raise, or
ValueError if the lock is not owned by this process.
"""
pid = readlink(self.name)
if int(pid) != os.getpid():
raise ValueError("Lock %r not owned by this process" % (self.name,))
rmlink(self.name)
self.locked = False | [
"def",
"unlock",
"(",
"self",
")",
":",
"pid",
"=",
"readlink",
"(",
"self",
".",
"name",
")",
"if",
"int",
"(",
"pid",
")",
"!=",
"os",
".",
"getpid",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"Lock %r not owned by this process\"",
"%",
"(",
"self"... | Release this lock.
This deletes the directory with the given name.
@raise: Any exception os.readlink() may raise, or
ValueError if the lock is not owned by this process. | [
"Release",
"this",
"lock",
".",
"This",
"deletes",
"the",
"directory",
"with",
"the",
"given",
"name",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/external/lockfile.py#L232-L245 |
31,291 | spyder-ide/spyder | spyder/plugins/help/utils/sphinxthread.py | SphinxThread.render | def render(self, doc, context=None, math_option=False, img_path='',
css_path=CSS_PATH):
"""Start thread to render a given documentation"""
# If the thread is already running wait for it to finish before
# starting it again.
if self.wait():
self.doc = doc
self.context = context
self.math_option = math_option
self.img_path = img_path
self.css_path = css_path
# This causes run() to be executed in separate thread
self.start() | python | def render(self, doc, context=None, math_option=False, img_path='',
css_path=CSS_PATH):
"""Start thread to render a given documentation"""
# If the thread is already running wait for it to finish before
# starting it again.
if self.wait():
self.doc = doc
self.context = context
self.math_option = math_option
self.img_path = img_path
self.css_path = css_path
# This causes run() to be executed in separate thread
self.start() | [
"def",
"render",
"(",
"self",
",",
"doc",
",",
"context",
"=",
"None",
",",
"math_option",
"=",
"False",
",",
"img_path",
"=",
"''",
",",
"css_path",
"=",
"CSS_PATH",
")",
":",
"# If the thread is already running wait for it to finish before",
"# starting it again."... | Start thread to render a given documentation | [
"Start",
"thread",
"to",
"render",
"a",
"given",
"documentation"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/utils/sphinxthread.py#L48-L60 |
31,292 | spyder-ide/spyder | spyder/preferences/languageserver.py | LSPServerTable.selection | def selection(self, index):
"""Update selected row."""
self.update()
self.isActiveWindow()
self._parent.delete_btn.setEnabled(True) | python | def selection(self, index):
"""Update selected row."""
self.update()
self.isActiveWindow()
self._parent.delete_btn.setEnabled(True) | [
"def",
"selection",
"(",
"self",
",",
"index",
")",
":",
"self",
".",
"update",
"(",
")",
"self",
".",
"isActiveWindow",
"(",
")",
"self",
".",
"_parent",
".",
"delete_btn",
".",
"setEnabled",
"(",
"True",
")"
] | Update selected row. | [
"Update",
"selected",
"row",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L512-L516 |
31,293 | spyder-ide/spyder | spyder/preferences/languageserver.py | LSPManagerConfigPage.setup_docstring_style_convention | def setup_docstring_style_convention(self, text):
"""Handle convention changes."""
if text == 'Custom':
self.docstring_style_select.label.setText(
_("Show the following errors:"))
self.docstring_style_ignore.label.setText(
_("Ignore the following errors:"))
else:
self.docstring_style_select.label.setText(
_("Show the following errors in addition "
"to the specified convention:"))
self.docstring_style_ignore.label.setText(
_("Ignore the following errors in addition "
"to the specified convention:")) | python | def setup_docstring_style_convention(self, text):
"""Handle convention changes."""
if text == 'Custom':
self.docstring_style_select.label.setText(
_("Show the following errors:"))
self.docstring_style_ignore.label.setText(
_("Ignore the following errors:"))
else:
self.docstring_style_select.label.setText(
_("Show the following errors in addition "
"to the specified convention:"))
self.docstring_style_ignore.label.setText(
_("Ignore the following errors in addition "
"to the specified convention:")) | [
"def",
"setup_docstring_style_convention",
"(",
"self",
",",
"text",
")",
":",
"if",
"text",
"==",
"'Custom'",
":",
"self",
".",
"docstring_style_select",
".",
"label",
".",
"setText",
"(",
"_",
"(",
"\"Show the following errors:\"",
")",
")",
"self",
".",
"do... | Handle convention changes. | [
"Handle",
"convention",
"changes",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/languageserver.py#L955-L968 |
31,294 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | SearchInComboBox.add_external_path | def add_external_path(self, path):
"""
Adds an external path to the combobox if it exists on the file system.
If the path is already listed in the combobox, it is removed from its
current position and added back at the end. If the maximum number of
paths is reached, the oldest external path is removed from the list.
"""
if not osp.exists(path):
return
self.removeItem(self.findText(path))
self.addItem(path)
self.setItemData(self.count() - 1, path, Qt.ToolTipRole)
while self.count() > MAX_PATH_HISTORY + EXTERNAL_PATHS:
self.removeItem(EXTERNAL_PATHS) | python | def add_external_path(self, path):
"""
Adds an external path to the combobox if it exists on the file system.
If the path is already listed in the combobox, it is removed from its
current position and added back at the end. If the maximum number of
paths is reached, the oldest external path is removed from the list.
"""
if not osp.exists(path):
return
self.removeItem(self.findText(path))
self.addItem(path)
self.setItemData(self.count() - 1, path, Qt.ToolTipRole)
while self.count() > MAX_PATH_HISTORY + EXTERNAL_PATHS:
self.removeItem(EXTERNAL_PATHS) | [
"def",
"add_external_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"osp",
".",
"exists",
"(",
"path",
")",
":",
"return",
"self",
".",
"removeItem",
"(",
"self",
".",
"findText",
"(",
"path",
")",
")",
"self",
".",
"addItem",
"(",
"path",
... | Adds an external path to the combobox if it exists on the file system.
If the path is already listed in the combobox, it is removed from its
current position and added back at the end. If the maximum number of
paths is reached, the oldest external path is removed from the list. | [
"Adds",
"an",
"external",
"path",
"to",
"the",
"combobox",
"if",
"it",
"exists",
"on",
"the",
"file",
"system",
".",
"If",
"the",
"path",
"is",
"already",
"listed",
"in",
"the",
"combobox",
"it",
"is",
"removed",
"from",
"its",
"current",
"position",
"an... | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L273-L286 |
31,295 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | SearchInComboBox.get_external_paths | def get_external_paths(self):
"""Returns a list of the external paths listed in the combobox."""
return [to_text_string(self.itemText(i))
for i in range(EXTERNAL_PATHS, self.count())] | python | def get_external_paths(self):
"""Returns a list of the external paths listed in the combobox."""
return [to_text_string(self.itemText(i))
for i in range(EXTERNAL_PATHS, self.count())] | [
"def",
"get_external_paths",
"(",
"self",
")",
":",
"return",
"[",
"to_text_string",
"(",
"self",
".",
"itemText",
"(",
"i",
")",
")",
"for",
"i",
"in",
"range",
"(",
"EXTERNAL_PATHS",
",",
"self",
".",
"count",
"(",
")",
")",
"]"
] | Returns a list of the external paths listed in the combobox. | [
"Returns",
"a",
"list",
"of",
"the",
"external",
"paths",
"listed",
"in",
"the",
"combobox",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L288-L291 |
31,296 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | SearchInComboBox.get_current_searchpath | def get_current_searchpath(self):
"""
Returns the path corresponding to the currently selected item
in the combobox.
"""
idx = self.currentIndex()
if idx == CWD:
return self.path
elif idx == PROJECT:
return self.project_path
elif idx == FILE_PATH:
return self.file_path
else:
return self.external_path | python | def get_current_searchpath(self):
"""
Returns the path corresponding to the currently selected item
in the combobox.
"""
idx = self.currentIndex()
if idx == CWD:
return self.path
elif idx == PROJECT:
return self.project_path
elif idx == FILE_PATH:
return self.file_path
else:
return self.external_path | [
"def",
"get_current_searchpath",
"(",
"self",
")",
":",
"idx",
"=",
"self",
".",
"currentIndex",
"(",
")",
"if",
"idx",
"==",
"CWD",
":",
"return",
"self",
".",
"path",
"elif",
"idx",
"==",
"PROJECT",
":",
"return",
"self",
".",
"project_path",
"elif",
... | Returns the path corresponding to the currently selected item
in the combobox. | [
"Returns",
"the",
"path",
"corresponding",
"to",
"the",
"currently",
"selected",
"item",
"in",
"the",
"combobox",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L298-L311 |
31,297 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | SearchInComboBox.path_selection_changed | def path_selection_changed(self):
"""Handles when the current index of the combobox changes."""
idx = self.currentIndex()
if idx == SELECT_OTHER:
external_path = self.select_directory()
if len(external_path) > 0:
self.add_external_path(external_path)
self.setCurrentIndex(self.count() - 1)
else:
self.setCurrentIndex(CWD)
elif idx == CLEAR_LIST:
reply = QMessageBox.question(
self, _("Clear other directories"),
_("Do you want to clear the list of other directories?"),
QMessageBox.Yes | QMessageBox.No)
if reply == QMessageBox.Yes:
self.clear_external_paths()
self.setCurrentIndex(CWD)
elif idx >= EXTERNAL_PATHS:
self.external_path = to_text_string(self.itemText(idx)) | python | def path_selection_changed(self):
"""Handles when the current index of the combobox changes."""
idx = self.currentIndex()
if idx == SELECT_OTHER:
external_path = self.select_directory()
if len(external_path) > 0:
self.add_external_path(external_path)
self.setCurrentIndex(self.count() - 1)
else:
self.setCurrentIndex(CWD)
elif idx == CLEAR_LIST:
reply = QMessageBox.question(
self, _("Clear other directories"),
_("Do you want to clear the list of other directories?"),
QMessageBox.Yes | QMessageBox.No)
if reply == QMessageBox.Yes:
self.clear_external_paths()
self.setCurrentIndex(CWD)
elif idx >= EXTERNAL_PATHS:
self.external_path = to_text_string(self.itemText(idx)) | [
"def",
"path_selection_changed",
"(",
"self",
")",
":",
"idx",
"=",
"self",
".",
"currentIndex",
"(",
")",
"if",
"idx",
"==",
"SELECT_OTHER",
":",
"external_path",
"=",
"self",
".",
"select_directory",
"(",
")",
"if",
"len",
"(",
"external_path",
")",
">",... | Handles when the current index of the combobox changes. | [
"Handles",
"when",
"the",
"current",
"index",
"of",
"the",
"combobox",
"changes",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L321-L340 |
31,298 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | SearchInComboBox.set_project_path | def set_project_path(self, path):
"""
Sets the project path and disables the project search in the combobox
if the value of path is None.
"""
if path is None:
self.project_path = None
self.model().item(PROJECT, 0).setEnabled(False)
if self.currentIndex() == PROJECT:
self.setCurrentIndex(CWD)
else:
path = osp.abspath(path)
self.project_path = path
self.model().item(PROJECT, 0).setEnabled(True) | python | def set_project_path(self, path):
"""
Sets the project path and disables the project search in the combobox
if the value of path is None.
"""
if path is None:
self.project_path = None
self.model().item(PROJECT, 0).setEnabled(False)
if self.currentIndex() == PROJECT:
self.setCurrentIndex(CWD)
else:
path = osp.abspath(path)
self.project_path = path
self.model().item(PROJECT, 0).setEnabled(True) | [
"def",
"set_project_path",
"(",
"self",
",",
"path",
")",
":",
"if",
"path",
"is",
"None",
":",
"self",
".",
"project_path",
"=",
"None",
"self",
".",
"model",
"(",
")",
".",
"item",
"(",
"PROJECT",
",",
"0",
")",
".",
"setEnabled",
"(",
"False",
"... | Sets the project path and disables the project search in the combobox
if the value of path is None. | [
"Sets",
"the",
"project",
"path",
"and",
"disables",
"the",
"project",
"search",
"in",
"the",
"combobox",
"if",
"the",
"value",
"of",
"path",
"is",
"None",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L353-L366 |
31,299 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | SearchInComboBox.eventFilter | def eventFilter(self, widget, event):
"""Used to handle key events on the QListView of the combobox."""
if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Delete:
index = self.view().currentIndex().row()
if index >= EXTERNAL_PATHS:
# Remove item and update the view.
self.removeItem(index)
self.showPopup()
# Set the view selection so that it doesn't bounce around.
new_index = min(self.count() - 1, index)
new_index = 0 if new_index < EXTERNAL_PATHS else new_index
self.view().setCurrentIndex(self.model().index(new_index, 0))
self.setCurrentIndex(new_index)
return True
return QComboBox.eventFilter(self, widget, event) | python | def eventFilter(self, widget, event):
"""Used to handle key events on the QListView of the combobox."""
if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Delete:
index = self.view().currentIndex().row()
if index >= EXTERNAL_PATHS:
# Remove item and update the view.
self.removeItem(index)
self.showPopup()
# Set the view selection so that it doesn't bounce around.
new_index = min(self.count() - 1, index)
new_index = 0 if new_index < EXTERNAL_PATHS else new_index
self.view().setCurrentIndex(self.model().index(new_index, 0))
self.setCurrentIndex(new_index)
return True
return QComboBox.eventFilter(self, widget, event) | [
"def",
"eventFilter",
"(",
"self",
",",
"widget",
",",
"event",
")",
":",
"if",
"event",
".",
"type",
"(",
")",
"==",
"QEvent",
".",
"KeyPress",
"and",
"event",
".",
"key",
"(",
")",
"==",
"Qt",
".",
"Key_Delete",
":",
"index",
"=",
"self",
".",
... | Used to handle key events on the QListView of the combobox. | [
"Used",
"to",
"handle",
"key",
"events",
"on",
"the",
"QListView",
"of",
"the",
"combobox",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L368-L382 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.