Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def _get_input_buffer(self):
input_buffer = ''
if self.current_prompt_pos is not None:
input_buffer = self.get_text(self.current_prompt_pos, 'eol')
input_buffer = input_buffer.replace(os.linesep, '\n')
return inp... | [
"Return input buffer"
] |
Please provide a description of the function:def new_prompt(self, prompt):
if self.get_cursor_line_column()[1] != 0:
self.write('\n')
self.write(prompt, prompt=True)
# now we update our cursor giving end of prompt
self.current_prompt_pos = self.get_position('cu... | [
"\r\n Print a new prompt and save its (line, index) position\r\n "
] |
Please provide a description of the function:def check_selection(self):
if self.current_prompt_pos is None:
self.set_cursor_position('eof')
else:
self.truncate_selection(self.current_prompt_pos) | [
"\r\n Check if selected text is r/w,\r\n otherwise remove read-only parts of selection\r\n "
] |
Please provide a description of the function:def copy(self):
if self.has_selected_text():
ConsoleBaseWidget.copy(self)
elif not sys.platform == 'darwin':
self.interrupt() | [
"Copy text to clipboard... or keyboard interrupt"
] |
Please provide a description of the function:def save_historylog(self):
title = _("Save history log")
self.redirect_stdio.emit(False)
filename, _selfilter = getsavefilename(self, title,
self.historylog_filename, "%s (*.log)" % _("History logs"))
self.re... | [
"Save current history log (all text in console)"
] |
Please provide a description of the function:def on_new_line(self):
self.set_cursor_position('eof')
self.current_prompt_pos = self.get_position('cursor')
self.new_input_line = False | [
"On new input line"
] |
Please provide a description of the function:def preprocess_keyevent(self, event):
# Copy must be done first to be able to copy read-only text parts
# (otherwise, right below, we would remove selection
# if not on current line)
ctrl = event.modifiers() & Qt.ControlModifier... | [
"Pre-process keypress event:\r\n return True if event is accepted, false otherwise"
] |
Please provide a description of the function:def postprocess_keyevent(self, event):
event, text, key, ctrl, shift = restore_keyevent(event)
# Is cursor on the last line? and after prompt?
if len(text):
#XXX: Shouldn't it be: `if len(unicode(text).strip(os.line... | [
"Post-process keypress event:\r\n in InternalShell, this is method is called when shell is ready"
] |
Please provide a description of the function:def load_history(self):
if osp.isfile(self.history_filename):
rawhistory, _ = encoding.readlines(self.history_filename)
rawhistory = [line.replace('\n', '') for line in rawhistory]
if rawhistory[1] != self.INITHISTORY... | [
"Load history from a .py file in user home directory"
] |
Please provide a description of the function:def write_error(self, text):
self.flush()
self.write(text, flush=True, error=True)
if get_debug_level():
STDERR.write(text) | [
"Simulate stderr"
] |
Please provide a description of the function:def write(self, text, flush=False, error=False, prompt=False):
if prompt:
self.flush()
if not is_string(text):
# This test is useful to discriminate QStrings from decoded str
text = to_text_string(text)
... | [
"Simulate stdout and stderr"
] |
Please provide a description of the function:def flush(self, error=False, prompt=False):
# Fix for Issue 2452
if PY3:
try:
text = "".join(self.__buffer)
except TypeError:
text = b"".join(self.__buffer)
try:
... | [
"Flush buffer, write text to console"
] |
Please provide a description of the function:def insert_text(self, text, at_end=False, error=False, prompt=False):
if at_end:
# Insert text at the end of the command line
self.append_text_to_shell(text, error, prompt)
else:
# Insert text at current curs... | [
"\r\n Insert text at the current cursor position\r\n or at the end of the command line\r\n "
] |
Please provide a description of the function:def dropEvent(self, event):
if (event.mimeData().hasFormat("text/plain")):
text = to_text_string(event.mimeData().text())
if self.new_input_line:
self.on_new_line()
self.insert_text(text, at_end=True)... | [
"Drag and Drop - Drop event"
] |
Please provide a description of the function:def setup_context_menu(self):
ShellBaseWidget.setup_context_menu(self)
self.copy_without_prompts_action = create_action(self,
_("Copy without prompts"),
icon=ima.icon('cop... | [
"Reimplements ShellBaseWidget method"
] |
Please provide a description of the function:def contextMenuEvent(self, event):
state = self.has_selected_text()
self.copy_without_prompts_action.setEnabled(state)
ShellBaseWidget.contextMenuEvent(self, event) | [
"Reimplements ShellBaseWidget method"
] |
Please provide a description of the function:def copy_without_prompts(self):
text = self.get_selected_text()
lines = text.split(os.linesep)
for index, line in enumerate(lines):
if line.startswith('>>> ') or line.startswith('... '):
lines[index] = line[4... | [
"Copy text to clipboard without prompts"
] |
Please provide a description of the function:def postprocess_keyevent(self, event):
ShellBaseWidget.postprocess_keyevent(self, event)
if QToolTip.isVisible():
_event, _text, key, _ctrl, _shift = restore_keyevent(event)
self.hide_tooltip_if_necessary(key) | [
"Process keypress event"
] |
Please provide a description of the function:def _key_backspace(self, cursor_position):
if self.has_selected_text():
self.check_selection()
self.remove_selected_text()
elif self.current_prompt_pos == cursor_position:
# Avoid deleting prompt
... | [
"Action for Backspace key"
] |
Please provide a description of the function:def _key_tab(self):
if self.is_cursor_on_last_line():
empty_line = not self.get_current_line_to_cursor().strip()
if empty_line:
self.stdkey_tab()
else:
self.show_code_completion() | [
"Action for TAB key"
] |
Please provide a description of the function:def _key_question(self, text):
if self.get_current_line_to_cursor():
last_obj = self.get_last_obj()
if last_obj and not last_obj.isdigit():
self.show_object_info(last_obj)
self.insert_text(text)
... | [
"Action for '?'"
] |
Please provide a description of the function:def _key_parenleft(self, text):
self.hide_completion_widget()
if self.get_current_line_to_cursor():
last_obj = self.get_last_obj()
if last_obj and not last_obj.isdigit():
self.insert_text(text)
... | [
"Action for '('"
] |
Please provide a description of the function:def _key_period(self, text):
self.insert_text(text)
if self.codecompletion_auto:
# Enable auto-completion only if last token isn't a float
last_obj = self.get_last_obj()
if last_obj and not last_obj.isdigit()... | [
"Action for '.'"
] |
Please provide a description of the function:def paste(self):
text = to_text_string(QApplication.clipboard().text())
if len(text.splitlines()) > 1:
# Multiline paste
if self.new_input_line:
self.on_new_line()
self.remove_selected_text()... | [
"Reimplemented slot to handle multiline paste action"
] |
Please provide a description of the function:def show_completion_list(self, completions, completion_text=""):
if not completions:
return
if not isinstance(completions[0], tuple):
completions = [(c, '') for c in completions]
if len(completions) == 1 and comp... | [
"Display the possible completions"
] |
Please provide a description of the function:def show_code_completion(self):
# Note: unicode conversion is needed only for ExternalShellBase
text = to_text_string(self.get_current_line_to_cursor())
last_obj = self.get_last_obj()
if not text:
return
o... | [
"Display a completion list based on the current line"
] |
Please provide a description of the function:def drop_pathlist(self, pathlist):
if pathlist:
files = ["r'%s'" % path for path in pathlist]
if len(files) == 1:
text = files[0]
else:
text = "[" + ", ".join(files) + "]"
... | [
"Drop path list"
] |
Please provide a description of the function:def argv(self):
# Python interpreter used to start kernels
if CONF.get('main_interpreter', 'default'):
pyexec = get_python_executable()
else:
# Avoid IPython adding the virtualenv on which Spyder is running
... | [
"Command to start kernels"
] |
Please provide a description of the function:def env(self):
# Add our PYTHONPATH to the kernel
pathlist = CONF.get('main', 'spyder_pythonpath', default=[])
default_interpreter = CONF.get('main_interpreter', 'default')
pypath = add_pathlist_to_PYTHONPATH([], pathlist, ipyconsole... | [
"Env vars for kernels"
] |
Please provide a description of the function:def setup_common_actions(self):
actions = FilteredDirView.setup_common_actions(self)
# Toggle horizontal scrollbar
hscrollbar_action = create_action(self, _("Show horizontal scrollbar"),
toggle... | [
"Setup context menu common actions"
] |
Please provide a description of the function:def toggle_hscrollbar(self, checked):
self.parent_widget.sig_option_changed.emit('show_hscrollbar', checked)
self.show_hscrollbar = checked
self.header().setStretchLastSection(not checked)
self.header().setHorizontalScrollMode(QA... | [
"Toggle horizontal scrollbar"
] |
Please provide a description of the function:def dragMoveEvent(self, event):
index = self.indexAt(event.pos())
if index:
dst = self.get_filename(index)
if osp.isdir(dst):
event.acceptProposedAction()
else:
event.ignore(... | [
"Reimplement Qt method"
] |
Please provide a description of the function:def dropEvent(self, event):
event.ignore()
action = event.dropAction()
if action not in (Qt.MoveAction, Qt.CopyAction):
return
# QTreeView must not remove the source items even in MoveAction mode:
# event.... | [
"Reimplement Qt method"
] |
Please provide a description of the function:def delete(self, fnames=None):
if fnames is None:
fnames = self.get_selected_filenames()
multiple = len(fnames) > 1
yes_to_all = None
for fname in fnames:
if fname == self.proxymodel.path_list[0]:
... | [
"Delete files"
] |
Please provide a description of the function:def set_project_dir(self, directory):
if directory is not None:
self.treewidget.set_root_path(osp.dirname(directory))
self.treewidget.set_folder_names([osp.basename(directory)])
self.treewidget.setup_project_view()
... | [
"Set the project directory"
] |
Please provide a description of the function:def setup_project(self, directory):
self.emptywidget.hide()
self.treewidget.show()
# Setup the directory shown by the tree
self.set_project_dir(directory) | [
"Setup project"
] |
Please provide a description of the function:def start_interpreter(self, namespace):
self.clear()
if self.interpreter is not None:
self.interpreter.closing()
self.interpreter = Interpreter(namespace, self.exitfunc,
SysOu... | [
"Start Python interpreter"
] |
Please provide a description of the function:def exit_interpreter(self):
self.interpreter.exit_flag = True
if self.multithreaded:
self.interpreter.stdin_write.write(to_binary_string('\n'))
self.interpreter.restore_stds() | [
"Exit interpreter"
] |
Please provide a description of the function:def stdout_avail(self):
data = self.interpreter.stdout_write.empty_queue()
if data:
self.write(data) | [
"Data is available in stdout, let's empty the queue and write it!"
] |
Please provide a description of the function:def stderr_avail(self):
data = self.interpreter.stderr_write.empty_queue()
if data:
self.write(data, error=True)
self.flush(error=True) | [
"Data is available in stderr, let's empty the queue and write it!"
] |
Please provide a description of the function:def wait_input(self, prompt=''):
self.new_prompt(prompt)
self.setFocus()
self.input_mode = True
self.input_loop = QEventLoop()
self.input_loop.exec_()
self.input_loop = None | [
"Wait for input (raw_input support)"
] |
Please provide a description of the function:def end_input(self, cmd):
self.input_mode = False
self.input_loop.exit()
self.interpreter.widget_proxy.end_input(cmd) | [
"End of wait_input mode"
] |
Please provide a description of the function:def setup_context_menu(self):
PythonShellWidget.setup_context_menu(self)
self.help_action = create_action(self, _("Help..."),
icon=ima.icon('DialogHelpButton'),
triggered=self.help)
... | [
"Reimplement PythonShellWidget method"
] |
Please provide a description of the function:def help(self):
QMessageBox.about(self, _("Help"),
% (_('Shell special commands:'),
_('Internal editor:'),
_('External editor:'),
... | [
"Help on Spyder console",
"<b>%s</b>\r\n <p><i>%s</i><br> edit foobar.py\r\n <p><i>%s</i><br> xedit foobar.py\r\n <p><i>%s</i><br> run foobar.py\r\n <p><i>%s</i><br> clear x, y\r\n ... |
Please provide a description of the function:def open_with_external_spyder(self, text):
match = get_error_match(to_text_string(text))
if match:
fname, lnb = match.groups()
builtins.open_in_spyder(fname, int(lnb)) | [
"Load file in external Spyder's editor, if available\r\n This method is used only for embedded consoles\r\n (could also be useful if we ever implement the magic %edit command)"
] |
Please provide a description of the function:def external_editor(self, filename, goto=-1):
editor_path = CONF.get('internal_console', 'external_editor/path')
goto_option = CONF.get('internal_console', 'external_editor/gotoline')
try:
args = [filename]
if go... | [
"Edit in an external editor\r\n Recommended: SciTE (e.g. to go to line where an error did occur)"
] |
Please provide a description of the function:def flush(self, error=False, prompt=False):
PythonShellWidget.flush(self, error=error, prompt=prompt)
if self.interrupted:
self.interrupted = False
raise KeyboardInterrupt | [
"Reimplement ShellBaseWidget method"
] |
Please provide a description of the function:def clear_terminal(self):
self.clear()
self.new_prompt(self.interpreter.p2 if self.interpreter.more else self.interpreter.p1) | [
"Reimplement ShellBaseWidget method"
] |
Please provide a description of the function:def on_enter(self, command):
if self.profile:
# Simple profiling test
t0 = time()
for _ in range(10):
self.execute_command(command)
self.insert_text(u"\n<Δt>=%dms\n" % (1e2*(time()-t0)))
... | [
"on_enter"
] |
Please provide a description of the function:def __flush_eventqueue(self):
while self.eventqueue:
past_event = self.eventqueue.pop(0)
self.postprocess_keyevent(past_event) | [
"Flush keyboard event queue"
] |
Please provide a description of the function:def keyboard_interrupt(self):
if self.multithreaded:
self.interpreter.raise_keyboard_interrupt()
else:
if self.interpreter.more:
self.write_error("\nKeyboardInterrupt\n")
self.interpreter... | [
"Simulate keyboard interrupt"
] |
Please provide a description of the function:def execute_lines(self, lines):
for line in lines.splitlines():
stripped_line = line.strip()
if stripped_line.startswith('#'):
continue
self.write(line+os.linesep, flush=True)
self.execut... | [
"\r\n Execute a set of lines as multiple command\r\n lines: multiple lines of text to be executed as single commands\r\n "
] |
Please provide a description of the function:def execute_command(self, cmd):
if self.input_mode:
self.end_input(cmd)
return
if cmd.endswith('\n'):
cmd = cmd[:-1]
# cls command
if cmd == 'cls':
self.clear_terminal()
... | [
"\r\n Execute a command\r\n cmd: one-line command only, with '\\n' at the end\r\n "
] |
Please provide a description of the function:def run_command(self, cmd, history=True, new_prompt=True):
if not cmd:
cmd = ''
else:
if history:
self.add_to_history(cmd)
if not self.multithreaded:
if 'input' not in cmd:
... | [
"Run command in interpreter"
] |
Please provide a description of the function:def get_dir(self, objtxt):
obj, valid = self._eval(objtxt)
if valid:
return getobjdir(obj) | [
"Return dir(object)"
] |
Please provide a description of the function:def iscallable(self, objtxt):
obj, valid = self._eval(objtxt)
if valid:
return callable(obj) | [
"Is object callable?"
] |
Please provide a description of the function:def get_arglist(self, objtxt):
obj, valid = self._eval(objtxt)
if valid:
return getargtxt(obj) | [
"Get func/method argument list"
] |
Please provide a description of the function:def get_doc(self, objtxt):
obj, valid = self._eval(objtxt)
if valid:
return getdoc(obj) | [
"Get object documentation dictionary"
] |
Please provide a description of the function:def get_source(self, objtxt):
obj, valid = self._eval(objtxt)
if valid:
return getsource(obj) | [
"Get object source"
] |
Please provide a description of the function:def is_defined(self, objtxt, force_import=False):
return self.interpreter.is_defined(objtxt, force_import) | [
"Return True if object is defined"
] |
Please provide a description of the function:def paintEvent(self, event):
painter = QPainter(self)
size = self.size()
color = QColor(self.color)
color.setAlphaF(.5)
painter.setPen(color)
for column in self.columns:
x = self.editor.fontMetrics().widt... | [
"Override Qt method"
] |
Please provide a description of the function:def set_columns(self, columns):
if isinstance(columns, tuple):
self.columns = columns
elif is_text_string(columns):
self.columns = tuple(int(e) for e in columns.split(','))
self.update() | [
"Set edge line columns values."
] |
Please provide a description of the function:def send_args_to_spyder(args):
port = CONF.get('main', 'open_files_port')
# Wait ~50 secs for the server to be up
# Taken from https://stackoverflow.com/a/4766598/438386
for _x in range(200):
try:
for arg in args:
... | [
"\r\n Simple socket client used to send the args passed to the Spyder \r\n executable to an already running instance.\r\n\r\n Args can be Python scripts or files with these extensions: .spydata, .mat,\r\n .npy, or .h5, which can be imported by the Variable Explorer.\r\n "
] |
Please provide a description of the function:def main():
# Parse command line options
if running_under_pytest():
try:
from unittest.mock import Mock
except ImportError:
from mock import Mock # Python 2
options = Mock()
options.new_instance ... | [
"\r\n Start Spyder application.\r\n\r\n If single instance mode is turned on (default behavior) and an instance of\r\n Spyder is already running, this will just parse and send command line\r\n options to the application.\r\n "
] |
Please provide a description of the function:def get_search_regex(query, ignore_case=True):
regex_text = [char for char in query if char != ' ']
regex_text = '.*'.join(regex_text)
regex = r'({0})'.format(regex_text)
if ignore_case:
pattern = re.compile(regex, re.IGNORECASE)
else:
... | [
"Returns a compiled regex pattern to search for query letters in order.\n\n Parameters\n ----------\n query : str\n String to search in another string (in order of character occurrence).\n ignore_case : True\n Optional value perform a case insensitive search (True by default).\n\n Retur... |
Please provide a description of the function:def get_search_score(query, choice, ignore_case=True, apply_regex=True,
template='{}'):
original_choice = choice
result = (original_choice, NOT_FOUND_SCORE)
# Handle empty string case
if not query:
return result
if igno... | [
"Returns a tuple with the enriched text (if a template is provided) and\n a score for the match.\n\n Parameters\n ----------\n query : str\n String with letters to search in choice (in order of appearance).\n choice : str\n Sentence/words in which to search for the 'query' letters.\n ... |
Please provide a description of the function:def get_search_scores(query, choices, ignore_case=True, template='{}',
valid_only=False, sort=False):
# First remove spaces from query
query = query.replace(' ', '')
pattern = get_search_regex(query, ignore_case)
results = []
f... | [
"Search for query inside choices and return a list of tuples.\n\n Returns a list of tuples of text with the enriched text (if a template is\n provided) and a score for the match. Lower scores imply a better match.\n\n Parameters\n ----------\n query : str\n String with letters to search in eac... |
Please provide a description of the function:def is_start_of_function(text):
if isinstance(text, str) or isinstance(text, unicode):
function_prefix = ['def', 'async def']
text = text.lstrip()
for prefix in function_prefix:
if text.startswith(prefix):
... | [
"Return True if text is the beginning of the function definition."
] |
Please provide a description of the function:def get_indent(text):
indent = ''
ret = re.match(r'(\s*)', text)
if ret:
indent = ret.group(1)
return indent | [
"Get indent of text.\r\n\r\n https://stackoverflow.com/questions/2268532/grab-a-lines-whitespace-\r\n indention-with-python\r\n "
] |
Please provide a description of the function:def get_function_definition_from_first_line(self):
document = self.code_editor.document()
cursor = QTextCursor(
document.findBlockByLineNumber(self.line_number_cursor - 1))
func_text = ''
func_indent = ''
... | [
"Get func def when the cursor is located on the first def line."
] |
Please provide a description of the function:def get_function_definition_from_below_last_line(self):
cursor = self.code_editor.textCursor()
func_text = ''
is_first_line = True
line_number = cursor.blockNumber() + 1
number_of_lines_of_function = 0
for idx... | [
"Get func def when the cursor is located below the last def line."
] |
Please provide a description of the function:def get_function_body(self, func_indent):
cursor = self.code_editor.textCursor()
line_number = cursor.blockNumber() + 1
number_of_lines = self.code_editor.blockCount()
body_list = []
for idx in range(number_of_lines - ... | [
"Get the function body text."
] |
Please provide a description of the function:def write_docstring(self):
line_to_cursor = self.code_editor.get_text('sol', 'cursor')
if self.is_beginning_triple_quotes(line_to_cursor):
cursor = self.code_editor.textCursor()
prev_pos = cursor.position()
... | [
"Write docstring to editor."
] |
Please provide a description of the function:def write_docstring_at_first_line_of_function(self):
result = self.get_function_definition_from_first_line()
editor = self.code_editor
if result:
func_text, number_of_line_func = result
line_number_function = (se... | [
"Write docstring to editor at mouse position."
] |
Please provide a description of the function:def write_docstring_for_shortcut(self):
# cursor placed below function definition
result = self.get_function_definition_from_below_last_line()
if result is not None:
__, number_of_lines_of_function = result
curso... | [
"Write docstring to editor by shortcut of code editor."
] |
Please provide a description of the function:def _generate_docstring(self, doc_type, quote):
docstring = None
self.quote3 = quote * 3
if quote == '"':
self.quote3_other = "'''"
else:
self.quote3_other = '"""'
result = self.get_function... | [
"Generate docstring."
] |
Please provide a description of the function:def _generate_numpy_doc(self, func_info):
numpy_doc = ''
arg_names = func_info.arg_name_list
arg_types = func_info.arg_type_list
arg_values = func_info.arg_value_list
if len(arg_names) > 0 and arg_names[0] == 'self':... | [
"Generate a docstring of numpy type."
] |
Please provide a description of the function:def find_top_level_bracket_locations(string_toparse):
bracket_stack = []
replace_args_list = []
bracket_type = None
literal_type = ''
brackets = {'(': ')', '[': ']', '{': '}'}
for idx, character in enumerate(str... | [
"Get the locations of top-level brackets in a string."
] |
Please provide a description of the function:def parse_return_elements(return_vals_group, return_element_name,
return_element_type, placeholder):
all_eq = (return_vals_group.count(return_vals_group[0])
== len(return_vals_group))
if all([{'[li... | [
"Return the appropriate text for a group of return elements."
] |
Please provide a description of the function:def _generate_docstring_return_section(self, return_vals, header,
return_element_name,
return_element_type,
placeholder, indent):
... | [
"Generate the Returns section of a function/method docstring."
] |
Please provide a description of the function:def is_char_in_pairs(pos_char, pairs):
for pos_left, pos_right in pairs.items():
if pos_left < pos_char < pos_right:
return True
return False | [
"Return True if the charactor is in pairs of brackets or quotes."
] |
Please provide a description of the function:def _find_quote_position(text):
pos = {}
is_found_left_quote = False
for idx, character in enumerate(text):
if is_found_left_quote is False:
if character == "'" or character == '"':
is_... | [
"Return the start and end position of pairs of quotes."
] |
Please provide a description of the function:def _find_bracket_position(self, text, bracket_left, bracket_right,
pos_quote):
pos = {}
pstack = []
for idx, character in enumerate(text):
if character == bracket_left and \
... | [
"Return the start and end position of pairs of brackets.\r\n\r\n https://stackoverflow.com/questions/29991917/\r\n indices-of-matching-parentheses-in-python\r\n "
] |
Please provide a description of the function:def split_arg_to_name_type_value(self, args_list):
for arg in args_list:
arg_type = None
arg_value = None
has_type = False
has_value = False
pos_colon = arg.find(':')
pos_equ... | [
"Split argument text to name, type, value."
] |
Please provide a description of the function:def split_args_text_to_list(self, args_text):
args_list = []
idx_find_start = 0
idx_arg_start = 0
try:
pos_quote = self._find_quote_position(args_text)
pos_round = self._find_bracket_position(args_text... | [
"Split the text including multiple arguments to list.\r\n\r\n This function uses a comma to separate arguments and ignores a comma in\r\n brackets ans quotes.\r\n "
] |
Please provide a description of the function:def parse_def(self, text):
self.__init__()
if not is_start_of_function(text):
return
self.func_indent = get_indent(text)
text = text.strip()
text = text.replace('\r\n', '')
text = text.replace... | [
"Parse the function definition text."
] |
Please provide a description of the function:def parse_body(self, text):
re_raise = re.findall(r'[ \t]raise ([a-zA-Z0-9_]*)', text)
if len(re_raise) > 0:
self.raise_list = [x.strip() for x in re_raise]
# remove duplicates from list while keeping it in the order
... | [
"Parse the function body text."
] |
Please provide a description of the function:def keyPressEvent(self, event):
key = event.key()
if key not in (Qt.Key_Enter, Qt.Key_Return):
self.code_editor.keyPressEvent(event)
self.close()
else:
super(QMenuOnlyForEnter, self).keyPressEvent(ev... | [
"Close the instance if key is not enter key."
] |
Please provide a description of the function:def _is_pid_running_on_windows(pid):
pid = str(pid)
# Hide flashing command prompt
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen(r'tasklist /fi "PID eq {0}"'.format(... | [
"Check if a process is running on windows systems based on the pid."
] |
Please provide a description of the function:def _show_message(self, text):
self.splash.showMessage(text, Qt.AlignBottom | Qt.AlignCenter |
Qt.AlignAbsolute, QColor(Qt.white)) | [
"Show message on splash screen."
] |
Please provide a description of the function:def animate_ellipsis(self):
ellipsis = self.ellipsis.pop(0)
text = ' '*len(ellipsis) + self.splash_text + ellipsis
self.ellipsis.append(ellipsis)
self._show_message(text) | [
"Animate dots at the end of the splash screen message."
] |
Please provide a description of the function:def set_splash_message(self, text):
self.splash_text = text
self._show_message(text)
self.timer_ellipsis.start(500) | [
"Sets the text in the bottom of the Splash screen."
] |
Please provide a description of the function:def launch_error_message(self, error_type, error=None):
messages = {CLOSE_ERROR: _("It was not possible to close the previous "
"Spyder instance.\nRestart aborted."),
RESET_ERROR: _("Spyder could not... | [
"Launch a message box with a predefined error message.\r\n\r\n Parameters\r\n ----------\r\n error_type : int [CLOSE_ERROR, RESET_ERROR, RESTART_ERROR]\r\n Possible error codes when restarting/reseting spyder.\r\n error : Exception\r\n Actual Python exception error ... |
Please provide a description of the function:def refresh_plugin(self):
if self.tabwidget.count():
editor = self.tabwidget.currentWidget()
else:
editor = None
self.find_widget.set_editor(editor) | [
"Refresh tabwidget"
] |
Please provide a description of the function:def get_plugin_actions(self):
self.history_action = create_action(self, _("History..."),
None, ima.icon('history'),
_("Set history maximum entries"),
... | [
"Return a list of actions related to plugin"
] |
Please provide a description of the function:def register_plugin(self):
self.focus_changed.connect(self.main.plugin_focus_changed)
self.main.add_dockwidget(self)
# self.main.console.set_historylog(self)
self.main.console.shell.refresh.connect(self.refresh_plugin) | [
"Register plugin in Spyder's main window"
] |
Please provide a description of the function:def update_font(self):
color_scheme = self.get_color_scheme()
font = self.get_plugin_font()
for editor in self.editors:
editor.set_font(font, color_scheme) | [
"Update font from Preferences"
] |
Please provide a description of the function:def apply_plugin_settings(self, options):
color_scheme_n = 'color_scheme_name'
color_scheme_o = self.get_color_scheme()
font_n = 'plugin_font'
font_o = self.get_plugin_font()
wrap_n = 'wrap'
wrap_o = self.get_op... | [
"Apply configuration file's plugin settings"
] |
Please provide a description of the function:def add_history(self, filename):
filename = encoding.to_unicode_from_fs(filename)
if filename in self.filenames:
return
editor = codeeditor.CodeEditor(self)
if osp.splitext(filename)[1] == '.py':
languag... | [
"\r\n Add new history tab\r\n Slot for add_history signal emitted by shell instance\r\n "
] |
Please provide a description of the function:def toggle_wrap_mode(self, checked):
if self.tabwidget is None:
return
for editor in self.editors:
editor.toggle_wrap_mode(checked)
self.set_option('wrap', checked) | [
"Toggle wrap mode"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.