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,300 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | SearchInComboBox.__redirect_stdio_emit | def __redirect_stdio_emit(self, value):
"""
Searches through the parent tree to see if it is possible to emit the
redirect_stdio signal.
This logic allows to test the SearchInComboBox select_directory method
outside of the FindInFiles plugin.
"""
parent = self.parent()
while parent is not None:
try:
parent.redirect_stdio.emit(value)
except AttributeError:
parent = parent.parent()
else:
break | python | def __redirect_stdio_emit(self, value):
"""
Searches through the parent tree to see if it is possible to emit the
redirect_stdio signal.
This logic allows to test the SearchInComboBox select_directory method
outside of the FindInFiles plugin.
"""
parent = self.parent()
while parent is not None:
try:
parent.redirect_stdio.emit(value)
except AttributeError:
parent = parent.parent()
else:
break | [
"def",
"__redirect_stdio_emit",
"(",
"self",
",",
"value",
")",
":",
"parent",
"=",
"self",
".",
"parent",
"(",
")",
"while",
"parent",
"is",
"not",
"None",
":",
"try",
":",
"parent",
".",
"redirect_stdio",
".",
"emit",
"(",
"value",
")",
"except",
"At... | Searches through the parent tree to see if it is possible to emit the
redirect_stdio signal.
This logic allows to test the SearchInComboBox select_directory method
outside of the FindInFiles plugin. | [
"Searches",
"through",
"the",
"parent",
"tree",
"to",
"see",
"if",
"it",
"is",
"possible",
"to",
"emit",
"the",
"redirect_stdio",
"signal",
".",
"This",
"logic",
"allows",
"to",
"test",
"the",
"SearchInComboBox",
"select_directory",
"method",
"outside",
"of",
... | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L384-L398 |
31,301 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | FindOptions.keyPressEvent | def keyPressEvent(self, event):
"""Reimplemented to handle key events"""
ctrl = event.modifiers() & Qt.ControlModifier
shift = event.modifiers() & Qt.ShiftModifier
if event.key() in (Qt.Key_Enter, Qt.Key_Return):
self.find.emit()
elif event.key() == Qt.Key_F and ctrl and shift:
# Toggle find widgets
self.parent().toggle_visibility.emit(not self.isVisible())
else:
QWidget.keyPressEvent(self, event) | python | def keyPressEvent(self, event):
"""Reimplemented to handle key events"""
ctrl = event.modifiers() & Qt.ControlModifier
shift = event.modifiers() & Qt.ShiftModifier
if event.key() in (Qt.Key_Enter, Qt.Key_Return):
self.find.emit()
elif event.key() == Qt.Key_F and ctrl and shift:
# Toggle find widgets
self.parent().toggle_visibility.emit(not self.isVisible())
else:
QWidget.keyPressEvent(self, event) | [
"def",
"keyPressEvent",
"(",
"self",
",",
"event",
")",
":",
"ctrl",
"=",
"event",
".",
"modifiers",
"(",
")",
"&",
"Qt",
".",
"ControlModifier",
"shift",
"=",
"event",
".",
"modifiers",
"(",
")",
"&",
"Qt",
".",
"ShiftModifier",
"if",
"event",
".",
... | Reimplemented to handle key events | [
"Reimplemented",
"to",
"handle",
"key",
"events"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L636-L646 |
31,302 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | ResultsBrowser.set_sorting | def set_sorting(self, flag):
"""Enable result sorting after search is complete."""
self.sorting['status'] = flag
self.header().setSectionsClickable(flag == ON) | python | def set_sorting(self, flag):
"""Enable result sorting after search is complete."""
self.sorting['status'] = flag
self.header().setSectionsClickable(flag == ON) | [
"def",
"set_sorting",
"(",
"self",
",",
"flag",
")",
":",
"self",
".",
"sorting",
"[",
"'status'",
"]",
"=",
"flag",
"self",
".",
"header",
"(",
")",
".",
"setSectionsClickable",
"(",
"flag",
"==",
"ON",
")"
] | Enable result sorting after search is complete. | [
"Enable",
"result",
"sorting",
"after",
"search",
"is",
"complete",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L778-L781 |
31,303 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | ResultsBrowser.append_result | def append_result(self, results, num_matches):
"""Real-time update of search results"""
filename, lineno, colno, match_end, line = results
if filename not in self.files:
file_item = FileMatchItem(self, filename, self.sorting,
self.text_color)
file_item.setExpanded(True)
self.files[filename] = file_item
self.num_files += 1
search_text = self.search_text
title = "'%s' - " % search_text
nb_files = self.num_files
if nb_files == 0:
text = _('String not found')
else:
text_matches = _('matches in')
text_files = _('file')
if nb_files > 1:
text_files += 's'
text = "%d %s %d %s" % (num_matches, text_matches,
nb_files, text_files)
self.set_title(title + text)
file_item = self.files[filename]
line = self.truncate_result(line, colno, match_end)
item = LineMatchItem(file_item, lineno, colno, line, self.text_color)
self.data[id(item)] = (filename, lineno, colno) | python | def append_result(self, results, num_matches):
"""Real-time update of search results"""
filename, lineno, colno, match_end, line = results
if filename not in self.files:
file_item = FileMatchItem(self, filename, self.sorting,
self.text_color)
file_item.setExpanded(True)
self.files[filename] = file_item
self.num_files += 1
search_text = self.search_text
title = "'%s' - " % search_text
nb_files = self.num_files
if nb_files == 0:
text = _('String not found')
else:
text_matches = _('matches in')
text_files = _('file')
if nb_files > 1:
text_files += 's'
text = "%d %s %d %s" % (num_matches, text_matches,
nb_files, text_files)
self.set_title(title + text)
file_item = self.files[filename]
line = self.truncate_result(line, colno, match_end)
item = LineMatchItem(file_item, lineno, colno, line, self.text_color)
self.data[id(item)] = (filename, lineno, colno) | [
"def",
"append_result",
"(",
"self",
",",
"results",
",",
"num_matches",
")",
":",
"filename",
",",
"lineno",
",",
"colno",
",",
"match_end",
",",
"line",
"=",
"results",
"if",
"filename",
"not",
"in",
"self",
".",
"files",
":",
"file_item",
"=",
"FileMa... | Real-time update of search results | [
"Real",
"-",
"time",
"update",
"of",
"search",
"results"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L876-L904 |
31,304 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | FileProgressBar.showEvent | def showEvent(self, event):
"""Override show event to start waiting spinner."""
QWidget.showEvent(self, event)
self.spinner.start() | python | def showEvent(self, event):
"""Override show event to start waiting spinner."""
QWidget.showEvent(self, event)
self.spinner.start() | [
"def",
"showEvent",
"(",
"self",
",",
"event",
")",
":",
"QWidget",
".",
"showEvent",
"(",
"self",
",",
"event",
")",
"self",
".",
"spinner",
".",
"start",
"(",
")"
] | Override show event to start waiting spinner. | [
"Override",
"show",
"event",
"to",
"start",
"waiting",
"spinner",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L934-L937 |
31,305 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | FileProgressBar.hideEvent | def hideEvent(self, event):
"""Override hide event to stop waiting spinner."""
QWidget.hideEvent(self, event)
self.spinner.stop() | python | def hideEvent(self, event):
"""Override hide event to stop waiting spinner."""
QWidget.hideEvent(self, event)
self.spinner.stop() | [
"def",
"hideEvent",
"(",
"self",
",",
"event",
")",
":",
"QWidget",
".",
"hideEvent",
"(",
"self",
",",
"event",
")",
"self",
".",
"spinner",
".",
"stop",
"(",
")"
] | Override hide event to stop waiting spinner. | [
"Override",
"hide",
"event",
"to",
"stop",
"waiting",
"spinner",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L939-L942 |
31,306 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | FindInFilesWidget.stop_and_reset_thread | def stop_and_reset_thread(self, ignore_results=False):
"""Stop current search thread and clean-up"""
if self.search_thread is not None:
if self.search_thread.isRunning():
if ignore_results:
self.search_thread.sig_finished.disconnect(
self.search_complete)
self.search_thread.stop()
self.search_thread.wait()
self.search_thread.setParent(None)
self.search_thread = None | python | def stop_and_reset_thread(self, ignore_results=False):
"""Stop current search thread and clean-up"""
if self.search_thread is not None:
if self.search_thread.isRunning():
if ignore_results:
self.search_thread.sig_finished.disconnect(
self.search_complete)
self.search_thread.stop()
self.search_thread.wait()
self.search_thread.setParent(None)
self.search_thread = None | [
"def",
"stop_and_reset_thread",
"(",
"self",
",",
"ignore_results",
"=",
"False",
")",
":",
"if",
"self",
".",
"search_thread",
"is",
"not",
"None",
":",
"if",
"self",
".",
"search_thread",
".",
"isRunning",
"(",
")",
":",
"if",
"ignore_results",
":",
"sel... | Stop current search thread and clean-up | [
"Stop",
"current",
"search",
"thread",
"and",
"clean",
"-",
"up"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L1029-L1039 |
31,307 | spyder-ide/spyder | spyder/plugins/findinfiles/widgets.py | FindInFilesWidget.search_complete | def search_complete(self, completed):
"""Current search thread has finished"""
self.result_browser.set_sorting(ON)
self.find_options.ok_button.setEnabled(True)
self.find_options.stop_button.setEnabled(False)
self.status_bar.hide()
self.result_browser.expandAll()
if self.search_thread is None:
return
self.sig_finished.emit()
found = self.search_thread.get_results()
self.stop_and_reset_thread()
if found is not None:
results, pathlist, nb, error_flag = found
self.result_browser.show() | python | def search_complete(self, completed):
"""Current search thread has finished"""
self.result_browser.set_sorting(ON)
self.find_options.ok_button.setEnabled(True)
self.find_options.stop_button.setEnabled(False)
self.status_bar.hide()
self.result_browser.expandAll()
if self.search_thread is None:
return
self.sig_finished.emit()
found = self.search_thread.get_results()
self.stop_and_reset_thread()
if found is not None:
results, pathlist, nb, error_flag = found
self.result_browser.show() | [
"def",
"search_complete",
"(",
"self",
",",
"completed",
")",
":",
"self",
".",
"result_browser",
".",
"set_sorting",
"(",
"ON",
")",
"self",
".",
"find_options",
".",
"ok_button",
".",
"setEnabled",
"(",
"True",
")",
"self",
".",
"find_options",
".",
"sto... | Current search thread has finished | [
"Current",
"search",
"thread",
"has",
"finished"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/findinfiles/widgets.py#L1045-L1059 |
31,308 | spyder-ide/spyder | spyder/widgets/github/backend.py | GithubBackend._get_credentials_from_settings | def _get_credentials_from_settings(self):
"""Get the stored credentials if any."""
remember_me = CONF.get('main', 'report_error/remember_me')
remember_token = CONF.get('main', 'report_error/remember_token')
username = CONF.get('main', 'report_error/username', '')
if not remember_me:
username = ''
return username, remember_me, remember_token | python | def _get_credentials_from_settings(self):
"""Get the stored credentials if any."""
remember_me = CONF.get('main', 'report_error/remember_me')
remember_token = CONF.get('main', 'report_error/remember_token')
username = CONF.get('main', 'report_error/username', '')
if not remember_me:
username = ''
return username, remember_me, remember_token | [
"def",
"_get_credentials_from_settings",
"(",
"self",
")",
":",
"remember_me",
"=",
"CONF",
".",
"get",
"(",
"'main'",
",",
"'report_error/remember_me'",
")",
"remember_token",
"=",
"CONF",
".",
"get",
"(",
"'main'",
",",
"'report_error/remember_token'",
")",
"use... | Get the stored credentials if any. | [
"Get",
"the",
"stored",
"credentials",
"if",
"any",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/github/backend.py#L177-L185 |
31,309 | spyder-ide/spyder | spyder/widgets/github/backend.py | GithubBackend._store_credentials | def _store_credentials(self, username, password, remember=False):
"""Store credentials for future use."""
if username and password and remember:
CONF.set('main', 'report_error/username', username)
try:
keyring.set_password('github', username, password)
except Exception:
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to store password'),
_('It was not possible to securely '
'save your password. You will be '
'prompted for your Github '
'credentials next time you want '
'to report an issue.'))
remember = False
CONF.set('main', 'report_error/remember_me', remember) | python | def _store_credentials(self, username, password, remember=False):
"""Store credentials for future use."""
if username and password and remember:
CONF.set('main', 'report_error/username', username)
try:
keyring.set_password('github', username, password)
except Exception:
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to store password'),
_('It was not possible to securely '
'save your password. You will be '
'prompted for your Github '
'credentials next time you want '
'to report an issue.'))
remember = False
CONF.set('main', 'report_error/remember_me', remember) | [
"def",
"_store_credentials",
"(",
"self",
",",
"username",
",",
"password",
",",
"remember",
"=",
"False",
")",
":",
"if",
"username",
"and",
"password",
"and",
"remember",
":",
"CONF",
".",
"set",
"(",
"'main'",
",",
"'report_error/username'",
",",
"usernam... | Store credentials for future use. | [
"Store",
"credentials",
"for",
"future",
"use",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/github/backend.py#L187-L203 |
31,310 | spyder-ide/spyder | spyder/widgets/github/backend.py | GithubBackend._store_token | def _store_token(self, token, remember=False):
"""Store token for future use."""
if token and remember:
try:
keyring.set_password('github', 'token', token)
except Exception:
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to store token'),
_('It was not possible to securely '
'save your token. You will be '
'prompted for your Github token '
'next time you want to report '
'an issue.'))
remember = False
CONF.set('main', 'report_error/remember_token', remember) | python | def _store_token(self, token, remember=False):
"""Store token for future use."""
if token and remember:
try:
keyring.set_password('github', 'token', token)
except Exception:
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to store token'),
_('It was not possible to securely '
'save your token. You will be '
'prompted for your Github token '
'next time you want to report '
'an issue.'))
remember = False
CONF.set('main', 'report_error/remember_token', remember) | [
"def",
"_store_token",
"(",
"self",
",",
"token",
",",
"remember",
"=",
"False",
")",
":",
"if",
"token",
"and",
"remember",
":",
"try",
":",
"keyring",
".",
"set_password",
"(",
"'github'",
",",
"'token'",
",",
"token",
")",
"except",
"Exception",
":",
... | Store token for future use. | [
"Store",
"token",
"for",
"future",
"use",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/github/backend.py#L205-L220 |
31,311 | spyder-ide/spyder | spyder/widgets/github/backend.py | GithubBackend.get_user_credentials | def get_user_credentials(self):
"""Get user credentials with the login dialog."""
password = None
token = None
(username, remember_me,
remember_token) = self._get_credentials_from_settings()
valid_py_os = not (PY2 and sys.platform.startswith('linux'))
if username and remember_me and valid_py_os:
# Get password from keyring
try:
password = keyring.get_password('github', username)
except Exception:
# No safe keyring backend
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to retrieve password'),
_('It was not possible to retrieve '
'your password. Please introduce '
'it again.'))
if remember_token and valid_py_os:
# Get token from keyring
try:
token = keyring.get_password('github', 'token')
except Exception:
# No safe keyring backend
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to retrieve token'),
_('It was not possible to retrieve '
'your token. Please introduce it '
'again.'))
if not running_under_pytest():
credentials = DlgGitHubLogin.login(self.parent_widget, username,
password, token, remember_me,
remember_token)
if (credentials['username'] and credentials['password'] and
valid_py_os):
self._store_credentials(credentials['username'],
credentials['password'],
credentials['remember'])
CONF.set('main', 'report_error/remember_me',
credentials['remember'])
if credentials['token'] and valid_py_os:
self._store_token(credentials['token'],
credentials['remember_token'])
CONF.set('main', 'report_error/remember_token',
credentials['remember_token'])
else:
return dict(username=username,
password=password,
token='',
remember=remember_me,
remember_token=remember_token)
return credentials | python | def get_user_credentials(self):
"""Get user credentials with the login dialog."""
password = None
token = None
(username, remember_me,
remember_token) = self._get_credentials_from_settings()
valid_py_os = not (PY2 and sys.platform.startswith('linux'))
if username and remember_me and valid_py_os:
# Get password from keyring
try:
password = keyring.get_password('github', username)
except Exception:
# No safe keyring backend
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to retrieve password'),
_('It was not possible to retrieve '
'your password. Please introduce '
'it again.'))
if remember_token and valid_py_os:
# Get token from keyring
try:
token = keyring.get_password('github', 'token')
except Exception:
# No safe keyring backend
if self._show_msgbox:
QMessageBox.warning(self.parent_widget,
_('Failed to retrieve token'),
_('It was not possible to retrieve '
'your token. Please introduce it '
'again.'))
if not running_under_pytest():
credentials = DlgGitHubLogin.login(self.parent_widget, username,
password, token, remember_me,
remember_token)
if (credentials['username'] and credentials['password'] and
valid_py_os):
self._store_credentials(credentials['username'],
credentials['password'],
credentials['remember'])
CONF.set('main', 'report_error/remember_me',
credentials['remember'])
if credentials['token'] and valid_py_os:
self._store_token(credentials['token'],
credentials['remember_token'])
CONF.set('main', 'report_error/remember_token',
credentials['remember_token'])
else:
return dict(username=username,
password=password,
token='',
remember=remember_me,
remember_token=remember_token)
return credentials | [
"def",
"get_user_credentials",
"(",
"self",
")",
":",
"password",
"=",
"None",
"token",
"=",
"None",
"(",
"username",
",",
"remember_me",
",",
"remember_token",
")",
"=",
"self",
".",
"_get_credentials_from_settings",
"(",
")",
"valid_py_os",
"=",
"not",
"(",
... | Get user credentials with the login dialog. | [
"Get",
"user",
"credentials",
"with",
"the",
"login",
"dialog",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/github/backend.py#L223-L280 |
31,312 | spyder-ide/spyder | spyder/widgets/calltip.py | ToolTipWidget.leaveEvent | def leaveEvent(self, event):
"""Override Qt method to hide the tooltip on leave."""
super(ToolTipWidget, self).leaveEvent(event)
self.hide() | python | def leaveEvent(self, event):
"""Override Qt method to hide the tooltip on leave."""
super(ToolTipWidget, self).leaveEvent(event)
self.hide() | [
"def",
"leaveEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"ToolTipWidget",
",",
"self",
")",
".",
"leaveEvent",
"(",
"event",
")",
"self",
".",
"hide",
"(",
")"
] | Override Qt method to hide the tooltip on leave. | [
"Override",
"Qt",
"method",
"to",
"hide",
"the",
"tooltip",
"on",
"leave",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/calltip.py#L105-L108 |
31,313 | spyder-ide/spyder | spyder/widgets/calltip.py | CallTipWidget.eventFilter | def eventFilter(self, obj, event):
""" Reimplemented to hide on certain key presses and on text edit focus
changes.
"""
if obj == self._text_edit:
etype = event.type()
if etype == QEvent.KeyPress:
key = event.key()
cursor = self._text_edit.textCursor()
prev_char = self._text_edit.get_character(cursor.position(),
offset=-1)
if key in (Qt.Key_Enter, Qt.Key_Return,
Qt.Key_Down, Qt.Key_Up):
self.hide()
elif key == Qt.Key_Escape:
self.hide()
return True
elif prev_char == ')':
self.hide()
elif etype == QEvent.FocusOut:
self.hide()
elif etype == QEvent.Enter:
if (self._hide_timer.isActive() and
self.app.topLevelAt(QCursor.pos()) == self):
self._hide_timer.stop()
elif etype == QEvent.Leave:
self._leave_event_hide()
return super(CallTipWidget, self).eventFilter(obj, event) | python | def eventFilter(self, obj, event):
""" Reimplemented to hide on certain key presses and on text edit focus
changes.
"""
if obj == self._text_edit:
etype = event.type()
if etype == QEvent.KeyPress:
key = event.key()
cursor = self._text_edit.textCursor()
prev_char = self._text_edit.get_character(cursor.position(),
offset=-1)
if key in (Qt.Key_Enter, Qt.Key_Return,
Qt.Key_Down, Qt.Key_Up):
self.hide()
elif key == Qt.Key_Escape:
self.hide()
return True
elif prev_char == ')':
self.hide()
elif etype == QEvent.FocusOut:
self.hide()
elif etype == QEvent.Enter:
if (self._hide_timer.isActive() and
self.app.topLevelAt(QCursor.pos()) == self):
self._hide_timer.stop()
elif etype == QEvent.Leave:
self._leave_event_hide()
return super(CallTipWidget, self).eventFilter(obj, event) | [
"def",
"eventFilter",
"(",
"self",
",",
"obj",
",",
"event",
")",
":",
"if",
"obj",
"==",
"self",
".",
"_text_edit",
":",
"etype",
"=",
"event",
".",
"type",
"(",
")",
"if",
"etype",
"==",
"QEvent",
".",
"KeyPress",
":",
"key",
"=",
"event",
".",
... | Reimplemented to hide on certain key presses and on text edit focus
changes. | [
"Reimplemented",
"to",
"hide",
"on",
"certain",
"key",
"presses",
"and",
"on",
"text",
"edit",
"focus",
"changes",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/calltip.py#L144-L176 |
31,314 | spyder-ide/spyder | spyder/widgets/calltip.py | CallTipWidget.timerEvent | def timerEvent(self, event):
""" Reimplemented to hide the widget when the hide timer fires.
"""
if event.timerId() == self._hide_timer.timerId():
self._hide_timer.stop()
self.hide() | python | def timerEvent(self, event):
""" Reimplemented to hide the widget when the hide timer fires.
"""
if event.timerId() == self._hide_timer.timerId():
self._hide_timer.stop()
self.hide() | [
"def",
"timerEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"timerId",
"(",
")",
"==",
"self",
".",
"_hide_timer",
".",
"timerId",
"(",
")",
":",
"self",
".",
"_hide_timer",
".",
"stop",
"(",
")",
"self",
".",
"hide",
"(",
")"
] | Reimplemented to hide the widget when the hide timer fires. | [
"Reimplemented",
"to",
"hide",
"the",
"widget",
"when",
"the",
"hide",
"timer",
"fires",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/calltip.py#L178-L183 |
31,315 | spyder-ide/spyder | spyder/widgets/calltip.py | CallTipWidget.enterEvent | def enterEvent(self, event):
""" Reimplemented to cancel the hide timer.
"""
super(CallTipWidget, self).enterEvent(event)
if self.as_tooltip:
self.hide()
if (self._hide_timer.isActive() and
self.app.topLevelAt(QCursor.pos()) == self):
self._hide_timer.stop() | python | def enterEvent(self, event):
""" Reimplemented to cancel the hide timer.
"""
super(CallTipWidget, self).enterEvent(event)
if self.as_tooltip:
self.hide()
if (self._hide_timer.isActive() and
self.app.topLevelAt(QCursor.pos()) == self):
self._hide_timer.stop() | [
"def",
"enterEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"CallTipWidget",
",",
"self",
")",
".",
"enterEvent",
"(",
"event",
")",
"if",
"self",
".",
"as_tooltip",
":",
"self",
".",
"hide",
"(",
")",
"if",
"(",
"self",
".",
"_hide_timer... | Reimplemented to cancel the hide timer. | [
"Reimplemented",
"to",
"cancel",
"the",
"hide",
"timer",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/calltip.py#L189-L198 |
31,316 | spyder-ide/spyder | spyder/widgets/calltip.py | CallTipWidget.hideEvent | def hideEvent(self, event):
""" Reimplemented to disconnect signal handlers and event filter.
"""
super(CallTipWidget, self).hideEvent(event)
self._text_edit.cursorPositionChanged.disconnect(
self._cursor_position_changed)
self._text_edit.removeEventFilter(self) | python | def hideEvent(self, event):
""" Reimplemented to disconnect signal handlers and event filter.
"""
super(CallTipWidget, self).hideEvent(event)
self._text_edit.cursorPositionChanged.disconnect(
self._cursor_position_changed)
self._text_edit.removeEventFilter(self) | [
"def",
"hideEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"CallTipWidget",
",",
"self",
")",
".",
"hideEvent",
"(",
"event",
")",
"self",
".",
"_text_edit",
".",
"cursorPositionChanged",
".",
"disconnect",
"(",
"self",
".",
"_cursor_position_cha... | Reimplemented to disconnect signal handlers and event filter. | [
"Reimplemented",
"to",
"disconnect",
"signal",
"handlers",
"and",
"event",
"filter",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/calltip.py#L200-L206 |
31,317 | spyder-ide/spyder | spyder/widgets/calltip.py | CallTipWidget.leaveEvent | def leaveEvent(self, event):
""" Reimplemented to start the hide timer.
"""
super(CallTipWidget, self).leaveEvent(event)
self._leave_event_hide() | python | def leaveEvent(self, event):
""" Reimplemented to start the hide timer.
"""
super(CallTipWidget, self).leaveEvent(event)
self._leave_event_hide() | [
"def",
"leaveEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"CallTipWidget",
",",
"self",
")",
".",
"leaveEvent",
"(",
"event",
")",
"self",
".",
"_leave_event_hide",
"(",
")"
] | Reimplemented to start the hide timer. | [
"Reimplemented",
"to",
"start",
"the",
"hide",
"timer",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/calltip.py#L208-L212 |
31,318 | spyder-ide/spyder | spyder/widgets/calltip.py | CallTipWidget.showEvent | def showEvent(self, event):
""" Reimplemented to connect signal handlers and event filter.
"""
super(CallTipWidget, self).showEvent(event)
self._text_edit.cursorPositionChanged.connect(
self._cursor_position_changed)
self._text_edit.installEventFilter(self) | python | def showEvent(self, event):
""" Reimplemented to connect signal handlers and event filter.
"""
super(CallTipWidget, self).showEvent(event)
self._text_edit.cursorPositionChanged.connect(
self._cursor_position_changed)
self._text_edit.installEventFilter(self) | [
"def",
"showEvent",
"(",
"self",
",",
"event",
")",
":",
"super",
"(",
"CallTipWidget",
",",
"self",
")",
".",
"showEvent",
"(",
"event",
")",
"self",
".",
"_text_edit",
".",
"cursorPositionChanged",
".",
"connect",
"(",
"self",
".",
"_cursor_position_change... | Reimplemented to connect signal handlers and event filter. | [
"Reimplemented",
"to",
"connect",
"signal",
"handlers",
"and",
"event",
"filter",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/calltip.py#L234-L240 |
31,319 | spyder-ide/spyder | spyder/widgets/calltip.py | CallTipWidget._cursor_position_changed | def _cursor_position_changed(self):
""" Updates the tip based on user cursor movement.
"""
cursor = self._text_edit.textCursor()
position = cursor.position()
document = self._text_edit.document()
char = to_text_string(document.characterAt(position - 1))
if position <= self._start_position:
self.hide()
elif char == ')':
pos, _ = self._find_parenthesis(position - 1, forward=False)
if pos == -1:
self.hide() | python | def _cursor_position_changed(self):
""" Updates the tip based on user cursor movement.
"""
cursor = self._text_edit.textCursor()
position = cursor.position()
document = self._text_edit.document()
char = to_text_string(document.characterAt(position - 1))
if position <= self._start_position:
self.hide()
elif char == ')':
pos, _ = self._find_parenthesis(position - 1, forward=False)
if pos == -1:
self.hide() | [
"def",
"_cursor_position_changed",
"(",
"self",
")",
":",
"cursor",
"=",
"self",
".",
"_text_edit",
".",
"textCursor",
"(",
")",
"position",
"=",
"cursor",
".",
"position",
"(",
")",
"document",
"=",
"self",
".",
"_text_edit",
".",
"document",
"(",
")",
... | Updates the tip based on user cursor movement. | [
"Updates",
"the",
"tip",
"based",
"on",
"user",
"cursor",
"movement",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/calltip.py#L394-L406 |
31,320 | spyder-ide/spyder | spyder/utils/sourcecode.py | has_mixed_eol_chars | def has_mixed_eol_chars(text):
"""Detect if text has mixed EOL characters"""
eol_chars = get_eol_chars(text)
if eol_chars is None:
return False
correct_text = eol_chars.join((text+eol_chars).splitlines())
return repr(correct_text) != repr(text) | python | def has_mixed_eol_chars(text):
"""Detect if text has mixed EOL characters"""
eol_chars = get_eol_chars(text)
if eol_chars is None:
return False
correct_text = eol_chars.join((text+eol_chars).splitlines())
return repr(correct_text) != repr(text) | [
"def",
"has_mixed_eol_chars",
"(",
"text",
")",
":",
"eol_chars",
"=",
"get_eol_chars",
"(",
"text",
")",
"if",
"eol_chars",
"is",
"None",
":",
"return",
"False",
"correct_text",
"=",
"eol_chars",
".",
"join",
"(",
"(",
"text",
"+",
"eol_chars",
")",
".",
... | Detect if text has mixed EOL characters | [
"Detect",
"if",
"text",
"has",
"mixed",
"EOL",
"characters"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/sourcecode.py#L44-L50 |
31,321 | spyder-ide/spyder | spyder/utils/sourcecode.py | normalize_eols | def normalize_eols(text, eol='\n'):
"""Use the same eol's in text"""
for eol_char, _ in EOL_CHARS:
if eol_char != eol:
text = text.replace(eol_char, eol)
return text | python | def normalize_eols(text, eol='\n'):
"""Use the same eol's in text"""
for eol_char, _ in EOL_CHARS:
if eol_char != eol:
text = text.replace(eol_char, eol)
return text | [
"def",
"normalize_eols",
"(",
"text",
",",
"eol",
"=",
"'\\n'",
")",
":",
"for",
"eol_char",
",",
"_",
"in",
"EOL_CHARS",
":",
"if",
"eol_char",
"!=",
"eol",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"eol_char",
",",
"eol",
")",
"return",
"text"... | Use the same eol's in text | [
"Use",
"the",
"same",
"eol",
"s",
"in",
"text"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/sourcecode.py#L53-L58 |
31,322 | spyder-ide/spyder | spyder/utils/sourcecode.py | is_builtin | def is_builtin(text):
"""Test if passed string is the name of a Python builtin object"""
from spyder.py3compat import builtins
return text in [str(name) for name in dir(builtins)
if not name.startswith('_')] | python | def is_builtin(text):
"""Test if passed string is the name of a Python builtin object"""
from spyder.py3compat import builtins
return text in [str(name) for name in dir(builtins)
if not name.startswith('_')] | [
"def",
"is_builtin",
"(",
"text",
")",
":",
"from",
"spyder",
".",
"py3compat",
"import",
"builtins",
"return",
"text",
"in",
"[",
"str",
"(",
"name",
")",
"for",
"name",
"in",
"dir",
"(",
"builtins",
")",
"if",
"not",
"name",
".",
"startswith",
"(",
... | Test if passed string is the name of a Python builtin object | [
"Test",
"if",
"passed",
"string",
"is",
"the",
"name",
"of",
"a",
"Python",
"builtin",
"object"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/sourcecode.py#L66-L70 |
31,323 | spyder-ide/spyder | spyder/utils/sourcecode.py | split_source | def split_source(source_code):
'''Split source code into lines
'''
eol_chars = get_eol_chars(source_code)
if eol_chars:
return source_code.split(eol_chars)
else:
return [source_code] | python | def split_source(source_code):
'''Split source code into lines
'''
eol_chars = get_eol_chars(source_code)
if eol_chars:
return source_code.split(eol_chars)
else:
return [source_code] | [
"def",
"split_source",
"(",
"source_code",
")",
":",
"eol_chars",
"=",
"get_eol_chars",
"(",
"source_code",
")",
"if",
"eol_chars",
":",
"return",
"source_code",
".",
"split",
"(",
"eol_chars",
")",
"else",
":",
"return",
"[",
"source_code",
"]"
] | Split source code into lines | [
"Split",
"source",
"code",
"into",
"lines"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/sourcecode.py#L100-L107 |
31,324 | spyder-ide/spyder | spyder/utils/sourcecode.py | get_identifiers | def get_identifiers(source_code):
'''Split source code into python identifier-like tokens'''
tokens = set(re.split(r"[^0-9a-zA-Z_.]", source_code))
valid = re.compile(r'[a-zA-Z_]')
return [token for token in tokens if re.match(valid, token)] | python | def get_identifiers(source_code):
'''Split source code into python identifier-like tokens'''
tokens = set(re.split(r"[^0-9a-zA-Z_.]", source_code))
valid = re.compile(r'[a-zA-Z_]')
return [token for token in tokens if re.match(valid, token)] | [
"def",
"get_identifiers",
"(",
"source_code",
")",
":",
"tokens",
"=",
"set",
"(",
"re",
".",
"split",
"(",
"r\"[^0-9a-zA-Z_.]\"",
",",
"source_code",
")",
")",
"valid",
"=",
"re",
".",
"compile",
"(",
"r'[a-zA-Z_]'",
")",
"return",
"[",
"token",
"for",
... | Split source code into python identifier-like tokens | [
"Split",
"source",
"code",
"into",
"python",
"identifier",
"-",
"like",
"tokens"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/sourcecode.py#L110-L114 |
31,325 | spyder-ide/spyder | spyder/utils/sourcecode.py | disambiguate_fname | def disambiguate_fname(files_path_list, filename):
"""Get tab title without ambiguation."""
fname = os.path.basename(filename)
same_name_files = get_same_name_files(files_path_list, fname)
if len(same_name_files) > 1:
compare_path = shortest_path(same_name_files)
if compare_path == filename:
same_name_files.remove(path_components(filename))
compare_path = shortest_path(same_name_files)
diff_path = differentiate_prefix(path_components(filename),
path_components(compare_path))
diff_path_length = len(diff_path)
path_component = path_components(diff_path)
if (diff_path_length > 20 and len(path_component) > 2):
if path_component[0] != '/' and path_component[0] != '':
path_component = [path_component[0], '...',
path_component[-1]]
else:
path_component = [path_component[2], '...',
path_component[-1]]
diff_path = os.path.join(*path_component)
fname = fname + " - " + diff_path
return fname | python | def disambiguate_fname(files_path_list, filename):
"""Get tab title without ambiguation."""
fname = os.path.basename(filename)
same_name_files = get_same_name_files(files_path_list, fname)
if len(same_name_files) > 1:
compare_path = shortest_path(same_name_files)
if compare_path == filename:
same_name_files.remove(path_components(filename))
compare_path = shortest_path(same_name_files)
diff_path = differentiate_prefix(path_components(filename),
path_components(compare_path))
diff_path_length = len(diff_path)
path_component = path_components(diff_path)
if (diff_path_length > 20 and len(path_component) > 2):
if path_component[0] != '/' and path_component[0] != '':
path_component = [path_component[0], '...',
path_component[-1]]
else:
path_component = [path_component[2], '...',
path_component[-1]]
diff_path = os.path.join(*path_component)
fname = fname + " - " + diff_path
return fname | [
"def",
"disambiguate_fname",
"(",
"files_path_list",
",",
"filename",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
"same_name_files",
"=",
"get_same_name_files",
"(",
"files_path_list",
",",
"fname",
")",
"if",
"len",
"(",
... | Get tab title without ambiguation. | [
"Get",
"tab",
"title",
"without",
"ambiguation",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/sourcecode.py#L173-L195 |
31,326 | spyder-ide/spyder | spyder/utils/sourcecode.py | get_same_name_files | def get_same_name_files(files_path_list, filename):
"""Get a list of the path components of the files with the same name."""
same_name_files = []
for fname in files_path_list:
if filename == os.path.basename(fname):
same_name_files.append(path_components(fname))
return same_name_files | python | def get_same_name_files(files_path_list, filename):
"""Get a list of the path components of the files with the same name."""
same_name_files = []
for fname in files_path_list:
if filename == os.path.basename(fname):
same_name_files.append(path_components(fname))
return same_name_files | [
"def",
"get_same_name_files",
"(",
"files_path_list",
",",
"filename",
")",
":",
"same_name_files",
"=",
"[",
"]",
"for",
"fname",
"in",
"files_path_list",
":",
"if",
"filename",
"==",
"os",
".",
"path",
".",
"basename",
"(",
"fname",
")",
":",
"same_name_fi... | Get a list of the path components of the files with the same name. | [
"Get",
"a",
"list",
"of",
"the",
"path",
"components",
"of",
"the",
"files",
"with",
"the",
"same",
"name",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/sourcecode.py#L197-L203 |
31,327 | spyder-ide/spyder | spyder/plugins/editor/utils/decoration.py | TextDecorationsManager.add | def add(self, decorations):
"""
Add text decorations on a CodeEditor instance.
Don't add duplicated decorations, and order decorations according
draw_order and the size of the selection.
Args:
decorations (sourcecode.api.TextDecoration) (could be a list)
Returns:
int: Amount of decorations added.
"""
added = 0
if isinstance(decorations, list):
not_repeated = set(decorations) - set(self._decorations)
self._decorations.extend(list(not_repeated))
added = len(not_repeated)
elif decorations not in self._decorations:
self._decorations.append(decorations)
added = 1
if added > 0:
self._order_decorations()
self.update()
return added | python | def add(self, decorations):
"""
Add text decorations on a CodeEditor instance.
Don't add duplicated decorations, and order decorations according
draw_order and the size of the selection.
Args:
decorations (sourcecode.api.TextDecoration) (could be a list)
Returns:
int: Amount of decorations added.
"""
added = 0
if isinstance(decorations, list):
not_repeated = set(decorations) - set(self._decorations)
self._decorations.extend(list(not_repeated))
added = len(not_repeated)
elif decorations not in self._decorations:
self._decorations.append(decorations)
added = 1
if added > 0:
self._order_decorations()
self.update()
return added | [
"def",
"add",
"(",
"self",
",",
"decorations",
")",
":",
"added",
"=",
"0",
"if",
"isinstance",
"(",
"decorations",
",",
"list",
")",
":",
"not_repeated",
"=",
"set",
"(",
"decorations",
")",
"-",
"set",
"(",
"self",
".",
"_decorations",
")",
"self",
... | Add text decorations on a CodeEditor instance.
Don't add duplicated decorations, and order decorations according
draw_order and the size of the selection.
Args:
decorations (sourcecode.api.TextDecoration) (could be a list)
Returns:
int: Amount of decorations added. | [
"Add",
"text",
"decorations",
"on",
"a",
"CodeEditor",
"instance",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/decoration.py#L35-L59 |
31,328 | spyder-ide/spyder | spyder/plugins/editor/utils/decoration.py | TextDecorationsManager.update | def update(self):
"""Update editor extra selections with added decorations.
NOTE: Update TextDecorations to use editor font, using a different
font family and point size could cause unwanted behaviors.
"""
font = self.editor.font()
for decoration in self._decorations:
try:
decoration.format.setFont(
font, QTextCharFormat.FontPropertiesSpecifiedOnly)
except (TypeError, AttributeError): # Qt < 5.3
decoration.format.setFontFamily(font.family())
decoration.format.setFontPointSize(font.pointSize())
self.editor.setExtraSelections(self._decorations) | python | def update(self):
"""Update editor extra selections with added decorations.
NOTE: Update TextDecorations to use editor font, using a different
font family and point size could cause unwanted behaviors.
"""
font = self.editor.font()
for decoration in self._decorations:
try:
decoration.format.setFont(
font, QTextCharFormat.FontPropertiesSpecifiedOnly)
except (TypeError, AttributeError): # Qt < 5.3
decoration.format.setFontFamily(font.family())
decoration.format.setFontPointSize(font.pointSize())
self.editor.setExtraSelections(self._decorations) | [
"def",
"update",
"(",
"self",
")",
":",
"font",
"=",
"self",
".",
"editor",
".",
"font",
"(",
")",
"for",
"decoration",
"in",
"self",
".",
"_decorations",
":",
"try",
":",
"decoration",
".",
"format",
".",
"setFont",
"(",
"font",
",",
"QTextCharFormat"... | Update editor extra selections with added decorations.
NOTE: Update TextDecorations to use editor font, using a different
font family and point size could cause unwanted behaviors. | [
"Update",
"editor",
"extra",
"selections",
"with",
"added",
"decorations",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/decoration.py#L86-L100 |
31,329 | spyder-ide/spyder | spyder/plugins/editor/utils/decoration.py | TextDecorationsManager._order_decorations | def _order_decorations(self):
"""Order decorations according draw_order and size of selection.
Highest draw_order will appear on top of the lowest values.
If draw_order is equal,smaller selections are draw in top of
bigger selections.
"""
def order_function(sel):
end = sel.cursor.selectionEnd()
start = sel.cursor.selectionStart()
return sel.draw_order, -(end - start)
self._decorations = sorted(self._decorations,
key=order_function) | python | def _order_decorations(self):
"""Order decorations according draw_order and size of selection.
Highest draw_order will appear on top of the lowest values.
If draw_order is equal,smaller selections are draw in top of
bigger selections.
"""
def order_function(sel):
end = sel.cursor.selectionEnd()
start = sel.cursor.selectionStart()
return sel.draw_order, -(end - start)
self._decorations = sorted(self._decorations,
key=order_function) | [
"def",
"_order_decorations",
"(",
"self",
")",
":",
"def",
"order_function",
"(",
"sel",
")",
":",
"end",
"=",
"sel",
".",
"cursor",
".",
"selectionEnd",
"(",
")",
"start",
"=",
"sel",
".",
"cursor",
".",
"selectionStart",
"(",
")",
"return",
"sel",
".... | Order decorations according draw_order and size of selection.
Highest draw_order will appear on top of the lowest values.
If draw_order is equal,smaller selections are draw in top of
bigger selections. | [
"Order",
"decorations",
"according",
"draw_order",
"and",
"size",
"of",
"selection",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/decoration.py#L108-L122 |
31,330 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/help.py | HelpWidget.get_signature | def get_signature(self, content):
"""Get signature from inspect reply content"""
data = content.get('data', {})
text = data.get('text/plain', '')
if text:
text = ANSI_OR_SPECIAL_PATTERN.sub('', text)
self._control.current_prompt_pos = self._prompt_pos
line = self._control.get_current_line_to_cursor()
name = line[:-1].split('(')[-1] # Take last token after a (
name = name.split('.')[-1] # Then take last token after a .
# Clean name from invalid chars
try:
name = self.clean_invalid_var_chars(name).split('_')[-1]
except:
pass
argspec = getargspecfromtext(text)
if argspec:
# This covers cases like np.abs, whose docstring is
# the same as np.absolute and because of that a proper
# signature can't be obtained correctly
signature = name + argspec
else:
signature = getsignaturefromtext(text, name)
# Remove docstring for uniformity with editor
signature = signature.split('Docstring:')[0]
return signature
else:
return '' | python | def get_signature(self, content):
"""Get signature from inspect reply content"""
data = content.get('data', {})
text = data.get('text/plain', '')
if text:
text = ANSI_OR_SPECIAL_PATTERN.sub('', text)
self._control.current_prompt_pos = self._prompt_pos
line = self._control.get_current_line_to_cursor()
name = line[:-1].split('(')[-1] # Take last token after a (
name = name.split('.')[-1] # Then take last token after a .
# Clean name from invalid chars
try:
name = self.clean_invalid_var_chars(name).split('_')[-1]
except:
pass
argspec = getargspecfromtext(text)
if argspec:
# This covers cases like np.abs, whose docstring is
# the same as np.absolute and because of that a proper
# signature can't be obtained correctly
signature = name + argspec
else:
signature = getsignaturefromtext(text, name)
# Remove docstring for uniformity with editor
signature = signature.split('Docstring:')[0]
return signature
else:
return '' | [
"def",
"get_signature",
"(",
"self",
",",
"content",
")",
":",
"data",
"=",
"content",
".",
"get",
"(",
"'data'",
",",
"{",
"}",
")",
"text",
"=",
"data",
".",
"get",
"(",
"'text/plain'",
",",
"''",
")",
"if",
"text",
":",
"text",
"=",
"ANSI_OR_SPE... | Get signature from inspect reply content | [
"Get",
"signature",
"from",
"inspect",
"reply",
"content"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/help.py#L40-L69 |
31,331 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/help.py | HelpWidget._handle_inspect_reply | def _handle_inspect_reply(self, rep):
"""
Reimplement call tips to only show signatures, using the same
style from our Editor and External Console too
"""
cursor = self._get_cursor()
info = self._request_info.get('call_tip')
if info and info.id == rep['parent_header']['msg_id'] and \
info.pos == cursor.position():
content = rep['content']
if content.get('status') == 'ok' and content.get('found', False):
signature = self.get_signature(content)
if signature:
# TODO: Pass the language from the Console to the calltip
self._control.show_calltip(signature, color='#999999',
is_python=True) | python | def _handle_inspect_reply(self, rep):
"""
Reimplement call tips to only show signatures, using the same
style from our Editor and External Console too
"""
cursor = self._get_cursor()
info = self._request_info.get('call_tip')
if info and info.id == rep['parent_header']['msg_id'] and \
info.pos == cursor.position():
content = rep['content']
if content.get('status') == 'ok' and content.get('found', False):
signature = self.get_signature(content)
if signature:
# TODO: Pass the language from the Console to the calltip
self._control.show_calltip(signature, color='#999999',
is_python=True) | [
"def",
"_handle_inspect_reply",
"(",
"self",
",",
"rep",
")",
":",
"cursor",
"=",
"self",
".",
"_get_cursor",
"(",
")",
"info",
"=",
"self",
".",
"_request_info",
".",
"get",
"(",
"'call_tip'",
")",
"if",
"info",
"and",
"info",
".",
"id",
"==",
"rep",
... | Reimplement call tips to only show signatures, using the same
style from our Editor and External Console too | [
"Reimplement",
"call",
"tips",
"to",
"only",
"show",
"signatures",
"using",
"the",
"same",
"style",
"from",
"our",
"Editor",
"and",
"External",
"Console",
"too"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/help.py#L119-L134 |
31,332 | spyder-ide/spyder | spyder/utils/external/github.py | _encode_params | def _encode_params(kw):
'''
Encode parameters.
'''
args = []
for k, v in kw.items():
try:
# Python 2
qv = v.encode('utf-8') if isinstance(v, unicode) else str(v)
except:
qv = v
args.append('%s=%s' % (k, urlquote(qv)))
return '&'.join(args) | python | def _encode_params(kw):
'''
Encode parameters.
'''
args = []
for k, v in kw.items():
try:
# Python 2
qv = v.encode('utf-8') if isinstance(v, unicode) else str(v)
except:
qv = v
args.append('%s=%s' % (k, urlquote(qv)))
return '&'.join(args) | [
"def",
"_encode_params",
"(",
"kw",
")",
":",
"args",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"kw",
".",
"items",
"(",
")",
":",
"try",
":",
"# Python 2",
"qv",
"=",
"v",
".",
"encode",
"(",
"'utf-8'",
")",
"if",
"isinstance",
"(",
"v",
",",... | Encode parameters. | [
"Encode",
"parameters",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/external/github.py#L79-L91 |
31,333 | spyder-ide/spyder | spyder/utils/external/github.py | _encode_json | def _encode_json(obj):
'''
Encode object as json str.
'''
def _dump_obj(obj):
if isinstance(obj, dict):
return obj
d = dict()
for k in dir(obj):
if not k.startswith('_'):
d[k] = getattr(obj, k)
return d
return json.dumps(obj, default=_dump_obj) | python | def _encode_json(obj):
'''
Encode object as json str.
'''
def _dump_obj(obj):
if isinstance(obj, dict):
return obj
d = dict()
for k in dir(obj):
if not k.startswith('_'):
d[k] = getattr(obj, k)
return d
return json.dumps(obj, default=_dump_obj) | [
"def",
"_encode_json",
"(",
"obj",
")",
":",
"def",
"_dump_obj",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"return",
"obj",
"d",
"=",
"dict",
"(",
")",
"for",
"k",
"in",
"dir",
"(",
"obj",
")",
":",
"if",
"not... | Encode object as json str. | [
"Encode",
"object",
"as",
"json",
"str",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/external/github.py#L93-L105 |
31,334 | spyder-ide/spyder | spyder/utils/external/github.py | GitHub.authorize_url | def authorize_url(self, state=None):
'''
Generate authorize_url.
>>> GitHub(client_id='3ebf94c5776d565bcf75').authorize_url()
'https://github.com/login/oauth/authorize?client_id=3ebf94c5776d565bcf75'
'''
if not self._client_id:
raise ApiAuthError('No client id.')
kw = dict(client_id=self._client_id)
if self._redirect_uri:
kw['redirect_uri'] = self._redirect_uri
if self._scope:
kw['scope'] = self._scope
if state:
kw['state'] = state
return 'https://github.com/login/oauth/authorize?%s' % _encode_params(kw) | python | def authorize_url(self, state=None):
'''
Generate authorize_url.
>>> GitHub(client_id='3ebf94c5776d565bcf75').authorize_url()
'https://github.com/login/oauth/authorize?client_id=3ebf94c5776d565bcf75'
'''
if not self._client_id:
raise ApiAuthError('No client id.')
kw = dict(client_id=self._client_id)
if self._redirect_uri:
kw['redirect_uri'] = self._redirect_uri
if self._scope:
kw['scope'] = self._scope
if state:
kw['state'] = state
return 'https://github.com/login/oauth/authorize?%s' % _encode_params(kw) | [
"def",
"authorize_url",
"(",
"self",
",",
"state",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_client_id",
":",
"raise",
"ApiAuthError",
"(",
"'No client id.'",
")",
"kw",
"=",
"dict",
"(",
"client_id",
"=",
"self",
".",
"_client_id",
")",
"if",
... | Generate authorize_url.
>>> GitHub(client_id='3ebf94c5776d565bcf75').authorize_url()
'https://github.com/login/oauth/authorize?client_id=3ebf94c5776d565bcf75' | [
"Generate",
"authorize_url",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/external/github.py#L184-L200 |
31,335 | spyder-ide/spyder | spyder/plugins/editor/lsp/decorators.py | send_request | def send_request(req=None, method=None, requires_response=True):
"""Call function req and then send its results via ZMQ."""
if req is None:
return functools.partial(send_request, method=method,
requires_response=requires_response)
@functools.wraps(req)
def wrapper(self, *args, **kwargs):
params = req(self, *args, **kwargs)
_id = self.send(method, params, requires_response)
return _id
wrapper._sends = method
return wrapper | python | def send_request(req=None, method=None, requires_response=True):
"""Call function req and then send its results via ZMQ."""
if req is None:
return functools.partial(send_request, method=method,
requires_response=requires_response)
@functools.wraps(req)
def wrapper(self, *args, **kwargs):
params = req(self, *args, **kwargs)
_id = self.send(method, params, requires_response)
return _id
wrapper._sends = method
return wrapper | [
"def",
"send_request",
"(",
"req",
"=",
"None",
",",
"method",
"=",
"None",
",",
"requires_response",
"=",
"True",
")",
":",
"if",
"req",
"is",
"None",
":",
"return",
"functools",
".",
"partial",
"(",
"send_request",
",",
"method",
"=",
"method",
",",
... | Call function req and then send its results via ZMQ. | [
"Call",
"function",
"req",
"and",
"then",
"send",
"its",
"results",
"via",
"ZMQ",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/lsp/decorators.py#L12-L24 |
31,336 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | ReadOnlyCollectionsModel.get_value | def get_value(self, index):
"""Return current value"""
if index.column() == 0:
return self.keys[ index.row() ]
elif index.column() == 1:
return self.types[ index.row() ]
elif index.column() == 2:
return self.sizes[ index.row() ]
else:
return self._data[ self.keys[index.row()] ] | python | def get_value(self, index):
"""Return current value"""
if index.column() == 0:
return self.keys[ index.row() ]
elif index.column() == 1:
return self.types[ index.row() ]
elif index.column() == 2:
return self.sizes[ index.row() ]
else:
return self._data[ self.keys[index.row()] ] | [
"def",
"get_value",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
".",
"column",
"(",
")",
"==",
"0",
":",
"return",
"self",
".",
"keys",
"[",
"index",
".",
"row",
"(",
")",
"]",
"elif",
"index",
".",
"column",
"(",
")",
"==",
"1",
":",
... | Return current value | [
"Return",
"current",
"value"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L301-L310 |
31,337 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | ReadOnlyCollectionsModel.headerData | def headerData(self, section, orientation, role=Qt.DisplayRole):
"""Overriding method headerData"""
if role != Qt.DisplayRole:
return to_qvariant()
i_column = int(section)
if orientation == Qt.Horizontal:
headers = (self.header0, _("Type"), _("Size"), _("Value"))
return to_qvariant( headers[i_column] )
else:
return to_qvariant() | python | def headerData(self, section, orientation, role=Qt.DisplayRole):
"""Overriding method headerData"""
if role != Qt.DisplayRole:
return to_qvariant()
i_column = int(section)
if orientation == Qt.Horizontal:
headers = (self.header0, _("Type"), _("Size"), _("Value"))
return to_qvariant( headers[i_column] )
else:
return to_qvariant() | [
"def",
"headerData",
"(",
"self",
",",
"section",
",",
"orientation",
",",
"role",
"=",
"Qt",
".",
"DisplayRole",
")",
":",
"if",
"role",
"!=",
"Qt",
".",
"DisplayRole",
":",
"return",
"to_qvariant",
"(",
")",
"i_column",
"=",
"int",
"(",
"section",
")... | Overriding method headerData | [
"Overriding",
"method",
"headerData"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L357-L366 |
31,338 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | ReadOnlyCollectionsModel.flags | def flags(self, index):
"""Overriding method flags"""
# This method was implemented in CollectionsModel only, but to enable
# tuple exploration (even without editing), this method was moved here
if not index.isValid():
return Qt.ItemIsEnabled
return Qt.ItemFlags(QAbstractTableModel.flags(self, index)|
Qt.ItemIsEditable) | python | def flags(self, index):
"""Overriding method flags"""
# This method was implemented in CollectionsModel only, but to enable
# tuple exploration (even without editing), this method was moved here
if not index.isValid():
return Qt.ItemIsEnabled
return Qt.ItemFlags(QAbstractTableModel.flags(self, index)|
Qt.ItemIsEditable) | [
"def",
"flags",
"(",
"self",
",",
"index",
")",
":",
"# This method was implemented in CollectionsModel only, but to enable\r",
"# tuple exploration (even without editing), this method was moved here\r",
"if",
"not",
"index",
".",
"isValid",
"(",
")",
":",
"return",
"Qt",
"."... | Overriding method flags | [
"Overriding",
"method",
"flags"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L368-L375 |
31,339 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | CollectionsDelegate.show_warning | def show_warning(self, index):
"""
Decide if showing a warning when the user is trying to view
a big variable associated to a Tablemodel index
This avoids getting the variables' value to know its
size and type, using instead those already computed by
the TableModel.
The problem is when a variable is too big, it can take a
lot of time just to get its value
"""
try:
val_size = index.model().sizes[index.row()]
val_type = index.model().types[index.row()]
except:
return False
if val_type in ['list', 'set', 'tuple', 'dict'] and \
int(val_size) > 1e5:
return True
else:
return False | python | def show_warning(self, index):
"""
Decide if showing a warning when the user is trying to view
a big variable associated to a Tablemodel index
This avoids getting the variables' value to know its
size and type, using instead those already computed by
the TableModel.
The problem is when a variable is too big, it can take a
lot of time just to get its value
"""
try:
val_size = index.model().sizes[index.row()]
val_type = index.model().types[index.row()]
except:
return False
if val_type in ['list', 'set', 'tuple', 'dict'] and \
int(val_size) > 1e5:
return True
else:
return False | [
"def",
"show_warning",
"(",
"self",
",",
"index",
")",
":",
"try",
":",
"val_size",
"=",
"index",
".",
"model",
"(",
")",
".",
"sizes",
"[",
"index",
".",
"row",
"(",
")",
"]",
"val_type",
"=",
"index",
".",
"model",
"(",
")",
".",
"types",
"[",
... | Decide if showing a warning when the user is trying to view
a big variable associated to a Tablemodel index
This avoids getting the variables' value to know its
size and type, using instead those already computed by
the TableModel.
The problem is when a variable is too big, it can take a
lot of time just to get its value | [
"Decide",
"if",
"showing",
"a",
"warning",
"when",
"the",
"user",
"is",
"trying",
"to",
"view",
"a",
"big",
"variable",
"associated",
"to",
"a",
"Tablemodel",
"index",
"This",
"avoids",
"getting",
"the",
"variables",
"value",
"to",
"know",
"its",
"size",
"... | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L435-L456 |
31,340 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | BaseTableView.set_data | def set_data(self, data):
"""Set table data"""
if data is not None:
self.model.set_data(data, self.dictfilter)
self.sortByColumn(0, Qt.AscendingOrder) | python | def set_data(self, data):
"""Set table data"""
if data is not None:
self.model.set_data(data, self.dictfilter)
self.sortByColumn(0, Qt.AscendingOrder) | [
"def",
"set_data",
"(",
"self",
",",
"data",
")",
":",
"if",
"data",
"is",
"not",
"None",
":",
"self",
".",
"model",
".",
"set_data",
"(",
"data",
",",
"self",
".",
"dictfilter",
")",
"self",
".",
"sortByColumn",
"(",
"0",
",",
"Qt",
".",
"Ascendin... | Set table data | [
"Set",
"table",
"data"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L920-L924 |
31,341 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | BaseTableView.keyPressEvent | def keyPressEvent(self, event):
"""Reimplement Qt methods"""
if event.key() == Qt.Key_Delete:
self.remove_item()
elif event.key() == Qt.Key_F2:
self.rename_item()
elif event == QKeySequence.Copy:
self.copy()
elif event == QKeySequence.Paste:
self.paste()
else:
QTableView.keyPressEvent(self, event) | python | def keyPressEvent(self, event):
"""Reimplement Qt methods"""
if event.key() == Qt.Key_Delete:
self.remove_item()
elif event.key() == Qt.Key_F2:
self.rename_item()
elif event == QKeySequence.Copy:
self.copy()
elif event == QKeySequence.Paste:
self.paste()
else:
QTableView.keyPressEvent(self, event) | [
"def",
"keyPressEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"key",
"(",
")",
"==",
"Qt",
".",
"Key_Delete",
":",
"self",
".",
"remove_item",
"(",
")",
"elif",
"event",
".",
"key",
"(",
")",
"==",
"Qt",
".",
"Key_F2",
":",
"se... | Reimplement Qt methods | [
"Reimplement",
"Qt",
"methods"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L953-L964 |
31,342 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | BaseTableView.dragEnterEvent | def dragEnterEvent(self, event):
"""Allow user to drag files"""
if mimedata2url(event.mimeData()):
event.accept()
else:
event.ignore() | python | def dragEnterEvent(self, event):
"""Allow user to drag files"""
if mimedata2url(event.mimeData()):
event.accept()
else:
event.ignore() | [
"def",
"dragEnterEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"mimedata2url",
"(",
"event",
".",
"mimeData",
"(",
")",
")",
":",
"event",
".",
"accept",
"(",
")",
"else",
":",
"event",
".",
"ignore",
"(",
")"
] | Allow user to drag files | [
"Allow",
"user",
"to",
"drag",
"files"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L976-L981 |
31,343 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | BaseTableView.dragMoveEvent | def dragMoveEvent(self, event):
"""Allow user to move files"""
if mimedata2url(event.mimeData()):
event.setDropAction(Qt.CopyAction)
event.accept()
else:
event.ignore() | python | def dragMoveEvent(self, event):
"""Allow user to move files"""
if mimedata2url(event.mimeData()):
event.setDropAction(Qt.CopyAction)
event.accept()
else:
event.ignore() | [
"def",
"dragMoveEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"mimedata2url",
"(",
"event",
".",
"mimeData",
"(",
")",
")",
":",
"event",
".",
"setDropAction",
"(",
"Qt",
".",
"CopyAction",
")",
"event",
".",
"accept",
"(",
")",
"else",
":",
"ev... | Allow user to move files | [
"Allow",
"user",
"to",
"move",
"files"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L983-L989 |
31,344 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | BaseTableView.dropEvent | def dropEvent(self, event):
"""Allow user to drop supported files"""
urls = mimedata2url(event.mimeData())
if urls:
event.setDropAction(Qt.CopyAction)
event.accept()
self.sig_files_dropped.emit(urls)
else:
event.ignore() | python | def dropEvent(self, event):
"""Allow user to drop supported files"""
urls = mimedata2url(event.mimeData())
if urls:
event.setDropAction(Qt.CopyAction)
event.accept()
self.sig_files_dropped.emit(urls)
else:
event.ignore() | [
"def",
"dropEvent",
"(",
"self",
",",
"event",
")",
":",
"urls",
"=",
"mimedata2url",
"(",
"event",
".",
"mimeData",
"(",
")",
")",
"if",
"urls",
":",
"event",
".",
"setDropAction",
"(",
"Qt",
".",
"CopyAction",
")",
"event",
".",
"accept",
"(",
")",... | Allow user to drop supported files | [
"Allow",
"user",
"to",
"drop",
"supported",
"files"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L991-L999 |
31,345 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | BaseTableView.import_from_string | def import_from_string(self, text, title=None):
"""Import data from string"""
data = self.model.get_data()
# Check if data is a dict
if not hasattr(data, "keys"):
return
editor = ImportWizard(self, text, title=title,
contents_title=_("Clipboard contents"),
varname=fix_reference_name("data",
blacklist=list(data.keys())))
if editor.exec_():
var_name, clip_data = editor.get_data()
self.new_value(var_name, clip_data) | python | def import_from_string(self, text, title=None):
"""Import data from string"""
data = self.model.get_data()
# Check if data is a dict
if not hasattr(data, "keys"):
return
editor = ImportWizard(self, text, title=title,
contents_title=_("Clipboard contents"),
varname=fix_reference_name("data",
blacklist=list(data.keys())))
if editor.exec_():
var_name, clip_data = editor.get_data()
self.new_value(var_name, clip_data) | [
"def",
"import_from_string",
"(",
"self",
",",
"text",
",",
"title",
"=",
"None",
")",
":",
"data",
"=",
"self",
".",
"model",
".",
"get_data",
"(",
")",
"# Check if data is a dict\r",
"if",
"not",
"hasattr",
"(",
"data",
",",
"\"keys\"",
")",
":",
"retu... | Import data from string | [
"Import",
"data",
"from",
"string"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1227-L1239 |
31,346 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | CollectionsEditorTableView.is_list | def is_list(self, key):
"""Return True if variable is a list or a tuple"""
data = self.model.get_data()
return isinstance(data[key], (tuple, list)) | python | def is_list(self, key):
"""Return True if variable is a list or a tuple"""
data = self.model.get_data()
return isinstance(data[key], (tuple, list)) | [
"def",
"is_list",
"(",
"self",
",",
"key",
")",
":",
"data",
"=",
"self",
".",
"model",
".",
"get_data",
"(",
")",
"return",
"isinstance",
"(",
"data",
"[",
"key",
"]",
",",
"(",
"tuple",
",",
"list",
")",
")"
] | Return True if variable is a list or a tuple | [
"Return",
"True",
"if",
"variable",
"is",
"a",
"list",
"or",
"a",
"tuple"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1301-L1304 |
31,347 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | CollectionsEditorTableView.is_set | def is_set(self, key):
"""Return True if variable is a set"""
data = self.model.get_data()
return isinstance(data[key], set) | python | def is_set(self, key):
"""Return True if variable is a set"""
data = self.model.get_data()
return isinstance(data[key], set) | [
"def",
"is_set",
"(",
"self",
",",
"key",
")",
":",
"data",
"=",
"self",
".",
"model",
".",
"get_data",
"(",
")",
"return",
"isinstance",
"(",
"data",
"[",
"key",
"]",
",",
"set",
")"
] | Return True if variable is a set | [
"Return",
"True",
"if",
"variable",
"is",
"a",
"set"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1306-L1309 |
31,348 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | CollectionsEditorTableView.get_len | def get_len(self, key):
"""Return sequence length"""
data = self.model.get_data()
return len(data[key]) | python | def get_len(self, key):
"""Return sequence length"""
data = self.model.get_data()
return len(data[key]) | [
"def",
"get_len",
"(",
"self",
",",
"key",
")",
":",
"data",
"=",
"self",
".",
"model",
".",
"get_data",
"(",
")",
"return",
"len",
"(",
"data",
"[",
"key",
"]",
")"
] | Return sequence length | [
"Return",
"sequence",
"length"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1311-L1314 |
31,349 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | CollectionsEditorTableView.is_array | def is_array(self, key):
"""Return True if variable is a numpy array"""
data = self.model.get_data()
return isinstance(data[key], (ndarray, MaskedArray)) | python | def is_array(self, key):
"""Return True if variable is a numpy array"""
data = self.model.get_data()
return isinstance(data[key], (ndarray, MaskedArray)) | [
"def",
"is_array",
"(",
"self",
",",
"key",
")",
":",
"data",
"=",
"self",
".",
"model",
".",
"get_data",
"(",
")",
"return",
"isinstance",
"(",
"data",
"[",
"key",
"]",
",",
"(",
"ndarray",
",",
"MaskedArray",
")",
")"
] | Return True if variable is a numpy array | [
"Return",
"True",
"if",
"variable",
"is",
"a",
"numpy",
"array"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1316-L1319 |
31,350 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | CollectionsEditorTableView.is_dict | def is_dict(self, key):
"""Return True if variable is a dictionary"""
data = self.model.get_data()
return isinstance(data[key], dict) | python | def is_dict(self, key):
"""Return True if variable is a dictionary"""
data = self.model.get_data()
return isinstance(data[key], dict) | [
"def",
"is_dict",
"(",
"self",
",",
"key",
")",
":",
"data",
"=",
"self",
".",
"model",
".",
"get_data",
"(",
")",
"return",
"isinstance",
"(",
"data",
"[",
"key",
"]",
",",
"dict",
")"
] | Return True if variable is a dictionary | [
"Return",
"True",
"if",
"variable",
"is",
"a",
"dictionary"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1326-L1329 |
31,351 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | CollectionsEditorTableView.get_array_shape | def get_array_shape(self, key):
"""Return array's shape"""
data = self.model.get_data()
return data[key].shape | python | def get_array_shape(self, key):
"""Return array's shape"""
data = self.model.get_data()
return data[key].shape | [
"def",
"get_array_shape",
"(",
"self",
",",
"key",
")",
":",
"data",
"=",
"self",
".",
"model",
".",
"get_data",
"(",
")",
"return",
"data",
"[",
"key",
"]",
".",
"shape"
] | Return array's shape | [
"Return",
"array",
"s",
"shape"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1331-L1334 |
31,352 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | CollectionsEditorTableView.get_array_ndim | def get_array_ndim(self, key):
"""Return array's ndim"""
data = self.model.get_data()
return data[key].ndim | python | def get_array_ndim(self, key):
"""Return array's ndim"""
data = self.model.get_data()
return data[key].ndim | [
"def",
"get_array_ndim",
"(",
"self",
",",
"key",
")",
":",
"data",
"=",
"self",
".",
"model",
".",
"get_data",
"(",
")",
"return",
"data",
"[",
"key",
"]",
".",
"ndim"
] | Return array's ndim | [
"Return",
"array",
"s",
"ndim"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1336-L1339 |
31,353 | spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/collectionseditor.py | CollectionsEditor.setup | def setup(self, data, title='', readonly=False, width=650, remote=False,
icon=None, parent=None):
"""Setup editor."""
if isinstance(data, (dict, set)):
# dictionnary, set
self.data_copy = data.copy()
datalen = len(data)
elif isinstance(data, (tuple, list)):
# list, tuple
self.data_copy = data[:]
datalen = len(data)
else:
# unknown object
import copy
try:
self.data_copy = copy.deepcopy(data)
except NotImplementedError:
self.data_copy = copy.copy(data)
except (TypeError, AttributeError):
readonly = True
self.data_copy = data
datalen = len(get_object_attrs(data))
# If the copy has a different type, then do not allow editing, because
# this would change the type after saving; cf. issue #6936
if type(self.data_copy) != type(data):
readonly = True
self.widget = CollectionsEditorWidget(self, self.data_copy,
title=title, readonly=readonly,
remote=remote)
self.widget.editor.model.sig_setting_data.connect(
self.save_and_close_enable)
layout = QVBoxLayout()
layout.addWidget(self.widget)
self.setLayout(layout)
# Buttons configuration
btn_layout = QHBoxLayout()
btn_layout.addStretch()
if not readonly:
self.btn_save_and_close = QPushButton(_('Save and Close'))
self.btn_save_and_close.setDisabled(True)
self.btn_save_and_close.clicked.connect(self.accept)
btn_layout.addWidget(self.btn_save_and_close)
self.btn_close = QPushButton(_('Close'))
self.btn_close.setAutoDefault(True)
self.btn_close.setDefault(True)
self.btn_close.clicked.connect(self.reject)
btn_layout.addWidget(self.btn_close)
layout.addLayout(btn_layout)
constant = 121
row_height = 30
error_margin = 10
height = constant + row_height * min([10, datalen]) + error_margin
self.resize(width, height)
self.setWindowTitle(self.widget.get_title())
if icon is None:
self.setWindowIcon(ima.icon('dictedit'))
if sys.platform == 'darwin':
# See: https://github.com/spyder-ide/spyder/issues/9051
self.setWindowFlags(Qt.Tool)
else:
# Make the dialog act as a window
self.setWindowFlags(Qt.Window) | python | def setup(self, data, title='', readonly=False, width=650, remote=False,
icon=None, parent=None):
"""Setup editor."""
if isinstance(data, (dict, set)):
# dictionnary, set
self.data_copy = data.copy()
datalen = len(data)
elif isinstance(data, (tuple, list)):
# list, tuple
self.data_copy = data[:]
datalen = len(data)
else:
# unknown object
import copy
try:
self.data_copy = copy.deepcopy(data)
except NotImplementedError:
self.data_copy = copy.copy(data)
except (TypeError, AttributeError):
readonly = True
self.data_copy = data
datalen = len(get_object_attrs(data))
# If the copy has a different type, then do not allow editing, because
# this would change the type after saving; cf. issue #6936
if type(self.data_copy) != type(data):
readonly = True
self.widget = CollectionsEditorWidget(self, self.data_copy,
title=title, readonly=readonly,
remote=remote)
self.widget.editor.model.sig_setting_data.connect(
self.save_and_close_enable)
layout = QVBoxLayout()
layout.addWidget(self.widget)
self.setLayout(layout)
# Buttons configuration
btn_layout = QHBoxLayout()
btn_layout.addStretch()
if not readonly:
self.btn_save_and_close = QPushButton(_('Save and Close'))
self.btn_save_and_close.setDisabled(True)
self.btn_save_and_close.clicked.connect(self.accept)
btn_layout.addWidget(self.btn_save_and_close)
self.btn_close = QPushButton(_('Close'))
self.btn_close.setAutoDefault(True)
self.btn_close.setDefault(True)
self.btn_close.clicked.connect(self.reject)
btn_layout.addWidget(self.btn_close)
layout.addLayout(btn_layout)
constant = 121
row_height = 30
error_margin = 10
height = constant + row_height * min([10, datalen]) + error_margin
self.resize(width, height)
self.setWindowTitle(self.widget.get_title())
if icon is None:
self.setWindowIcon(ima.icon('dictedit'))
if sys.platform == 'darwin':
# See: https://github.com/spyder-ide/spyder/issues/9051
self.setWindowFlags(Qt.Tool)
else:
# Make the dialog act as a window
self.setWindowFlags(Qt.Window) | [
"def",
"setup",
"(",
"self",
",",
"data",
",",
"title",
"=",
"''",
",",
"readonly",
"=",
"False",
",",
"width",
"=",
"650",
",",
"remote",
"=",
"False",
",",
"icon",
"=",
"None",
",",
"parent",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"dat... | Setup editor. | [
"Setup",
"editor",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1427-L1497 |
31,354 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.kernel_id | def kernel_id(self):
"""Get kernel id"""
if self.connection_file is not None:
json_file = osp.basename(self.connection_file)
return json_file.split('.json')[0] | python | def kernel_id(self):
"""Get kernel id"""
if self.connection_file is not None:
json_file = osp.basename(self.connection_file)
return json_file.split('.json')[0] | [
"def",
"kernel_id",
"(",
"self",
")",
":",
"if",
"self",
".",
"connection_file",
"is",
"not",
"None",
":",
"json_file",
"=",
"osp",
".",
"basename",
"(",
"self",
".",
"connection_file",
")",
"return",
"json_file",
".",
"split",
"(",
"'.json'",
")",
"[",
... | Get kernel id | [
"Get",
"kernel",
"id"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L194-L198 |
31,355 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.stderr_file | def stderr_file(self):
"""Filename to save kernel stderr output."""
stderr_file = None
if self.connection_file is not None:
stderr_file = self.kernel_id + '.stderr'
if self.stderr_dir is not None:
stderr_file = osp.join(self.stderr_dir, stderr_file)
else:
try:
stderr_file = osp.join(get_temp_dir(), stderr_file)
except (IOError, OSError):
stderr_file = None
return stderr_file | python | def stderr_file(self):
"""Filename to save kernel stderr output."""
stderr_file = None
if self.connection_file is not None:
stderr_file = self.kernel_id + '.stderr'
if self.stderr_dir is not None:
stderr_file = osp.join(self.stderr_dir, stderr_file)
else:
try:
stderr_file = osp.join(get_temp_dir(), stderr_file)
except (IOError, OSError):
stderr_file = None
return stderr_file | [
"def",
"stderr_file",
"(",
"self",
")",
":",
"stderr_file",
"=",
"None",
"if",
"self",
".",
"connection_file",
"is",
"not",
"None",
":",
"stderr_file",
"=",
"self",
".",
"kernel_id",
"+",
"'.stderr'",
"if",
"self",
".",
"stderr_dir",
"is",
"not",
"None",
... | Filename to save kernel stderr output. | [
"Filename",
"to",
"save",
"kernel",
"stderr",
"output",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L201-L213 |
31,356 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.stderr_handle | def stderr_handle(self):
"""Get handle to stderr_file."""
if self.stderr_file is not None:
# Needed to prevent any error that could appear.
# See issue 6267
try:
handle = codecs.open(self.stderr_file, 'w', encoding='utf-8')
except Exception:
handle = None
else:
handle = None
return handle | python | def stderr_handle(self):
"""Get handle to stderr_file."""
if self.stderr_file is not None:
# Needed to prevent any error that could appear.
# See issue 6267
try:
handle = codecs.open(self.stderr_file, 'w', encoding='utf-8')
except Exception:
handle = None
else:
handle = None
return handle | [
"def",
"stderr_handle",
"(",
"self",
")",
":",
"if",
"self",
".",
"stderr_file",
"is",
"not",
"None",
":",
"# Needed to prevent any error that could appear.\r",
"# See issue 6267\r",
"try",
":",
"handle",
"=",
"codecs",
".",
"open",
"(",
"self",
".",
"stderr_file"... | Get handle to stderr_file. | [
"Get",
"handle",
"to",
"stderr_file",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L216-L228 |
31,357 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.remove_stderr_file | def remove_stderr_file(self):
"""Remove stderr_file associated with the client."""
try:
# Defer closing the stderr_handle until the client
# is closed because jupyter_client needs it open
# while it tries to restart the kernel
self.stderr_handle.close()
os.remove(self.stderr_file)
except Exception:
pass | python | def remove_stderr_file(self):
"""Remove stderr_file associated with the client."""
try:
# Defer closing the stderr_handle until the client
# is closed because jupyter_client needs it open
# while it tries to restart the kernel
self.stderr_handle.close()
os.remove(self.stderr_file)
except Exception:
pass | [
"def",
"remove_stderr_file",
"(",
"self",
")",
":",
"try",
":",
"# Defer closing the stderr_handle until the client\r",
"# is closed because jupyter_client needs it open\r",
"# while it tries to restart the kernel\r",
"self",
".",
"stderr_handle",
".",
"close",
"(",
")",
"os",
... | Remove stderr_file associated with the client. | [
"Remove",
"stderr_file",
"associated",
"with",
"the",
"client",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L230-L239 |
31,358 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.configure_shellwidget | def configure_shellwidget(self, give_focus=True):
"""Configure shellwidget after kernel is started"""
if give_focus:
self.get_control().setFocus()
# Set exit callback
self.shellwidget.set_exit_callback()
# To save history
self.shellwidget.executing.connect(self.add_to_history)
# For Mayavi to run correctly
self.shellwidget.executing.connect(
self.shellwidget.set_backend_for_mayavi)
# To update history after execution
self.shellwidget.executed.connect(self.update_history)
# To update the Variable Explorer after execution
self.shellwidget.executed.connect(
self.shellwidget.refresh_namespacebrowser)
# To enable the stop button when executing a process
self.shellwidget.executing.connect(self.enable_stop_button)
# To disable the stop button after execution stopped
self.shellwidget.executed.connect(self.disable_stop_button)
# To show kernel restarted/died messages
self.shellwidget.sig_kernel_restarted.connect(
self.kernel_restarted_message)
# To correctly change Matplotlib backend interactively
self.shellwidget.executing.connect(
self.shellwidget.change_mpl_backend)
# To show env and sys.path contents
self.shellwidget.sig_show_syspath.connect(self.show_syspath)
self.shellwidget.sig_show_env.connect(self.show_env)
# To sync with working directory toolbar
self.shellwidget.executed.connect(self.shellwidget.get_cwd)
# To apply style
self.set_color_scheme(self.shellwidget.syntax_style, reset=False)
# To hide the loading page
self.shellwidget.sig_prompt_ready.connect(self._hide_loading_page)
# Show possible errors when setting Matplotlib backend
self.shellwidget.sig_prompt_ready.connect(
self._show_mpl_backend_errors) | python | def configure_shellwidget(self, give_focus=True):
"""Configure shellwidget after kernel is started"""
if give_focus:
self.get_control().setFocus()
# Set exit callback
self.shellwidget.set_exit_callback()
# To save history
self.shellwidget.executing.connect(self.add_to_history)
# For Mayavi to run correctly
self.shellwidget.executing.connect(
self.shellwidget.set_backend_for_mayavi)
# To update history after execution
self.shellwidget.executed.connect(self.update_history)
# To update the Variable Explorer after execution
self.shellwidget.executed.connect(
self.shellwidget.refresh_namespacebrowser)
# To enable the stop button when executing a process
self.shellwidget.executing.connect(self.enable_stop_button)
# To disable the stop button after execution stopped
self.shellwidget.executed.connect(self.disable_stop_button)
# To show kernel restarted/died messages
self.shellwidget.sig_kernel_restarted.connect(
self.kernel_restarted_message)
# To correctly change Matplotlib backend interactively
self.shellwidget.executing.connect(
self.shellwidget.change_mpl_backend)
# To show env and sys.path contents
self.shellwidget.sig_show_syspath.connect(self.show_syspath)
self.shellwidget.sig_show_env.connect(self.show_env)
# To sync with working directory toolbar
self.shellwidget.executed.connect(self.shellwidget.get_cwd)
# To apply style
self.set_color_scheme(self.shellwidget.syntax_style, reset=False)
# To hide the loading page
self.shellwidget.sig_prompt_ready.connect(self._hide_loading_page)
# Show possible errors when setting Matplotlib backend
self.shellwidget.sig_prompt_ready.connect(
self._show_mpl_backend_errors) | [
"def",
"configure_shellwidget",
"(",
"self",
",",
"give_focus",
"=",
"True",
")",
":",
"if",
"give_focus",
":",
"self",
".",
"get_control",
"(",
")",
".",
"setFocus",
"(",
")",
"# Set exit callback\r",
"self",
".",
"shellwidget",
".",
"set_exit_callback",
"(",... | Configure shellwidget after kernel is started | [
"Configure",
"shellwidget",
"after",
"kernel",
"is",
"started"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L241-L292 |
31,359 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.stop_button_click_handler | def stop_button_click_handler(self):
"""Method to handle what to do when the stop button is pressed"""
self.stop_button.setDisabled(True)
# Interrupt computations or stop debugging
if not self.shellwidget._reading:
self.interrupt_kernel()
else:
self.shellwidget.write_to_stdin('exit') | python | def stop_button_click_handler(self):
"""Method to handle what to do when the stop button is pressed"""
self.stop_button.setDisabled(True)
# Interrupt computations or stop debugging
if not self.shellwidget._reading:
self.interrupt_kernel()
else:
self.shellwidget.write_to_stdin('exit') | [
"def",
"stop_button_click_handler",
"(",
"self",
")",
":",
"self",
".",
"stop_button",
".",
"setDisabled",
"(",
"True",
")",
"# Interrupt computations or stop debugging\r",
"if",
"not",
"self",
".",
"shellwidget",
".",
"_reading",
":",
"self",
".",
"interrupt_kernel... | Method to handle what to do when the stop button is pressed | [
"Method",
"to",
"handle",
"what",
"to",
"do",
"when",
"the",
"stop",
"button",
"is",
"pressed"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L305-L312 |
31,360 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.show_kernel_error | def show_kernel_error(self, error):
"""Show kernel initialization errors in infowidget."""
# Replace end of line chars with <br>
eol = sourcecode.get_eol_chars(error)
if eol:
error = error.replace(eol, '<br>')
# Don't break lines in hyphens
# From https://stackoverflow.com/q/7691569/438386
error = error.replace('-', '‑')
# Create error page
message = _("An error ocurred while starting the kernel")
kernel_error_template = Template(KERNEL_ERROR)
self.info_page = kernel_error_template.substitute(
css_path=self.css_path,
message=message,
error=error)
# Show error
self.set_info_page()
self.shellwidget.hide()
self.infowidget.show()
# Tell the client we're in error mode
self.is_error_shown = True | python | def show_kernel_error(self, error):
"""Show kernel initialization errors in infowidget."""
# Replace end of line chars with <br>
eol = sourcecode.get_eol_chars(error)
if eol:
error = error.replace(eol, '<br>')
# Don't break lines in hyphens
# From https://stackoverflow.com/q/7691569/438386
error = error.replace('-', '‑')
# Create error page
message = _("An error ocurred while starting the kernel")
kernel_error_template = Template(KERNEL_ERROR)
self.info_page = kernel_error_template.substitute(
css_path=self.css_path,
message=message,
error=error)
# Show error
self.set_info_page()
self.shellwidget.hide()
self.infowidget.show()
# Tell the client we're in error mode
self.is_error_shown = True | [
"def",
"show_kernel_error",
"(",
"self",
",",
"error",
")",
":",
"# Replace end of line chars with <br>\r",
"eol",
"=",
"sourcecode",
".",
"get_eol_chars",
"(",
"error",
")",
"if",
"eol",
":",
"error",
"=",
"error",
".",
"replace",
"(",
"eol",
",",
"'<br>'",
... | Show kernel initialization errors in infowidget. | [
"Show",
"kernel",
"initialization",
"errors",
"in",
"infowidget",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L314-L339 |
31,361 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.get_name | def get_name(self):
"""Return client name"""
if self.given_name is None:
# Name according to host
if self.hostname is None:
name = _("Console")
else:
name = self.hostname
# Adding id to name
client_id = self.id_['int_id'] + u'/' + self.id_['str_id']
name = name + u' ' + client_id
elif self.given_name in ["Pylab", "SymPy", "Cython"]:
client_id = self.id_['int_id'] + u'/' + self.id_['str_id']
name = self.given_name + u' ' + client_id
else:
name = self.given_name + u'/' + self.id_['str_id']
return name | python | def get_name(self):
"""Return client name"""
if self.given_name is None:
# Name according to host
if self.hostname is None:
name = _("Console")
else:
name = self.hostname
# Adding id to name
client_id = self.id_['int_id'] + u'/' + self.id_['str_id']
name = name + u' ' + client_id
elif self.given_name in ["Pylab", "SymPy", "Cython"]:
client_id = self.id_['int_id'] + u'/' + self.id_['str_id']
name = self.given_name + u' ' + client_id
else:
name = self.given_name + u'/' + self.id_['str_id']
return name | [
"def",
"get_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"given_name",
"is",
"None",
":",
"# Name according to host\r",
"if",
"self",
".",
"hostname",
"is",
"None",
":",
"name",
"=",
"_",
"(",
"\"Console\"",
")",
"else",
":",
"name",
"=",
"self",
"... | Return client name | [
"Return",
"client",
"name"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L341-L357 |
31,362 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.get_options_menu | def get_options_menu(self):
"""Return options menu"""
env_action = create_action(
self,
_("Show environment variables"),
icon=ima.icon('environ'),
triggered=self.shellwidget.get_env
)
syspath_action = create_action(
self,
_("Show sys.path contents"),
icon=ima.icon('syspath'),
triggered=self.shellwidget.get_syspath
)
self.show_time_action.setChecked(self.show_elapsed_time)
additional_actions = [MENU_SEPARATOR,
env_action,
syspath_action,
self.show_time_action]
if self.menu_actions is not None:
console_menu = self.menu_actions + additional_actions
return console_menu
else:
return additional_actions | python | def get_options_menu(self):
"""Return options menu"""
env_action = create_action(
self,
_("Show environment variables"),
icon=ima.icon('environ'),
triggered=self.shellwidget.get_env
)
syspath_action = create_action(
self,
_("Show sys.path contents"),
icon=ima.icon('syspath'),
triggered=self.shellwidget.get_syspath
)
self.show_time_action.setChecked(self.show_elapsed_time)
additional_actions = [MENU_SEPARATOR,
env_action,
syspath_action,
self.show_time_action]
if self.menu_actions is not None:
console_menu = self.menu_actions + additional_actions
return console_menu
else:
return additional_actions | [
"def",
"get_options_menu",
"(",
"self",
")",
":",
"env_action",
"=",
"create_action",
"(",
"self",
",",
"_",
"(",
"\"Show environment variables\"",
")",
",",
"icon",
"=",
"ima",
".",
"icon",
"(",
"'environ'",
")",
",",
"triggered",
"=",
"self",
".",
"shell... | Return options menu | [
"Return",
"options",
"menu"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L372-L399 |
31,363 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.get_toolbar_buttons | def get_toolbar_buttons(self):
"""Return toolbar buttons list."""
buttons = []
# Code to add the stop button
if self.stop_button is None:
self.stop_button = create_toolbutton(
self,
text=_("Stop"),
icon=self.stop_icon,
tip=_("Stop the current command"))
self.disable_stop_button()
# set click event handler
self.stop_button.clicked.connect(self.stop_button_click_handler)
if is_dark_interface():
self.stop_button.setStyleSheet("QToolButton{padding: 3px;}")
if self.stop_button is not None:
buttons.append(self.stop_button)
# Reset namespace button
if self.reset_button is None:
self.reset_button = create_toolbutton(
self,
text=_("Remove"),
icon=ima.icon('editdelete'),
tip=_("Remove all variables"),
triggered=self.reset_namespace)
if is_dark_interface():
self.reset_button.setStyleSheet("QToolButton{padding: 3px;}")
if self.reset_button is not None:
buttons.append(self.reset_button)
if self.options_button is None:
options = self.get_options_menu()
if options:
self.options_button = create_toolbutton(self,
text=_('Options'), icon=ima.icon('tooloptions'))
self.options_button.setPopupMode(QToolButton.InstantPopup)
menu = QMenu(self)
add_actions(menu, options)
self.options_button.setMenu(menu)
if self.options_button is not None:
buttons.append(self.options_button)
return buttons | python | def get_toolbar_buttons(self):
"""Return toolbar buttons list."""
buttons = []
# Code to add the stop button
if self.stop_button is None:
self.stop_button = create_toolbutton(
self,
text=_("Stop"),
icon=self.stop_icon,
tip=_("Stop the current command"))
self.disable_stop_button()
# set click event handler
self.stop_button.clicked.connect(self.stop_button_click_handler)
if is_dark_interface():
self.stop_button.setStyleSheet("QToolButton{padding: 3px;}")
if self.stop_button is not None:
buttons.append(self.stop_button)
# Reset namespace button
if self.reset_button is None:
self.reset_button = create_toolbutton(
self,
text=_("Remove"),
icon=ima.icon('editdelete'),
tip=_("Remove all variables"),
triggered=self.reset_namespace)
if is_dark_interface():
self.reset_button.setStyleSheet("QToolButton{padding: 3px;}")
if self.reset_button is not None:
buttons.append(self.reset_button)
if self.options_button is None:
options = self.get_options_menu()
if options:
self.options_button = create_toolbutton(self,
text=_('Options'), icon=ima.icon('tooloptions'))
self.options_button.setPopupMode(QToolButton.InstantPopup)
menu = QMenu(self)
add_actions(menu, options)
self.options_button.setMenu(menu)
if self.options_button is not None:
buttons.append(self.options_button)
return buttons | [
"def",
"get_toolbar_buttons",
"(",
"self",
")",
":",
"buttons",
"=",
"[",
"]",
"# Code to add the stop button\r",
"if",
"self",
".",
"stop_button",
"is",
"None",
":",
"self",
".",
"stop_button",
"=",
"create_toolbutton",
"(",
"self",
",",
"text",
"=",
"_",
"... | Return toolbar buttons list. | [
"Return",
"toolbar",
"buttons",
"list",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L401-L445 |
31,364 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.add_actions_to_context_menu | def add_actions_to_context_menu(self, menu):
"""Add actions to IPython widget context menu"""
inspect_action = create_action(self, _("Inspect current object"),
QKeySequence(get_shortcut('console',
'inspect current object')),
icon=ima.icon('MessageBoxInformation'),
triggered=self.inspect_object)
clear_line_action = create_action(self, _("Clear line or block"),
QKeySequence(get_shortcut(
'console',
'clear line')),
triggered=self.clear_line)
reset_namespace_action = create_action(self, _("Remove all variables"),
QKeySequence(get_shortcut(
'ipython_console',
'reset namespace')),
icon=ima.icon('editdelete'),
triggered=self.reset_namespace)
clear_console_action = create_action(self, _("Clear console"),
QKeySequence(get_shortcut('console',
'clear shell')),
triggered=self.clear_console)
quit_action = create_action(self, _("&Quit"), icon=ima.icon('exit'),
triggered=self.exit_callback)
add_actions(menu, (None, inspect_action, clear_line_action,
clear_console_action, reset_namespace_action,
None, quit_action))
return menu | python | def add_actions_to_context_menu(self, menu):
"""Add actions to IPython widget context menu"""
inspect_action = create_action(self, _("Inspect current object"),
QKeySequence(get_shortcut('console',
'inspect current object')),
icon=ima.icon('MessageBoxInformation'),
triggered=self.inspect_object)
clear_line_action = create_action(self, _("Clear line or block"),
QKeySequence(get_shortcut(
'console',
'clear line')),
triggered=self.clear_line)
reset_namespace_action = create_action(self, _("Remove all variables"),
QKeySequence(get_shortcut(
'ipython_console',
'reset namespace')),
icon=ima.icon('editdelete'),
triggered=self.reset_namespace)
clear_console_action = create_action(self, _("Clear console"),
QKeySequence(get_shortcut('console',
'clear shell')),
triggered=self.clear_console)
quit_action = create_action(self, _("&Quit"), icon=ima.icon('exit'),
triggered=self.exit_callback)
add_actions(menu, (None, inspect_action, clear_line_action,
clear_console_action, reset_namespace_action,
None, quit_action))
return menu | [
"def",
"add_actions_to_context_menu",
"(",
"self",
",",
"menu",
")",
":",
"inspect_action",
"=",
"create_action",
"(",
"self",
",",
"_",
"(",
"\"Inspect current object\"",
")",
",",
"QKeySequence",
"(",
"get_shortcut",
"(",
"'console'",
",",
"'inspect current object... | Add actions to IPython widget context menu | [
"Add",
"actions",
"to",
"IPython",
"widget",
"context",
"menu"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L447-L479 |
31,365 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.set_font | def set_font(self, font):
"""Set IPython widget's font"""
self.shellwidget._control.setFont(font)
self.shellwidget.font = font | python | def set_font(self, font):
"""Set IPython widget's font"""
self.shellwidget._control.setFont(font)
self.shellwidget.font = font | [
"def",
"set_font",
"(",
"self",
",",
"font",
")",
":",
"self",
".",
"shellwidget",
".",
"_control",
".",
"setFont",
"(",
"font",
")",
"self",
".",
"shellwidget",
".",
"font",
"=",
"font"
] | Set IPython widget's font | [
"Set",
"IPython",
"widget",
"s",
"font"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L481-L484 |
31,366 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.set_color_scheme | def set_color_scheme(self, color_scheme, reset=True):
"""Set IPython color scheme."""
# Needed to handle not initialized kernel_client
# See issue 6996
try:
self.shellwidget.set_color_scheme(color_scheme, reset)
except AttributeError:
pass | python | def set_color_scheme(self, color_scheme, reset=True):
"""Set IPython color scheme."""
# Needed to handle not initialized kernel_client
# See issue 6996
try:
self.shellwidget.set_color_scheme(color_scheme, reset)
except AttributeError:
pass | [
"def",
"set_color_scheme",
"(",
"self",
",",
"color_scheme",
",",
"reset",
"=",
"True",
")",
":",
"# Needed to handle not initialized kernel_client\r",
"# See issue 6996\r",
"try",
":",
"self",
".",
"shellwidget",
".",
"set_color_scheme",
"(",
"color_scheme",
",",
"re... | Set IPython color scheme. | [
"Set",
"IPython",
"color",
"scheme",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L486-L493 |
31,367 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.restart_kernel | def restart_kernel(self):
"""
Restart the associated kernel.
Took this code from the qtconsole project
Licensed under the BSD license
"""
sw = self.shellwidget
if not running_under_pytest() and self.ask_before_restart:
message = _('Are you sure you want to restart the kernel?')
buttons = QMessageBox.Yes | QMessageBox.No
result = QMessageBox.question(self, _('Restart kernel?'),
message, buttons)
else:
result = None
if (result == QMessageBox.Yes or
running_under_pytest() or
not self.ask_before_restart):
if sw.kernel_manager:
if self.infowidget.isVisible():
self.infowidget.hide()
sw.show()
try:
sw.kernel_manager.restart_kernel(
stderr=self.stderr_handle)
except RuntimeError as e:
sw._append_plain_text(
_('Error restarting kernel: %s\n') % e,
before_prompt=True
)
else:
# For issue 6235. IPython was changing the setting of
# %colors on windows by assuming it was using a dark
# background. This corrects it based on the scheme.
self.set_color_scheme(sw.syntax_style)
sw._append_html(_("<br>Restarting kernel...\n<hr><br>"),
before_prompt=False)
else:
sw._append_plain_text(
_('Cannot restart a kernel not started by Spyder\n'),
before_prompt=True
) | python | def restart_kernel(self):
"""
Restart the associated kernel.
Took this code from the qtconsole project
Licensed under the BSD license
"""
sw = self.shellwidget
if not running_under_pytest() and self.ask_before_restart:
message = _('Are you sure you want to restart the kernel?')
buttons = QMessageBox.Yes | QMessageBox.No
result = QMessageBox.question(self, _('Restart kernel?'),
message, buttons)
else:
result = None
if (result == QMessageBox.Yes or
running_under_pytest() or
not self.ask_before_restart):
if sw.kernel_manager:
if self.infowidget.isVisible():
self.infowidget.hide()
sw.show()
try:
sw.kernel_manager.restart_kernel(
stderr=self.stderr_handle)
except RuntimeError as e:
sw._append_plain_text(
_('Error restarting kernel: %s\n') % e,
before_prompt=True
)
else:
# For issue 6235. IPython was changing the setting of
# %colors on windows by assuming it was using a dark
# background. This corrects it based on the scheme.
self.set_color_scheme(sw.syntax_style)
sw._append_html(_("<br>Restarting kernel...\n<hr><br>"),
before_prompt=False)
else:
sw._append_plain_text(
_('Cannot restart a kernel not started by Spyder\n'),
before_prompt=True
) | [
"def",
"restart_kernel",
"(",
"self",
")",
":",
"sw",
"=",
"self",
".",
"shellwidget",
"if",
"not",
"running_under_pytest",
"(",
")",
"and",
"self",
".",
"ask_before_restart",
":",
"message",
"=",
"_",
"(",
"'Are you sure you want to restart the kernel?'",
")",
... | Restart the associated kernel.
Took this code from the qtconsole project
Licensed under the BSD license | [
"Restart",
"the",
"associated",
"kernel",
".",
"Took",
"this",
"code",
"from",
"the",
"qtconsole",
"project",
"Licensed",
"under",
"the",
"BSD",
"license"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L512-L555 |
31,368 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.reset_namespace | def reset_namespace(self):
"""Resets the namespace by removing all names defined by the user"""
self.shellwidget.reset_namespace(warning=self.reset_warning,
message=True) | python | def reset_namespace(self):
"""Resets the namespace by removing all names defined by the user"""
self.shellwidget.reset_namespace(warning=self.reset_warning,
message=True) | [
"def",
"reset_namespace",
"(",
"self",
")",
":",
"self",
".",
"shellwidget",
".",
"reset_namespace",
"(",
"warning",
"=",
"self",
".",
"reset_warning",
",",
"message",
"=",
"True",
")"
] | Resets the namespace by removing all names defined by the user | [
"Resets",
"the",
"namespace",
"by",
"removing",
"all",
"names",
"defined",
"by",
"the",
"user"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L593-L596 |
31,369 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.show_syspath | def show_syspath(self, syspath):
"""Show sys.path contents."""
if syspath is not None:
editor = CollectionsEditor(self)
editor.setup(syspath, title="sys.path contents", readonly=True,
width=600, icon=ima.icon('syspath'))
self.dialog_manager.show(editor)
else:
return | python | def show_syspath(self, syspath):
"""Show sys.path contents."""
if syspath is not None:
editor = CollectionsEditor(self)
editor.setup(syspath, title="sys.path contents", readonly=True,
width=600, icon=ima.icon('syspath'))
self.dialog_manager.show(editor)
else:
return | [
"def",
"show_syspath",
"(",
"self",
",",
"syspath",
")",
":",
"if",
"syspath",
"is",
"not",
"None",
":",
"editor",
"=",
"CollectionsEditor",
"(",
"self",
")",
"editor",
".",
"setup",
"(",
"syspath",
",",
"title",
"=",
"\"sys.path contents\"",
",",
"readonl... | Show sys.path contents. | [
"Show",
"sys",
".",
"path",
"contents",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L602-L610 |
31,370 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.show_env | def show_env(self, env):
"""Show environment variables."""
self.dialog_manager.show(RemoteEnvDialog(env, parent=self)) | python | def show_env(self, env):
"""Show environment variables."""
self.dialog_manager.show(RemoteEnvDialog(env, parent=self)) | [
"def",
"show_env",
"(",
"self",
",",
"env",
")",
":",
"self",
".",
"dialog_manager",
".",
"show",
"(",
"RemoteEnvDialog",
"(",
"env",
",",
"parent",
"=",
"self",
")",
")"
] | Show environment variables. | [
"Show",
"environment",
"variables",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L613-L615 |
31,371 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.show_time | def show_time(self, end=False):
"""Text to show in time_label."""
if self.time_label is None:
return
elapsed_time = time.monotonic() - self.t0
# System time changed to past date, so reset start.
if elapsed_time < 0:
self.t0 = time.monotonic()
elapsed_time = 0
if elapsed_time > 24 * 3600: # More than a day...!
fmt = "%d %H:%M:%S"
else:
fmt = "%H:%M:%S"
if end:
color = "#AAAAAA"
else:
color = "#AA6655"
text = "<span style=\'color: %s\'><b>%s" \
"</b></span>" % (color,
time.strftime(fmt, time.gmtime(elapsed_time)))
self.time_label.setText(text) | python | def show_time(self, end=False):
"""Text to show in time_label."""
if self.time_label is None:
return
elapsed_time = time.monotonic() - self.t0
# System time changed to past date, so reset start.
if elapsed_time < 0:
self.t0 = time.monotonic()
elapsed_time = 0
if elapsed_time > 24 * 3600: # More than a day...!
fmt = "%d %H:%M:%S"
else:
fmt = "%H:%M:%S"
if end:
color = "#AAAAAA"
else:
color = "#AA6655"
text = "<span style=\'color: %s\'><b>%s" \
"</b></span>" % (color,
time.strftime(fmt, time.gmtime(elapsed_time)))
self.time_label.setText(text) | [
"def",
"show_time",
"(",
"self",
",",
"end",
"=",
"False",
")",
":",
"if",
"self",
".",
"time_label",
"is",
"None",
":",
"return",
"elapsed_time",
"=",
"time",
".",
"monotonic",
"(",
")",
"-",
"self",
".",
"t0",
"# System time changed to past date, so reset ... | Text to show in time_label. | [
"Text",
"to",
"show",
"in",
"time_label",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L623-L644 |
31,372 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget.set_info_page | def set_info_page(self):
"""Set current info_page."""
if self.info_page is not None:
self.infowidget.setHtml(
self.info_page,
QUrl.fromLocalFile(self.css_path)
) | python | def set_info_page(self):
"""Set current info_page."""
if self.info_page is not None:
self.infowidget.setHtml(
self.info_page,
QUrl.fromLocalFile(self.css_path)
) | [
"def",
"set_info_page",
"(",
"self",
")",
":",
"if",
"self",
".",
"info_page",
"is",
"not",
"None",
":",
"self",
".",
"infowidget",
".",
"setHtml",
"(",
"self",
".",
"info_page",
",",
"QUrl",
".",
"fromLocalFile",
"(",
"self",
".",
"css_path",
")",
")"... | Set current info_page. | [
"Set",
"current",
"info_page",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L657-L663 |
31,373 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget._show_loading_page | def _show_loading_page(self):
"""Show animation while the kernel is loading."""
self.shellwidget.hide()
self.infowidget.show()
self.info_page = self.loading_page
self.set_info_page() | python | def _show_loading_page(self):
"""Show animation while the kernel is loading."""
self.shellwidget.hide()
self.infowidget.show()
self.info_page = self.loading_page
self.set_info_page() | [
"def",
"_show_loading_page",
"(",
"self",
")",
":",
"self",
".",
"shellwidget",
".",
"hide",
"(",
")",
"self",
".",
"infowidget",
".",
"show",
"(",
")",
"self",
".",
"info_page",
"=",
"self",
".",
"loading_page",
"self",
".",
"set_info_page",
"(",
")"
] | Show animation while the kernel is loading. | [
"Show",
"animation",
"while",
"the",
"kernel",
"is",
"loading",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L684-L689 |
31,374 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget._hide_loading_page | def _hide_loading_page(self):
"""Hide animation shown while the kernel is loading."""
self.infowidget.hide()
self.shellwidget.show()
self.info_page = self.blank_page
self.set_info_page()
self.shellwidget.sig_prompt_ready.disconnect(self._hide_loading_page) | python | def _hide_loading_page(self):
"""Hide animation shown while the kernel is loading."""
self.infowidget.hide()
self.shellwidget.show()
self.info_page = self.blank_page
self.set_info_page()
self.shellwidget.sig_prompt_ready.disconnect(self._hide_loading_page) | [
"def",
"_hide_loading_page",
"(",
"self",
")",
":",
"self",
".",
"infowidget",
".",
"hide",
"(",
")",
"self",
".",
"shellwidget",
".",
"show",
"(",
")",
"self",
".",
"info_page",
"=",
"self",
".",
"blank_page",
"self",
".",
"set_info_page",
"(",
")",
"... | Hide animation shown while the kernel is loading. | [
"Hide",
"animation",
"shown",
"while",
"the",
"kernel",
"is",
"loading",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L691-L697 |
31,375 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget._read_stderr | def _read_stderr(self):
"""Read the stderr file of the kernel."""
# We need to read stderr_file as bytes to be able to
# detect its encoding with chardet
f = open(self.stderr_file, 'rb')
try:
stderr_text = f.read()
# This is needed to avoid showing an empty error message
# when the kernel takes too much time to start.
# See issue 8581
if not stderr_text:
return ''
# This is needed since the stderr file could be encoded
# in something different to utf-8.
# See issue 4191
encoding = get_coding(stderr_text)
stderr_text = to_text_string(stderr_text, encoding)
return stderr_text
finally:
f.close() | python | def _read_stderr(self):
"""Read the stderr file of the kernel."""
# We need to read stderr_file as bytes to be able to
# detect its encoding with chardet
f = open(self.stderr_file, 'rb')
try:
stderr_text = f.read()
# This is needed to avoid showing an empty error message
# when the kernel takes too much time to start.
# See issue 8581
if not stderr_text:
return ''
# This is needed since the stderr file could be encoded
# in something different to utf-8.
# See issue 4191
encoding = get_coding(stderr_text)
stderr_text = to_text_string(stderr_text, encoding)
return stderr_text
finally:
f.close() | [
"def",
"_read_stderr",
"(",
"self",
")",
":",
"# We need to read stderr_file as bytes to be able to\r",
"# detect its encoding with chardet\r",
"f",
"=",
"open",
"(",
"self",
".",
"stderr_file",
",",
"'rb'",
")",
"try",
":",
"stderr_text",
"=",
"f",
".",
"read",
"("... | Read the stderr file of the kernel. | [
"Read",
"the",
"stderr",
"file",
"of",
"the",
"kernel",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L699-L721 |
31,376 | spyder-ide/spyder | spyder/plugins/ipythonconsole/widgets/client.py | ClientWidget._show_mpl_backend_errors | def _show_mpl_backend_errors(self):
"""
Show possible errors when setting the selected Matplotlib backend.
"""
if not self.external_kernel:
self.shellwidget.silent_execute(
"get_ipython().kernel._show_mpl_backend_errors()")
self.shellwidget.sig_prompt_ready.disconnect(
self._show_mpl_backend_errors) | python | def _show_mpl_backend_errors(self):
"""
Show possible errors when setting the selected Matplotlib backend.
"""
if not self.external_kernel:
self.shellwidget.silent_execute(
"get_ipython().kernel._show_mpl_backend_errors()")
self.shellwidget.sig_prompt_ready.disconnect(
self._show_mpl_backend_errors) | [
"def",
"_show_mpl_backend_errors",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"external_kernel",
":",
"self",
".",
"shellwidget",
".",
"silent_execute",
"(",
"\"get_ipython().kernel._show_mpl_backend_errors()\"",
")",
"self",
".",
"shellwidget",
".",
"sig_prompt... | Show possible errors when setting the selected Matplotlib backend. | [
"Show",
"possible",
"errors",
"when",
"setting",
"the",
"selected",
"Matplotlib",
"backend",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/client.py#L723-L731 |
31,377 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin._format_signature | def _format_signature(self, signature, doc='', parameter='',
parameter_doc='', color=_DEFAULT_TITLE_COLOR,
is_python=False):
"""
Create HTML template for signature.
This template will include indent after the method name, a highlight
color for the active parameter and highlights for special chars.
"""
active_parameter_template = (
'<span style=\'font-family:"{font_family}";'
'font-size:{font_size}pt;'
'color:{color}\'>'
'<b>{parameter}</b>'
'</span>'
)
chars_template = (
'<span style="color:{0};'.format(self._CHAR_HIGHLIGHT_COLOR) +
'font-weight:bold">{char}'
'</span>'
)
def handle_sub(matchobj):
"""
Handle substitution of active parameter template.
This ensures the correct highlight of the active parameter.
"""
match = matchobj.group(0)
new = match.replace(parameter, active_parameter_template)
return new
# Remove duplicate spaces
signature = ' '.join(signature.split())
# Replace ay initial spaces
signature = signature.replace('( ', '(')
# Process signature template
pattern = r'[\*|(|\s](' + parameter + r')[,|)|\s|=]'
formatted_lines = []
name = signature.split('(')[0]
indent = ' ' * (len(name) + 1)
rows = textwrap.wrap(signature, width=60, subsequent_indent=indent)
for row in rows:
# Add template to highlight the active parameter
row = re.sub(pattern, handle_sub, row)
row = row.replace(' ', ' ')
row = row.replace('span ', 'span ')
if is_python:
for char in ['(', ')', ',', '*', '**']:
new_char = chars_template.format(char=char)
row = row.replace(char, new_char)
formatted_lines.append(row)
title_template = '<br>'.join(formatted_lines)
# Get current font properties
font = self.font()
font_size = font.pointSize()
font_family = font.family()
# Format title to display active parameter
title = title_template.format(
font_size=font_size,
font_family=font_family,
color=self._PARAMETER_HIGHLIGHT_COLOR,
parameter=parameter,
)
# Process documentation
# TODO: To be included in a separate PR
# active = active_parameter_template.format(
# font_size=font_size,
# font_family=font_family,
# color=self._PARAMETER_HIGHLIGHT_COLOR,
# parameter=parameter,
# )
# if doc is not None and len(doc) > 0:
# text_doc = doc.split('\n')[0]
# else:
# text_doc = ''
# if parameter_doc is not None and len(parameter_doc) > 0:
# text_prefix = text_doc + '<br><hr><br>param: ' + active
# text = parameter_doc
# else:
# text_prefix = ''
# text = ''
# formatted_lines = []
# rows = textwrap.wrap(text, width=60)
# for row in rows:
# row = row.replace(' ', ' ')
# if text_prefix:
# text = text_prefix + '<br><br>' + '<br>'.join(rows)
# else:
# text = '<br>'.join(rows)
# text += '<br>'
# Format text
tiptext = self._format_text(title, '', color)
return tiptext, rows | python | def _format_signature(self, signature, doc='', parameter='',
parameter_doc='', color=_DEFAULT_TITLE_COLOR,
is_python=False):
"""
Create HTML template for signature.
This template will include indent after the method name, a highlight
color for the active parameter and highlights for special chars.
"""
active_parameter_template = (
'<span style=\'font-family:"{font_family}";'
'font-size:{font_size}pt;'
'color:{color}\'>'
'<b>{parameter}</b>'
'</span>'
)
chars_template = (
'<span style="color:{0};'.format(self._CHAR_HIGHLIGHT_COLOR) +
'font-weight:bold">{char}'
'</span>'
)
def handle_sub(matchobj):
"""
Handle substitution of active parameter template.
This ensures the correct highlight of the active parameter.
"""
match = matchobj.group(0)
new = match.replace(parameter, active_parameter_template)
return new
# Remove duplicate spaces
signature = ' '.join(signature.split())
# Replace ay initial spaces
signature = signature.replace('( ', '(')
# Process signature template
pattern = r'[\*|(|\s](' + parameter + r')[,|)|\s|=]'
formatted_lines = []
name = signature.split('(')[0]
indent = ' ' * (len(name) + 1)
rows = textwrap.wrap(signature, width=60, subsequent_indent=indent)
for row in rows:
# Add template to highlight the active parameter
row = re.sub(pattern, handle_sub, row)
row = row.replace(' ', ' ')
row = row.replace('span ', 'span ')
if is_python:
for char in ['(', ')', ',', '*', '**']:
new_char = chars_template.format(char=char)
row = row.replace(char, new_char)
formatted_lines.append(row)
title_template = '<br>'.join(formatted_lines)
# Get current font properties
font = self.font()
font_size = font.pointSize()
font_family = font.family()
# Format title to display active parameter
title = title_template.format(
font_size=font_size,
font_family=font_family,
color=self._PARAMETER_HIGHLIGHT_COLOR,
parameter=parameter,
)
# Process documentation
# TODO: To be included in a separate PR
# active = active_parameter_template.format(
# font_size=font_size,
# font_family=font_family,
# color=self._PARAMETER_HIGHLIGHT_COLOR,
# parameter=parameter,
# )
# if doc is not None and len(doc) > 0:
# text_doc = doc.split('\n')[0]
# else:
# text_doc = ''
# if parameter_doc is not None and len(parameter_doc) > 0:
# text_prefix = text_doc + '<br><hr><br>param: ' + active
# text = parameter_doc
# else:
# text_prefix = ''
# text = ''
# formatted_lines = []
# rows = textwrap.wrap(text, width=60)
# for row in rows:
# row = row.replace(' ', ' ')
# if text_prefix:
# text = text_prefix + '<br><br>' + '<br>'.join(rows)
# else:
# text = '<br>'.join(rows)
# text += '<br>'
# Format text
tiptext = self._format_text(title, '', color)
return tiptext, rows | [
"def",
"_format_signature",
"(",
"self",
",",
"signature",
",",
"doc",
"=",
"''",
",",
"parameter",
"=",
"''",
",",
"parameter_doc",
"=",
"''",
",",
"color",
"=",
"_DEFAULT_TITLE_COLOR",
",",
"is_python",
"=",
"False",
")",
":",
"active_parameter_template",
... | Create HTML template for signature.
This template will include indent after the method name, a highlight
color for the active parameter and highlights for special chars. | [
"Create",
"HTML",
"template",
"for",
"signature",
".",
"This",
"template",
"will",
"include",
"indent",
"after",
"the",
"method",
"name",
"a",
"highlight",
"color",
"for",
"the",
"active",
"parameter",
"and",
"highlights",
"for",
"special",
"chars",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L185-L288 |
31,378 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.show_calltip | def show_calltip(self, signature, doc='', parameter='', parameter_doc='',
color=_DEFAULT_TITLE_COLOR, is_python=False):
"""
Show calltip.
Calltips look like tooltips but will not disappear if mouse hovers
them. They are useful for displaying signature information on methods
and functions.
"""
# Find position of calltip
point = self._calculate_position()
# Format text
tiptext, wrapped_lines = self._format_signature(
signature,
doc,
parameter,
parameter_doc,
color,
is_python,
)
self._update_stylesheet(self.calltip_widget)
# Show calltip
self.calltip_widget.show_tip(point, tiptext, wrapped_lines) | python | def show_calltip(self, signature, doc='', parameter='', parameter_doc='',
color=_DEFAULT_TITLE_COLOR, is_python=False):
"""
Show calltip.
Calltips look like tooltips but will not disappear if mouse hovers
them. They are useful for displaying signature information on methods
and functions.
"""
# Find position of calltip
point = self._calculate_position()
# Format text
tiptext, wrapped_lines = self._format_signature(
signature,
doc,
parameter,
parameter_doc,
color,
is_python,
)
self._update_stylesheet(self.calltip_widget)
# Show calltip
self.calltip_widget.show_tip(point, tiptext, wrapped_lines) | [
"def",
"show_calltip",
"(",
"self",
",",
"signature",
",",
"doc",
"=",
"''",
",",
"parameter",
"=",
"''",
",",
"parameter_doc",
"=",
"''",
",",
"color",
"=",
"_DEFAULT_TITLE_COLOR",
",",
"is_python",
"=",
"False",
")",
":",
"# Find position of calltip\r",
"p... | Show calltip.
Calltips look like tooltips but will not disappear if mouse hovers
them. They are useful for displaying signature information on methods
and functions. | [
"Show",
"calltip",
".",
"Calltips",
"look",
"like",
"tooltips",
"but",
"will",
"not",
"disappear",
"if",
"mouse",
"hovers",
"them",
".",
"They",
"are",
"useful",
"for",
"displaying",
"signature",
"information",
"on",
"methods",
"and",
"functions",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L290-L315 |
31,379 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.show_tooltip | def show_tooltip(self, title, text, color=_DEFAULT_TITLE_COLOR,
at_line=None, at_position=None, at_point=None):
"""
Show tooltip.
Tooltips will disappear if mouse hovers them. They are meant for quick
inspections.
"""
if text is not None and len(text) != 0:
# Find position of calltip
point = self._calculate_position(
at_line=at_line,
at_position=at_position,
at_point=at_point,
)
# Format text
tiptext = self._format_text(title, text, color, ellide=True)
self._update_stylesheet(self.tooltip_widget)
# Display tooltip
self.tooltip_widget.show_tip(point, tiptext)
self.tooltip_widget.show() | python | def show_tooltip(self, title, text, color=_DEFAULT_TITLE_COLOR,
at_line=None, at_position=None, at_point=None):
"""
Show tooltip.
Tooltips will disappear if mouse hovers them. They are meant for quick
inspections.
"""
if text is not None and len(text) != 0:
# Find position of calltip
point = self._calculate_position(
at_line=at_line,
at_position=at_position,
at_point=at_point,
)
# Format text
tiptext = self._format_text(title, text, color, ellide=True)
self._update_stylesheet(self.tooltip_widget)
# Display tooltip
self.tooltip_widget.show_tip(point, tiptext)
self.tooltip_widget.show() | [
"def",
"show_tooltip",
"(",
"self",
",",
"title",
",",
"text",
",",
"color",
"=",
"_DEFAULT_TITLE_COLOR",
",",
"at_line",
"=",
"None",
",",
"at_position",
"=",
"None",
",",
"at_point",
"=",
"None",
")",
":",
"if",
"text",
"is",
"not",
"None",
"and",
"l... | Show tooltip.
Tooltips will disappear if mouse hovers them. They are meant for quick
inspections. | [
"Show",
"tooltip",
".",
"Tooltips",
"will",
"disappear",
"if",
"mouse",
"hovers",
"them",
".",
"They",
"are",
"meant",
"for",
"quick",
"inspections",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L317-L340 |
31,380 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.get_text_with_eol | def get_text_with_eol(self):
"""Same as 'toPlainText', replace '\n'
by correct end-of-line characters"""
utext = to_text_string(self.toPlainText())
lines = utext.splitlines()
linesep = self.get_line_separator()
txt = linesep.join(lines)
if utext.endswith('\n'):
txt += linesep
return txt | python | def get_text_with_eol(self):
"""Same as 'toPlainText', replace '\n'
by correct end-of-line characters"""
utext = to_text_string(self.toPlainText())
lines = utext.splitlines()
linesep = self.get_line_separator()
txt = linesep.join(lines)
if utext.endswith('\n'):
txt += linesep
return txt | [
"def",
"get_text_with_eol",
"(",
"self",
")",
":",
"utext",
"=",
"to_text_string",
"(",
"self",
".",
"toPlainText",
"(",
")",
")",
"lines",
"=",
"utext",
".",
"splitlines",
"(",
")",
"linesep",
"=",
"self",
".",
"get_line_separator",
"(",
")",
"txt",
"="... | Same as 'toPlainText', replace '\n'
by correct end-of-line characters | [
"Same",
"as",
"toPlainText",
"replace",
"\\",
"n",
"by",
"correct",
"end",
"-",
"of",
"-",
"line",
"characters"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L362-L371 |
31,381 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.get_position | def get_position(self, subject):
"""Get offset in character for the given subject from the start of
text edit area"""
cursor = self.textCursor()
if subject == 'cursor':
pass
elif subject == 'sol':
cursor.movePosition(QTextCursor.StartOfBlock)
elif subject == 'eol':
cursor.movePosition(QTextCursor.EndOfBlock)
elif subject == 'eof':
cursor.movePosition(QTextCursor.End)
elif subject == 'sof':
cursor.movePosition(QTextCursor.Start)
else:
# Assuming that input argument was already a position
return subject
return cursor.position() | python | def get_position(self, subject):
"""Get offset in character for the given subject from the start of
text edit area"""
cursor = self.textCursor()
if subject == 'cursor':
pass
elif subject == 'sol':
cursor.movePosition(QTextCursor.StartOfBlock)
elif subject == 'eol':
cursor.movePosition(QTextCursor.EndOfBlock)
elif subject == 'eof':
cursor.movePosition(QTextCursor.End)
elif subject == 'sof':
cursor.movePosition(QTextCursor.Start)
else:
# Assuming that input argument was already a position
return subject
return cursor.position() | [
"def",
"get_position",
"(",
"self",
",",
"subject",
")",
":",
"cursor",
"=",
"self",
".",
"textCursor",
"(",
")",
"if",
"subject",
"==",
"'cursor'",
":",
"pass",
"elif",
"subject",
"==",
"'sol'",
":",
"cursor",
".",
"movePosition",
"(",
"QTextCursor",
".... | Get offset in character for the given subject from the start of
text edit area | [
"Get",
"offset",
"in",
"character",
"for",
"the",
"given",
"subject",
"from",
"the",
"start",
"of",
"text",
"edit",
"area"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L375-L392 |
31,382 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.set_cursor_position | def set_cursor_position(self, position):
"""Set cursor position"""
position = self.get_position(position)
cursor = self.textCursor()
cursor.setPosition(position)
self.setTextCursor(cursor)
self.ensureCursorVisible() | python | def set_cursor_position(self, position):
"""Set cursor position"""
position = self.get_position(position)
cursor = self.textCursor()
cursor.setPosition(position)
self.setTextCursor(cursor)
self.ensureCursorVisible() | [
"def",
"set_cursor_position",
"(",
"self",
",",
"position",
")",
":",
"position",
"=",
"self",
".",
"get_position",
"(",
"position",
")",
"cursor",
"=",
"self",
".",
"textCursor",
"(",
")",
"cursor",
".",
"setPosition",
"(",
"position",
")",
"self",
".",
... | Set cursor position | [
"Set",
"cursor",
"position"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L410-L416 |
31,383 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.is_cursor_on_first_line | def is_cursor_on_first_line(self):
"""Return True if cursor is on the first line"""
cursor = self.textCursor()
cursor.movePosition(QTextCursor.StartOfBlock)
return cursor.atStart() | python | def is_cursor_on_first_line(self):
"""Return True if cursor is on the first line"""
cursor = self.textCursor()
cursor.movePosition(QTextCursor.StartOfBlock)
return cursor.atStart() | [
"def",
"is_cursor_on_first_line",
"(",
"self",
")",
":",
"cursor",
"=",
"self",
".",
"textCursor",
"(",
")",
"cursor",
".",
"movePosition",
"(",
"QTextCursor",
".",
"StartOfBlock",
")",
"return",
"cursor",
".",
"atStart",
"(",
")"
] | Return True if cursor is on the first line | [
"Return",
"True",
"if",
"cursor",
"is",
"on",
"the",
"first",
"line"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L424-L428 |
31,384 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.is_cursor_on_last_line | def is_cursor_on_last_line(self):
"""Return True if cursor is on the last line"""
cursor = self.textCursor()
cursor.movePosition(QTextCursor.EndOfBlock)
return cursor.atEnd() | python | def is_cursor_on_last_line(self):
"""Return True if cursor is on the last line"""
cursor = self.textCursor()
cursor.movePosition(QTextCursor.EndOfBlock)
return cursor.atEnd() | [
"def",
"is_cursor_on_last_line",
"(",
"self",
")",
":",
"cursor",
"=",
"self",
".",
"textCursor",
"(",
")",
"cursor",
".",
"movePosition",
"(",
"QTextCursor",
".",
"EndOfBlock",
")",
"return",
"cursor",
".",
"atEnd",
"(",
")"
] | Return True if cursor is on the last line | [
"Return",
"True",
"if",
"cursor",
"is",
"on",
"the",
"last",
"line"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L430-L434 |
31,385 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.clear_selection | def clear_selection(self):
"""Clear current selection"""
cursor = self.textCursor()
cursor.clearSelection()
self.setTextCursor(cursor) | python | def clear_selection(self):
"""Clear current selection"""
cursor = self.textCursor()
cursor.clearSelection()
self.setTextCursor(cursor) | [
"def",
"clear_selection",
"(",
"self",
")",
":",
"cursor",
"=",
"self",
".",
"textCursor",
"(",
")",
"cursor",
".",
"clearSelection",
"(",
")",
"self",
".",
"setTextCursor",
"(",
"cursor",
")"
] | Clear current selection | [
"Clear",
"current",
"selection"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L476-L480 |
31,386 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.get_current_word_and_position | def get_current_word_and_position(self, completion=False):
"""Return current word, i.e. word at cursor position,
and the start position"""
cursor = self.textCursor()
if cursor.hasSelection():
# Removes the selection and moves the cursor to the left side
# of the selection: this is required to be able to properly
# select the whole word under cursor (otherwise, the same word is
# not selected when the cursor is at the right side of it):
cursor.setPosition(min([cursor.selectionStart(),
cursor.selectionEnd()]))
else:
# Checks if the first character to the right is a white space
# and if not, moves the cursor one word to the left (otherwise,
# if the character to the left do not match the "word regexp"
# (see below), the word to the left of the cursor won't be
# selected), but only if the first character to the left is not a
# white space too.
def is_space(move):
curs = self.textCursor()
curs.movePosition(move, QTextCursor.KeepAnchor)
return not to_text_string(curs.selectedText()).strip()
if not completion:
if is_space(QTextCursor.NextCharacter):
if is_space(QTextCursor.PreviousCharacter):
return
cursor.movePosition(QTextCursor.WordLeft)
else:
def is_special_character(move):
curs = self.textCursor()
curs.movePosition(move, QTextCursor.KeepAnchor)
text_cursor = to_text_string(curs.selectedText()).strip()
return len(re.findall(r'([^\d\W]\w*)',
text_cursor, re.UNICODE)) == 0
if is_space(QTextCursor.PreviousCharacter):
return
if (is_special_character(QTextCursor.NextCharacter)):
cursor.movePosition(QTextCursor.WordLeft)
cursor.select(QTextCursor.WordUnderCursor)
text = to_text_string(cursor.selectedText())
# find a valid python variable name
match = re.findall(r'([^\d\W]\w*)', text, re.UNICODE)
if match:
return match[0], cursor.selectionStart() | python | def get_current_word_and_position(self, completion=False):
"""Return current word, i.e. word at cursor position,
and the start position"""
cursor = self.textCursor()
if cursor.hasSelection():
# Removes the selection and moves the cursor to the left side
# of the selection: this is required to be able to properly
# select the whole word under cursor (otherwise, the same word is
# not selected when the cursor is at the right side of it):
cursor.setPosition(min([cursor.selectionStart(),
cursor.selectionEnd()]))
else:
# Checks if the first character to the right is a white space
# and if not, moves the cursor one word to the left (otherwise,
# if the character to the left do not match the "word regexp"
# (see below), the word to the left of the cursor won't be
# selected), but only if the first character to the left is not a
# white space too.
def is_space(move):
curs = self.textCursor()
curs.movePosition(move, QTextCursor.KeepAnchor)
return not to_text_string(curs.selectedText()).strip()
if not completion:
if is_space(QTextCursor.NextCharacter):
if is_space(QTextCursor.PreviousCharacter):
return
cursor.movePosition(QTextCursor.WordLeft)
else:
def is_special_character(move):
curs = self.textCursor()
curs.movePosition(move, QTextCursor.KeepAnchor)
text_cursor = to_text_string(curs.selectedText()).strip()
return len(re.findall(r'([^\d\W]\w*)',
text_cursor, re.UNICODE)) == 0
if is_space(QTextCursor.PreviousCharacter):
return
if (is_special_character(QTextCursor.NextCharacter)):
cursor.movePosition(QTextCursor.WordLeft)
cursor.select(QTextCursor.WordUnderCursor)
text = to_text_string(cursor.selectedText())
# find a valid python variable name
match = re.findall(r'([^\d\W]\w*)', text, re.UNICODE)
if match:
return match[0], cursor.selectionStart() | [
"def",
"get_current_word_and_position",
"(",
"self",
",",
"completion",
"=",
"False",
")",
":",
"cursor",
"=",
"self",
".",
"textCursor",
"(",
")",
"if",
"cursor",
".",
"hasSelection",
"(",
")",
":",
"# Removes the selection and moves the cursor to the left side\r",
... | Return current word, i.e. word at cursor position,
and the start position | [
"Return",
"current",
"word",
"i",
".",
"e",
".",
"word",
"at",
"cursor",
"position",
"and",
"the",
"start",
"position"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L551-L596 |
31,387 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.get_current_word | def get_current_word(self, completion=False):
"""Return current word, i.e. word at cursor position"""
ret = self.get_current_word_and_position(completion)
if ret is not None:
return ret[0] | python | def get_current_word(self, completion=False):
"""Return current word, i.e. word at cursor position"""
ret = self.get_current_word_and_position(completion)
if ret is not None:
return ret[0] | [
"def",
"get_current_word",
"(",
"self",
",",
"completion",
"=",
"False",
")",
":",
"ret",
"=",
"self",
".",
"get_current_word_and_position",
"(",
"completion",
")",
"if",
"ret",
"is",
"not",
"None",
":",
"return",
"ret",
"[",
"0",
"]"
] | Return current word, i.e. word at cursor position | [
"Return",
"current",
"word",
"i",
".",
"e",
".",
"word",
"at",
"cursor",
"position"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L598-L602 |
31,388 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.get_current_line | def get_current_line(self):
"""Return current line's text"""
cursor = self.textCursor()
cursor.select(QTextCursor.BlockUnderCursor)
return to_text_string(cursor.selectedText()) | python | def get_current_line(self):
"""Return current line's text"""
cursor = self.textCursor()
cursor.select(QTextCursor.BlockUnderCursor)
return to_text_string(cursor.selectedText()) | [
"def",
"get_current_line",
"(",
"self",
")",
":",
"cursor",
"=",
"self",
".",
"textCursor",
"(",
")",
"cursor",
".",
"select",
"(",
"QTextCursor",
".",
"BlockUnderCursor",
")",
"return",
"to_text_string",
"(",
"cursor",
".",
"selectedText",
"(",
")",
")"
] | Return current line's text | [
"Return",
"current",
"line",
"s",
"text"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L604-L608 |
31,389 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.get_selected_text | def get_selected_text(self):
"""
Return text selected by current text cursor, converted in unicode
Replace the unicode line separator character \u2029 by
the line separator characters returned by get_line_separator
"""
return to_text_string(self.textCursor().selectedText()).replace(u"\u2029",
self.get_line_separator()) | python | def get_selected_text(self):
"""
Return text selected by current text cursor, converted in unicode
Replace the unicode line separator character \u2029 by
the line separator characters returned by get_line_separator
"""
return to_text_string(self.textCursor().selectedText()).replace(u"\u2029",
self.get_line_separator()) | [
"def",
"get_selected_text",
"(",
"self",
")",
":",
"return",
"to_text_string",
"(",
"self",
".",
"textCursor",
"(",
")",
".",
"selectedText",
"(",
")",
")",
".",
"replace",
"(",
"u\"\\u2029\"",
",",
"self",
".",
"get_line_separator",
"(",
")",
")"
] | Return text selected by current text cursor, converted in unicode
Replace the unicode line separator character \u2029 by
the line separator characters returned by get_line_separator | [
"Return",
"text",
"selected",
"by",
"current",
"text",
"cursor",
"converted",
"in",
"unicode",
"Replace",
"the",
"unicode",
"line",
"separator",
"character",
"\\",
"u2029",
"by",
"the",
"line",
"separator",
"characters",
"returned",
"by",
"get_line_separator"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L651-L659 |
31,390 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.get_number_matches | def get_number_matches(self, pattern, source_text='', case=False,
regexp=False):
"""Get the number of matches for the searched text."""
pattern = to_text_string(pattern)
if not pattern:
return 0
if not regexp:
pattern = re.escape(pattern)
if not source_text:
source_text = to_text_string(self.toPlainText())
try:
if case:
regobj = re.compile(pattern)
else:
regobj = re.compile(pattern, re.IGNORECASE)
except sre_constants.error:
return None
number_matches = 0
for match in regobj.finditer(source_text):
number_matches += 1
return number_matches | python | def get_number_matches(self, pattern, source_text='', case=False,
regexp=False):
"""Get the number of matches for the searched text."""
pattern = to_text_string(pattern)
if not pattern:
return 0
if not regexp:
pattern = re.escape(pattern)
if not source_text:
source_text = to_text_string(self.toPlainText())
try:
if case:
regobj = re.compile(pattern)
else:
regobj = re.compile(pattern, re.IGNORECASE)
except sre_constants.error:
return None
number_matches = 0
for match in regobj.finditer(source_text):
number_matches += 1
return number_matches | [
"def",
"get_number_matches",
"(",
"self",
",",
"pattern",
",",
"source_text",
"=",
"''",
",",
"case",
"=",
"False",
",",
"regexp",
"=",
"False",
")",
":",
"pattern",
"=",
"to_text_string",
"(",
"pattern",
")",
"if",
"not",
"pattern",
":",
"return",
"0",
... | Get the number of matches for the searched text. | [
"Get",
"the",
"number",
"of",
"matches",
"for",
"the",
"searched",
"text",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L773-L798 |
31,391 | spyder-ide/spyder | spyder/widgets/mixins.py | BaseEditMixin.get_match_number | def get_match_number(self, pattern, case=False, regexp=False):
"""Get number of the match for the searched text."""
position = self.textCursor().position()
source_text = self.get_text(position_from='sof', position_to=position)
match_number = self.get_number_matches(pattern,
source_text=source_text,
case=case, regexp=regexp)
return match_number | python | def get_match_number(self, pattern, case=False, regexp=False):
"""Get number of the match for the searched text."""
position = self.textCursor().position()
source_text = self.get_text(position_from='sof', position_to=position)
match_number = self.get_number_matches(pattern,
source_text=source_text,
case=case, regexp=regexp)
return match_number | [
"def",
"get_match_number",
"(",
"self",
",",
"pattern",
",",
"case",
"=",
"False",
",",
"regexp",
"=",
"False",
")",
":",
"position",
"=",
"self",
".",
"textCursor",
"(",
")",
".",
"position",
"(",
")",
"source_text",
"=",
"self",
".",
"get_text",
"(",... | Get number of the match for the searched text. | [
"Get",
"number",
"of",
"the",
"match",
"for",
"the",
"searched",
"text",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L800-L807 |
31,392 | spyder-ide/spyder | spyder/widgets/mixins.py | TracebackLinksMixin.mouseReleaseEvent | def mouseReleaseEvent(self, event):
"""Go to error"""
self.QT_CLASS.mouseReleaseEvent(self, event)
text = self.get_line_at(event.pos())
if get_error_match(text) and not self.has_selected_text():
if self.go_to_error is not None:
self.go_to_error.emit(text) | python | def mouseReleaseEvent(self, event):
"""Go to error"""
self.QT_CLASS.mouseReleaseEvent(self, event)
text = self.get_line_at(event.pos())
if get_error_match(text) and not self.has_selected_text():
if self.go_to_error is not None:
self.go_to_error.emit(text) | [
"def",
"mouseReleaseEvent",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"QT_CLASS",
".",
"mouseReleaseEvent",
"(",
"self",
",",
"event",
")",
"text",
"=",
"self",
".",
"get_line_at",
"(",
"event",
".",
"pos",
"(",
")",
")",
"if",
"get_error_match",... | Go to error | [
"Go",
"to",
"error"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L862-L868 |
31,393 | spyder-ide/spyder | spyder/widgets/mixins.py | TracebackLinksMixin.mouseMoveEvent | def mouseMoveEvent(self, event):
"""Show Pointing Hand Cursor on error messages"""
text = self.get_line_at(event.pos())
if get_error_match(text):
if not self.__cursor_changed:
QApplication.setOverrideCursor(QCursor(Qt.PointingHandCursor))
self.__cursor_changed = True
event.accept()
return
if self.__cursor_changed:
QApplication.restoreOverrideCursor()
self.__cursor_changed = False
self.QT_CLASS.mouseMoveEvent(self, event) | python | def mouseMoveEvent(self, event):
"""Show Pointing Hand Cursor on error messages"""
text = self.get_line_at(event.pos())
if get_error_match(text):
if not self.__cursor_changed:
QApplication.setOverrideCursor(QCursor(Qt.PointingHandCursor))
self.__cursor_changed = True
event.accept()
return
if self.__cursor_changed:
QApplication.restoreOverrideCursor()
self.__cursor_changed = False
self.QT_CLASS.mouseMoveEvent(self, event) | [
"def",
"mouseMoveEvent",
"(",
"self",
",",
"event",
")",
":",
"text",
"=",
"self",
".",
"get_line_at",
"(",
"event",
".",
"pos",
"(",
")",
")",
"if",
"get_error_match",
"(",
"text",
")",
":",
"if",
"not",
"self",
".",
"__cursor_changed",
":",
"QApplica... | Show Pointing Hand Cursor on error messages | [
"Show",
"Pointing",
"Hand",
"Cursor",
"on",
"error",
"messages"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L870-L882 |
31,394 | spyder-ide/spyder | spyder/widgets/mixins.py | TracebackLinksMixin.leaveEvent | def leaveEvent(self, event):
"""If cursor has not been restored yet, do it now"""
if self.__cursor_changed:
QApplication.restoreOverrideCursor()
self.__cursor_changed = False
self.QT_CLASS.leaveEvent(self, event) | python | def leaveEvent(self, event):
"""If cursor has not been restored yet, do it now"""
if self.__cursor_changed:
QApplication.restoreOverrideCursor()
self.__cursor_changed = False
self.QT_CLASS.leaveEvent(self, event) | [
"def",
"leaveEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"self",
".",
"__cursor_changed",
":",
"QApplication",
".",
"restoreOverrideCursor",
"(",
")",
"self",
".",
"__cursor_changed",
"=",
"False",
"self",
".",
"QT_CLASS",
".",
"leaveEvent",
"(",
"sel... | If cursor has not been restored yet, do it now | [
"If",
"cursor",
"has",
"not",
"been",
"restored",
"yet",
"do",
"it",
"now"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L884-L889 |
31,395 | spyder-ide/spyder | spyder/widgets/mixins.py | SaveHistoryMixin.create_history_filename | def create_history_filename(self):
"""Create history_filename with INITHISTORY if it doesn't exist."""
if self.history_filename and not osp.isfile(self.history_filename):
try:
encoding.writelines(self.INITHISTORY, self.history_filename)
except EnvironmentError:
pass | python | def create_history_filename(self):
"""Create history_filename with INITHISTORY if it doesn't exist."""
if self.history_filename and not osp.isfile(self.history_filename):
try:
encoding.writelines(self.INITHISTORY, self.history_filename)
except EnvironmentError:
pass | [
"def",
"create_history_filename",
"(",
"self",
")",
":",
"if",
"self",
".",
"history_filename",
"and",
"not",
"osp",
".",
"isfile",
"(",
"self",
".",
"history_filename",
")",
":",
"try",
":",
"encoding",
".",
"writelines",
"(",
"self",
".",
"INITHISTORY",
... | Create history_filename with INITHISTORY if it doesn't exist. | [
"Create",
"history_filename",
"with",
"INITHISTORY",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L988-L994 |
31,396 | spyder-ide/spyder | spyder/widgets/mixins.py | SaveHistoryMixin.add_to_history | def add_to_history(self, command):
"""Add command to history"""
command = to_text_string(command)
if command in ['', '\n'] or command.startswith('Traceback'):
return
if command.endswith('\n'):
command = command[:-1]
self.histidx = None
if len(self.history) > 0 and self.history[-1] == command:
return
self.history.append(command)
text = os.linesep + command
# When the first entry will be written in history file,
# the separator will be append first:
if self.history_filename not in self.HISTORY_FILENAMES:
self.HISTORY_FILENAMES.append(self.history_filename)
text = self.SEPARATOR + text
# Needed to prevent errors when writing history to disk
# See issue 6431
try:
encoding.write(text, self.history_filename, mode='ab')
except EnvironmentError:
pass
if self.append_to_history is not None:
self.append_to_history.emit(self.history_filename, text) | python | def add_to_history(self, command):
"""Add command to history"""
command = to_text_string(command)
if command in ['', '\n'] or command.startswith('Traceback'):
return
if command.endswith('\n'):
command = command[:-1]
self.histidx = None
if len(self.history) > 0 and self.history[-1] == command:
return
self.history.append(command)
text = os.linesep + command
# When the first entry will be written in history file,
# the separator will be append first:
if self.history_filename not in self.HISTORY_FILENAMES:
self.HISTORY_FILENAMES.append(self.history_filename)
text = self.SEPARATOR + text
# Needed to prevent errors when writing history to disk
# See issue 6431
try:
encoding.write(text, self.history_filename, mode='ab')
except EnvironmentError:
pass
if self.append_to_history is not None:
self.append_to_history.emit(self.history_filename, text) | [
"def",
"add_to_history",
"(",
"self",
",",
"command",
")",
":",
"command",
"=",
"to_text_string",
"(",
"command",
")",
"if",
"command",
"in",
"[",
"''",
",",
"'\\n'",
"]",
"or",
"command",
".",
"startswith",
"(",
"'Traceback'",
")",
":",
"return",
"if",
... | Add command to history | [
"Add",
"command",
"to",
"history"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L996-L1021 |
31,397 | spyder-ide/spyder | spyder/widgets/mixins.py | BrowseHistoryMixin.find_in_history | def find_in_history(self, tocursor, start_idx, backward):
"""Find text 'tocursor' in history, from index 'start_idx'"""
if start_idx is None:
start_idx = len(self.history)
# Finding text in history
step = -1 if backward else 1
idx = start_idx
if len(tocursor) == 0 or self.hist_wholeline:
idx += step
if idx >= len(self.history) or len(self.history) == 0:
return "", len(self.history)
elif idx < 0:
idx = 0
self.hist_wholeline = True
return self.history[idx], idx
else:
for index in range(len(self.history)):
idx = (start_idx+step*(index+1)) % len(self.history)
entry = self.history[idx]
if entry.startswith(tocursor):
return entry[len(tocursor):], idx
else:
return None, start_idx | python | def find_in_history(self, tocursor, start_idx, backward):
"""Find text 'tocursor' in history, from index 'start_idx'"""
if start_idx is None:
start_idx = len(self.history)
# Finding text in history
step = -1 if backward else 1
idx = start_idx
if len(tocursor) == 0 or self.hist_wholeline:
idx += step
if idx >= len(self.history) or len(self.history) == 0:
return "", len(self.history)
elif idx < 0:
idx = 0
self.hist_wholeline = True
return self.history[idx], idx
else:
for index in range(len(self.history)):
idx = (start_idx+step*(index+1)) % len(self.history)
entry = self.history[idx]
if entry.startswith(tocursor):
return entry[len(tocursor):], idx
else:
return None, start_idx | [
"def",
"find_in_history",
"(",
"self",
",",
"tocursor",
",",
"start_idx",
",",
"backward",
")",
":",
"if",
"start_idx",
"is",
"None",
":",
"start_idx",
"=",
"len",
"(",
"self",
".",
"history",
")",
"# Finding text in history\r",
"step",
"=",
"-",
"1",
"if"... | Find text 'tocursor' in history, from index 'start_idx | [
"Find",
"text",
"tocursor",
"in",
"history",
"from",
"index",
"start_idx"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L1054-L1076 |
31,398 | spyder-ide/spyder | spyder/preferences/shortcuts.py | ShortcutTranslator.keyevent_to_keyseq | def keyevent_to_keyseq(self, event):
"""Return a QKeySequence representation of the provided QKeyEvent."""
self.keyPressEvent(event)
event.accept()
return self.keySequence() | python | def keyevent_to_keyseq(self, event):
"""Return a QKeySequence representation of the provided QKeyEvent."""
self.keyPressEvent(event)
event.accept()
return self.keySequence() | [
"def",
"keyevent_to_keyseq",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"keyPressEvent",
"(",
"event",
")",
"event",
".",
"accept",
"(",
")",
"return",
"self",
".",
"keySequence",
"(",
")"
] | Return a QKeySequence representation of the provided QKeyEvent. | [
"Return",
"a",
"QKeySequence",
"representation",
"of",
"the",
"provided",
"QKeyEvent",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/shortcuts.py#L74-L78 |
31,399 | spyder-ide/spyder | spyder/preferences/shortcuts.py | ShortcutLineEdit.setText | def setText(self, sequence):
"""Qt method extension."""
self.setToolTip(sequence)
super(ShortcutLineEdit, self).setText(sequence) | python | def setText(self, sequence):
"""Qt method extension."""
self.setToolTip(sequence)
super(ShortcutLineEdit, self).setText(sequence) | [
"def",
"setText",
"(",
"self",
",",
"sequence",
")",
":",
"self",
".",
"setToolTip",
"(",
"sequence",
")",
"super",
"(",
"ShortcutLineEdit",
",",
"self",
")",
".",
"setText",
"(",
"sequence",
")"
] | Qt method extension. | [
"Qt",
"method",
"extension",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/shortcuts.py#L115-L118 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.