id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
30,600
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/importwizard.py
PreviewTable.process_data
def process_data(self, text, colsep=u"\t", rowsep=u"\n", transpose=False, skiprows=0, comments='#'): """Put data into table model""" data = self._shape_text(text, colsep, rowsep, transpose, skiprows, comments) self._model = PreviewTableModel(data) self.setModel(self._model)
python
def process_data(self, text, colsep=u"\t", rowsep=u"\n", transpose=False, skiprows=0, comments='#'): """Put data into table model""" data = self._shape_text(text, colsep, rowsep, transpose, skiprows, comments) self._model = PreviewTableModel(data) self.setModel(self._model)
[ "def", "process_data", "(", "self", ",", "text", ",", "colsep", "=", "u\"\\t\"", ",", "rowsep", "=", "u\"\\n\"", ",", "transpose", "=", "False", ",", "skiprows", "=", "0", ",", "comments", "=", "'#'", ")", ":", "data", "=", "self", ".", "_shape_text", ...
Put data into table model
[ "Put", "data", "into", "table", "model" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/importwizard.py#L407-L413
30,601
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/importwizard.py
PreviewTable.parse_to_type
def parse_to_type(self,**kwargs): """Parse to a given type""" indexes = self.selectedIndexes() if not indexes: return for index in indexes: self.model().parse_data_type(index, **kwargs)
python
def parse_to_type(self,**kwargs): """Parse to a given type""" indexes = self.selectedIndexes() if not indexes: return for index in indexes: self.model().parse_data_type(index, **kwargs)
[ "def", "parse_to_type", "(", "self", ",", "*", "*", "kwargs", ")", ":", "indexes", "=", "self", ".", "selectedIndexes", "(", ")", "if", "not", "indexes", ":", "return", "for", "index", "in", "indexes", ":", "self", ".", "model", "(", ")", ".", "parse...
Parse to a given type
[ "Parse", "to", "a", "given", "type" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/importwizard.py#L416-L421
30,602
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/importwizard.py
PreviewWidget.open_data
def open_data(self, text, colsep=u"\t", rowsep=u"\n", transpose=False, skiprows=0, comments='#'): """Open clipboard text as table""" if pd: self.pd_text = text self.pd_info = dict(sep=colsep, lineterminator=rowsep, skiprows=skiprows, comment=comments) if colsep is None: self.pd_info = dict(lineterminator=rowsep, skiprows=skiprows, comment=comments, delim_whitespace=True) self._table_view.process_data(text, colsep, rowsep, transpose, skiprows, comments)
python
def open_data(self, text, colsep=u"\t", rowsep=u"\n", transpose=False, skiprows=0, comments='#'): """Open clipboard text as table""" if pd: self.pd_text = text self.pd_info = dict(sep=colsep, lineterminator=rowsep, skiprows=skiprows, comment=comments) if colsep is None: self.pd_info = dict(lineterminator=rowsep, skiprows=skiprows, comment=comments, delim_whitespace=True) self._table_view.process_data(text, colsep, rowsep, transpose, skiprows, comments)
[ "def", "open_data", "(", "self", ",", "text", ",", "colsep", "=", "u\"\\t\"", ",", "rowsep", "=", "u\"\\n\"", ",", "transpose", "=", "False", ",", "skiprows", "=", "0", ",", "comments", "=", "'#'", ")", ":", "if", "pd", ":", "self", ".", "pd_text", ...
Open clipboard text as table
[ "Open", "clipboard", "text", "as", "table" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/importwizard.py#L467-L478
30,603
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/importwizard.py
ImportWizard._focus_tab
def _focus_tab(self, tab_idx): """Change tab focus""" for i in range(self.tab_widget.count()): self.tab_widget.setTabEnabled(i, False) self.tab_widget.setTabEnabled(tab_idx, True) self.tab_widget.setCurrentIndex(tab_idx)
python
def _focus_tab(self, tab_idx): """Change tab focus""" for i in range(self.tab_widget.count()): self.tab_widget.setTabEnabled(i, False) self.tab_widget.setTabEnabled(tab_idx, True) self.tab_widget.setCurrentIndex(tab_idx)
[ "def", "_focus_tab", "(", "self", ",", "tab_idx", ")", ":", "for", "i", "in", "range", "(", "self", ".", "tab_widget", ".", "count", "(", ")", ")", ":", "self", ".", "tab_widget", ".", "setTabEnabled", "(", "i", ",", "False", ")", "self", ".", "tab...
Change tab focus
[ "Change", "tab", "focus" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/importwizard.py#L558-L563
30,604
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/importwizard.py
ImportWizard._set_step
def _set_step(self, step): """Proceed to a given step""" new_tab = self.tab_widget.currentIndex() + step assert new_tab < self.tab_widget.count() and new_tab >= 0 if new_tab == self.tab_widget.count()-1: try: self.table_widget.open_data(self._get_plain_text(), self.text_widget.get_col_sep(), self.text_widget.get_row_sep(), self.text_widget.trnsp_box.isChecked(), self.text_widget.get_skiprows(), self.text_widget.get_comments()) self.done_btn.setEnabled(True) self.done_btn.setDefault(True) self.fwd_btn.setEnabled(False) self.back_btn.setEnabled(True) except (SyntaxError, AssertionError) as error: QMessageBox.critical(self, _("Import wizard"), _("<b>Unable to proceed to next step</b>" "<br><br>Please check your entries." "<br><br>Error message:<br>%s") % str(error)) return elif new_tab == 0: self.done_btn.setEnabled(False) self.fwd_btn.setEnabled(True) self.back_btn.setEnabled(False) self._focus_tab(new_tab)
python
def _set_step(self, step): """Proceed to a given step""" new_tab = self.tab_widget.currentIndex() + step assert new_tab < self.tab_widget.count() and new_tab >= 0 if new_tab == self.tab_widget.count()-1: try: self.table_widget.open_data(self._get_plain_text(), self.text_widget.get_col_sep(), self.text_widget.get_row_sep(), self.text_widget.trnsp_box.isChecked(), self.text_widget.get_skiprows(), self.text_widget.get_comments()) self.done_btn.setEnabled(True) self.done_btn.setDefault(True) self.fwd_btn.setEnabled(False) self.back_btn.setEnabled(True) except (SyntaxError, AssertionError) as error: QMessageBox.critical(self, _("Import wizard"), _("<b>Unable to proceed to next step</b>" "<br><br>Please check your entries." "<br><br>Error message:<br>%s") % str(error)) return elif new_tab == 0: self.done_btn.setEnabled(False) self.fwd_btn.setEnabled(True) self.back_btn.setEnabled(False) self._focus_tab(new_tab)
[ "def", "_set_step", "(", "self", ",", "step", ")", ":", "new_tab", "=", "self", ".", "tab_widget", ".", "currentIndex", "(", ")", "+", "step", "assert", "new_tab", "<", "self", ".", "tab_widget", ".", "count", "(", ")", "and", "new_tab", ">=", "0", "...
Proceed to a given step
[ "Proceed", "to", "a", "given", "step" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/importwizard.py#L565-L591
30,605
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/importwizard.py
ImportWizard._simplify_shape
def _simplify_shape(self, alist, rec=0): """Reduce the alist dimension if needed""" if rec != 0: if len(alist) == 1: return alist[-1] return alist if len(alist) == 1: return self._simplify_shape(alist[-1], 1) return [self._simplify_shape(al, 1) for al in alist]
python
def _simplify_shape(self, alist, rec=0): """Reduce the alist dimension if needed""" if rec != 0: if len(alist) == 1: return alist[-1] return alist if len(alist) == 1: return self._simplify_shape(alist[-1], 1) return [self._simplify_shape(al, 1) for al in alist]
[ "def", "_simplify_shape", "(", "self", ",", "alist", ",", "rec", "=", "0", ")", ":", "if", "rec", "!=", "0", ":", "if", "len", "(", "alist", ")", "==", "1", ":", "return", "alist", "[", "-", "1", "]", "return", "alist", "if", "len", "(", "alist...
Reduce the alist dimension if needed
[ "Reduce", "the", "alist", "dimension", "if", "needed" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/importwizard.py#L599-L607
30,606
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/importwizard.py
ImportWizard._get_table_data
def _get_table_data(self): """Return clipboard processed as data""" data = self._simplify_shape( self.table_widget.get_data()) if self.table_widget.array_btn.isChecked(): return array(data) elif pd and self.table_widget.df_btn.isChecked(): info = self.table_widget.pd_info buf = io.StringIO(self.table_widget.pd_text) return pd.read_csv(buf, **info) return data
python
def _get_table_data(self): """Return clipboard processed as data""" data = self._simplify_shape( self.table_widget.get_data()) if self.table_widget.array_btn.isChecked(): return array(data) elif pd and self.table_widget.df_btn.isChecked(): info = self.table_widget.pd_info buf = io.StringIO(self.table_widget.pd_text) return pd.read_csv(buf, **info) return data
[ "def", "_get_table_data", "(", "self", ")", ":", "data", "=", "self", ".", "_simplify_shape", "(", "self", ".", "table_widget", ".", "get_data", "(", ")", ")", "if", "self", ".", "table_widget", ".", "array_btn", ".", "isChecked", "(", ")", ":", "return"...
Return clipboard processed as data
[ "Return", "clipboard", "processed", "as", "data" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/importwizard.py#L609-L619
30,607
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/importwizard.py
ImportWizard.process
def process(self): """Process the data from clipboard""" var_name = self.name_edt.text() try: self.var_name = str(var_name) except UnicodeEncodeError: self.var_name = to_text_string(var_name) if self.text_widget.get_as_data(): self.clip_data = self._get_table_data() elif self.text_widget.get_as_code(): self.clip_data = try_to_eval( to_text_string(self._get_plain_text())) else: self.clip_data = to_text_string(self._get_plain_text()) self.accept()
python
def process(self): """Process the data from clipboard""" var_name = self.name_edt.text() try: self.var_name = str(var_name) except UnicodeEncodeError: self.var_name = to_text_string(var_name) if self.text_widget.get_as_data(): self.clip_data = self._get_table_data() elif self.text_widget.get_as_code(): self.clip_data = try_to_eval( to_text_string(self._get_plain_text())) else: self.clip_data = to_text_string(self._get_plain_text()) self.accept()
[ "def", "process", "(", "self", ")", ":", "var_name", "=", "self", ".", "name_edt", ".", "text", "(", ")", "try", ":", "self", ".", "var_name", "=", "str", "(", "var_name", ")", "except", "UnicodeEncodeError", ":", "self", ".", "var_name", "=", "to_text...
Process the data from clipboard
[ "Process", "the", "data", "from", "clipboard" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/importwizard.py#L626-L640
30,608
spyder-ide/spyder
spyder/plugins/ipythonconsole/widgets/debugging.py
DebuggingWidget.set_spyder_breakpoints
def set_spyder_breakpoints(self, force=False): """Set Spyder breakpoints into a debugging session""" if self._reading or force: breakpoints_dict = CONF.get('run', 'breakpoints', {}) # We need to enclose pickled values in a list to be able to # send them to the kernel in Python 2 serialiazed_breakpoints = [pickle.dumps(breakpoints_dict, protocol=PICKLE_PROTOCOL)] breakpoints = to_text_string(serialiazed_breakpoints) cmd = u"!get_ipython().kernel._set_spyder_breakpoints({})" self.kernel_client.input(cmd.format(breakpoints))
python
def set_spyder_breakpoints(self, force=False): """Set Spyder breakpoints into a debugging session""" if self._reading or force: breakpoints_dict = CONF.get('run', 'breakpoints', {}) # We need to enclose pickled values in a list to be able to # send them to the kernel in Python 2 serialiazed_breakpoints = [pickle.dumps(breakpoints_dict, protocol=PICKLE_PROTOCOL)] breakpoints = to_text_string(serialiazed_breakpoints) cmd = u"!get_ipython().kernel._set_spyder_breakpoints({})" self.kernel_client.input(cmd.format(breakpoints))
[ "def", "set_spyder_breakpoints", "(", "self", ",", "force", "=", "False", ")", ":", "if", "self", ".", "_reading", "or", "force", ":", "breakpoints_dict", "=", "CONF", ".", "get", "(", "'run'", ",", "'breakpoints'", ",", "{", "}", ")", "# We need to enclos...
Set Spyder breakpoints into a debugging session
[ "Set", "Spyder", "breakpoints", "into", "a", "debugging", "session" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/debugging.py#L36-L48
30,609
spyder-ide/spyder
spyder/plugins/ipythonconsole/widgets/debugging.py
DebuggingWidget.dbg_exec_magic
def dbg_exec_magic(self, magic, args=''): """Run an IPython magic while debugging.""" code = "!get_ipython().kernel.shell.run_line_magic('{}', '{}')".format( magic, args) self.kernel_client.input(code)
python
def dbg_exec_magic(self, magic, args=''): """Run an IPython magic while debugging.""" code = "!get_ipython().kernel.shell.run_line_magic('{}', '{}')".format( magic, args) self.kernel_client.input(code)
[ "def", "dbg_exec_magic", "(", "self", ",", "magic", ",", "args", "=", "''", ")", ":", "code", "=", "\"!get_ipython().kernel.shell.run_line_magic('{}', '{}')\"", ".", "format", "(", "magic", ",", "args", ")", "self", ".", "kernel_client", ".", "input", "(", "co...
Run an IPython magic while debugging.
[ "Run", "an", "IPython", "magic", "while", "debugging", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/debugging.py#L50-L54
30,610
spyder-ide/spyder
spyder/plugins/ipythonconsole/widgets/debugging.py
DebuggingWidget.refresh_from_pdb
def refresh_from_pdb(self, pdb_state): """ Refresh Variable Explorer and Editor from a Pdb session, after running any pdb command. See publish_pdb_state and notify_spyder in spyder_kernels """ if 'step' in pdb_state and 'fname' in pdb_state['step']: fname = pdb_state['step']['fname'] lineno = pdb_state['step']['lineno'] self.sig_pdb_step.emit(fname, lineno) if 'namespace_view' in pdb_state: self.sig_namespace_view.emit(ast.literal_eval( pdb_state['namespace_view'])) if 'var_properties' in pdb_state: self.sig_var_properties.emit(ast.literal_eval( pdb_state['var_properties']))
python
def refresh_from_pdb(self, pdb_state): """ Refresh Variable Explorer and Editor from a Pdb session, after running any pdb command. See publish_pdb_state and notify_spyder in spyder_kernels """ if 'step' in pdb_state and 'fname' in pdb_state['step']: fname = pdb_state['step']['fname'] lineno = pdb_state['step']['lineno'] self.sig_pdb_step.emit(fname, lineno) if 'namespace_view' in pdb_state: self.sig_namespace_view.emit(ast.literal_eval( pdb_state['namespace_view'])) if 'var_properties' in pdb_state: self.sig_var_properties.emit(ast.literal_eval( pdb_state['var_properties']))
[ "def", "refresh_from_pdb", "(", "self", ",", "pdb_state", ")", ":", "if", "'step'", "in", "pdb_state", "and", "'fname'", "in", "pdb_state", "[", "'step'", "]", ":", "fname", "=", "pdb_state", "[", "'step'", "]", "[", "'fname'", "]", "lineno", "=", "pdb_s...
Refresh Variable Explorer and Editor from a Pdb session, after running any pdb command. See publish_pdb_state and notify_spyder in spyder_kernels
[ "Refresh", "Variable", "Explorer", "and", "Editor", "from", "a", "Pdb", "session", "after", "running", "any", "pdb", "command", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/debugging.py#L56-L74
30,611
spyder-ide/spyder
spyder/plugins/ipythonconsole/widgets/debugging.py
DebuggingWidget._handle_input_request
def _handle_input_request(self, msg): """Save history and add a %plot magic.""" if self._hidden: raise RuntimeError('Request for raw input during hidden execution.') # Make sure that all output from the SUB channel has been processed # before entering readline mode. self.kernel_client.iopub_channel.flush() def callback(line): # Save history to browse it later if not (len(self._control.history) > 0 and self._control.history[-1] == line): # do not save pdb commands cmd = line.split(" ")[0] if "do_" + cmd not in dir(pdb.Pdb): self._control.history.append(line) # This is the Spyder addition: add a %plot magic to display # plots while debugging if line.startswith('%plot '): line = line.split()[-1] code = "__spy_code__ = get_ipython().run_cell('%s')" % line self.kernel_client.input(code) else: self.kernel_client.input(line) if self._reading: self._reading = False self._readline(msg['content']['prompt'], callback=callback, password=msg['content']['password'])
python
def _handle_input_request(self, msg): """Save history and add a %plot magic.""" if self._hidden: raise RuntimeError('Request for raw input during hidden execution.') # Make sure that all output from the SUB channel has been processed # before entering readline mode. self.kernel_client.iopub_channel.flush() def callback(line): # Save history to browse it later if not (len(self._control.history) > 0 and self._control.history[-1] == line): # do not save pdb commands cmd = line.split(" ")[0] if "do_" + cmd not in dir(pdb.Pdb): self._control.history.append(line) # This is the Spyder addition: add a %plot magic to display # plots while debugging if line.startswith('%plot '): line = line.split()[-1] code = "__spy_code__ = get_ipython().run_cell('%s')" % line self.kernel_client.input(code) else: self.kernel_client.input(line) if self._reading: self._reading = False self._readline(msg['content']['prompt'], callback=callback, password=msg['content']['password'])
[ "def", "_handle_input_request", "(", "self", ",", "msg", ")", ":", "if", "self", ".", "_hidden", ":", "raise", "RuntimeError", "(", "'Request for raw input during hidden execution.'", ")", "# Make sure that all output from the SUB channel has been processed", "# before entering...
Save history and add a %plot magic.
[ "Save", "history", "and", "add", "a", "%plot", "magic", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/debugging.py#L77-L106
30,612
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
global_max
def global_max(col_vals, index): """Returns the global maximum and minimum.""" col_vals_without_None = [x for x in col_vals if x is not None] max_col, min_col = zip(*col_vals_without_None) return max(max_col), min(min_col)
python
def global_max(col_vals, index): """Returns the global maximum and minimum.""" col_vals_without_None = [x for x in col_vals if x is not None] max_col, min_col = zip(*col_vals_without_None) return max(max_col), min(min_col)
[ "def", "global_max", "(", "col_vals", ",", "index", ")", ":", "col_vals_without_None", "=", "[", "x", "for", "x", "in", "col_vals", "if", "x", "is", "not", "None", "]", "max_col", ",", "min_col", "=", "zip", "(", "*", "col_vals_without_None", ")", "retur...
Returns the global maximum and minimum.
[ "Returns", "the", "global", "maximum", "and", "minimum", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L105-L109
30,613
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameModel.header
def header(self, axis, x, level=0): """ Return the values of the labels for the header of columns or rows. The value corresponds to the header of column or row x in the given level. """ ax = self._axis(axis) return ax.values[x] if not hasattr(ax, 'levels') \ else ax.values[x][level]
python
def header(self, axis, x, level=0): """ Return the values of the labels for the header of columns or rows. The value corresponds to the header of column or row x in the given level. """ ax = self._axis(axis) return ax.values[x] if not hasattr(ax, 'levels') \ else ax.values[x][level]
[ "def", "header", "(", "self", ",", "axis", ",", "x", ",", "level", "=", "0", ")", ":", "ax", "=", "self", ".", "_axis", "(", "axis", ")", "return", "ax", ".", "values", "[", "x", "]", "if", "not", "hasattr", "(", "ax", ",", "'levels'", ")", "...
Return the values of the labels for the header of columns or rows. The value corresponds to the header of column or row x in the given level.
[ "Return", "the", "values", "of", "the", "labels", "for", "the", "header", "of", "columns", "or", "rows", ".", "The", "value", "corresponds", "to", "the", "header", "of", "column", "or", "row", "x", "in", "the", "given", "level", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L194-L203
30,614
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameModel.get_bgcolor
def get_bgcolor(self, index): """Background color depending on value.""" column = index.column() if not self.bgcolor_enabled: return value = self.get_value(index.row(), column) if self.max_min_col[column] is None or isna(value): color = QColor(BACKGROUND_NONNUMBER_COLOR) if is_text_string(value): color.setAlphaF(BACKGROUND_STRING_ALPHA) else: color.setAlphaF(BACKGROUND_MISC_ALPHA) else: if isinstance(value, COMPLEX_NUMBER_TYPES): color_func = abs else: color_func = float vmax, vmin = self.return_max(self.max_min_col, column) hue = (BACKGROUND_NUMBER_MINHUE + BACKGROUND_NUMBER_HUERANGE * (vmax - color_func(value)) / (vmax - vmin)) hue = float(abs(hue)) if hue > 1: hue = 1 color = QColor.fromHsvF(hue, BACKGROUND_NUMBER_SATURATION, BACKGROUND_NUMBER_VALUE, BACKGROUND_NUMBER_ALPHA) return color
python
def get_bgcolor(self, index): """Background color depending on value.""" column = index.column() if not self.bgcolor_enabled: return value = self.get_value(index.row(), column) if self.max_min_col[column] is None or isna(value): color = QColor(BACKGROUND_NONNUMBER_COLOR) if is_text_string(value): color.setAlphaF(BACKGROUND_STRING_ALPHA) else: color.setAlphaF(BACKGROUND_MISC_ALPHA) else: if isinstance(value, COMPLEX_NUMBER_TYPES): color_func = abs else: color_func = float vmax, vmin = self.return_max(self.max_min_col, column) hue = (BACKGROUND_NUMBER_MINHUE + BACKGROUND_NUMBER_HUERANGE * (vmax - color_func(value)) / (vmax - vmin)) hue = float(abs(hue)) if hue > 1: hue = 1 color = QColor.fromHsvF(hue, BACKGROUND_NUMBER_SATURATION, BACKGROUND_NUMBER_VALUE, BACKGROUND_NUMBER_ALPHA) return color
[ "def", "get_bgcolor", "(", "self", ",", "index", ")", ":", "column", "=", "index", ".", "column", "(", ")", "if", "not", "self", ".", "bgcolor_enabled", ":", "return", "value", "=", "self", ".", "get_value", "(", "index", ".", "row", "(", ")", ",", ...
Background color depending on value.
[ "Background", "color", "depending", "on", "value", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L269-L295
30,615
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameModel.get_value
def get_value(self, row, column): """Return the value of the DataFrame.""" # To increase the performance iat is used but that requires error # handling, so fallback uses iloc try: value = self.df.iat[row, column] except OutOfBoundsDatetime: value = self.df.iloc[:, column].astype(str).iat[row] except: value = self.df.iloc[row, column] return value
python
def get_value(self, row, column): """Return the value of the DataFrame.""" # To increase the performance iat is used but that requires error # handling, so fallback uses iloc try: value = self.df.iat[row, column] except OutOfBoundsDatetime: value = self.df.iloc[:, column].astype(str).iat[row] except: value = self.df.iloc[row, column] return value
[ "def", "get_value", "(", "self", ",", "row", ",", "column", ")", ":", "# To increase the performance iat is used but that requires error\r", "# handling, so fallback uses iloc\r", "try", ":", "value", "=", "self", ".", "df", ".", "iat", "[", "row", ",", "column", "]...
Return the value of the DataFrame.
[ "Return", "the", "value", "of", "the", "DataFrame", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L297-L307
30,616
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameView.load_more_data
def load_more_data(self, value, rows=False, columns=False): """Load more rows and columns to display.""" try: if rows and value == self.verticalScrollBar().maximum(): self.model().fetch_more(rows=rows) self.sig_fetch_more_rows.emit() if columns and value == self.horizontalScrollBar().maximum(): self.model().fetch_more(columns=columns) self.sig_fetch_more_columns.emit() except NameError: # Needed to handle a NameError while fetching data when closing # See issue 7880 pass
python
def load_more_data(self, value, rows=False, columns=False): """Load more rows and columns to display.""" try: if rows and value == self.verticalScrollBar().maximum(): self.model().fetch_more(rows=rows) self.sig_fetch_more_rows.emit() if columns and value == self.horizontalScrollBar().maximum(): self.model().fetch_more(columns=columns) self.sig_fetch_more_columns.emit() except NameError: # Needed to handle a NameError while fetching data when closing # See issue 7880 pass
[ "def", "load_more_data", "(", "self", ",", "value", ",", "rows", "=", "False", ",", "columns", "=", "False", ")", ":", "try", ":", "if", "rows", "and", "value", "==", "self", ".", "verticalScrollBar", "(", ")", ".", "maximum", "(", ")", ":", "self", ...
Load more rows and columns to display.
[ "Load", "more", "rows", "and", "columns", "to", "display", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L524-L537
30,617
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameView.sortByColumn
def sortByColumn(self, index): """Implement a column sort.""" if self.sort_old == [None]: self.header_class.setSortIndicatorShown(True) sort_order = self.header_class.sortIndicatorOrder() self.sig_sort_by_column.emit() if not self.model().sort(index, sort_order): if len(self.sort_old) != 2: self.header_class.setSortIndicatorShown(False) else: self.header_class.setSortIndicator(self.sort_old[0], self.sort_old[1]) return self.sort_old = [index, self.header_class.sortIndicatorOrder()]
python
def sortByColumn(self, index): """Implement a column sort.""" if self.sort_old == [None]: self.header_class.setSortIndicatorShown(True) sort_order = self.header_class.sortIndicatorOrder() self.sig_sort_by_column.emit() if not self.model().sort(index, sort_order): if len(self.sort_old) != 2: self.header_class.setSortIndicatorShown(False) else: self.header_class.setSortIndicator(self.sort_old[0], self.sort_old[1]) return self.sort_old = [index, self.header_class.sortIndicatorOrder()]
[ "def", "sortByColumn", "(", "self", ",", "index", ")", ":", "if", "self", ".", "sort_old", "==", "[", "None", "]", ":", "self", ".", "header_class", ".", "setSortIndicatorShown", "(", "True", ")", "sort_order", "=", "self", ".", "header_class", ".", "sor...
Implement a column sort.
[ "Implement", "a", "column", "sort", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L539-L552
30,618
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameView.setup_menu
def setup_menu(self): """Setup context menu.""" copy_action = create_action(self, _('Copy'), shortcut=keybinding('Copy'), icon=ima.icon('editcopy'), triggered=self.copy, context=Qt.WidgetShortcut) functions = ((_("To bool"), bool), (_("To complex"), complex), (_("To int"), int), (_("To float"), float), (_("To str"), to_text_string)) types_in_menu = [copy_action] for name, func in functions: slot = lambda func=func: self.change_type(func) types_in_menu += [create_action(self, name, triggered=slot, context=Qt.WidgetShortcut)] menu = QMenu(self) add_actions(menu, types_in_menu) return menu
python
def setup_menu(self): """Setup context menu.""" copy_action = create_action(self, _('Copy'), shortcut=keybinding('Copy'), icon=ima.icon('editcopy'), triggered=self.copy, context=Qt.WidgetShortcut) functions = ((_("To bool"), bool), (_("To complex"), complex), (_("To int"), int), (_("To float"), float), (_("To str"), to_text_string)) types_in_menu = [copy_action] for name, func in functions: slot = lambda func=func: self.change_type(func) types_in_menu += [create_action(self, name, triggered=slot, context=Qt.WidgetShortcut)] menu = QMenu(self) add_actions(menu, types_in_menu) return menu
[ "def", "setup_menu", "(", "self", ")", ":", "copy_action", "=", "create_action", "(", "self", ",", "_", "(", "'Copy'", ")", ",", "shortcut", "=", "keybinding", "(", "'Copy'", ")", ",", "icon", "=", "ima", ".", "icon", "(", "'editcopy'", ")", ",", "tr...
Setup context menu.
[ "Setup", "context", "menu", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L559-L577
30,619
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameView.change_type
def change_type(self, func): """A function that changes types of cells.""" model = self.model() index_list = self.selectedIndexes() [model.setData(i, '', change_type=func) for i in index_list]
python
def change_type(self, func): """A function that changes types of cells.""" model = self.model() index_list = self.selectedIndexes() [model.setData(i, '', change_type=func) for i in index_list]
[ "def", "change_type", "(", "self", ",", "func", ")", ":", "model", "=", "self", ".", "model", "(", ")", "index_list", "=", "self", ".", "selectedIndexes", "(", ")", "[", "model", ".", "setData", "(", "i", ",", "''", ",", "change_type", "=", "func", ...
A function that changes types of cells.
[ "A", "function", "that", "changes", "types", "of", "cells", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L579-L583
30,620
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameHeaderModel.rowCount
def rowCount(self, index=None): """Get number of rows in the header.""" if self.axis == 0: return max(1, self._shape[0]) else: if self.total_rows <= self.rows_loaded: return self.total_rows else: return self.rows_loaded
python
def rowCount(self, index=None): """Get number of rows in the header.""" if self.axis == 0: return max(1, self._shape[0]) else: if self.total_rows <= self.rows_loaded: return self.total_rows else: return self.rows_loaded
[ "def", "rowCount", "(", "self", ",", "index", "=", "None", ")", ":", "if", "self", ".", "axis", "==", "0", ":", "return", "max", "(", "1", ",", "self", ".", "_shape", "[", "0", "]", ")", "else", ":", "if", "self", ".", "total_rows", "<=", "self...
Get number of rows in the header.
[ "Get", "number", "of", "rows", "in", "the", "header", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L645-L653
30,621
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameHeaderModel.sort
def sort(self, column, order=Qt.AscendingOrder): """Overriding sort method.""" ascending = order == Qt.AscendingOrder self.model.sort(self.COLUMN_INDEX, order=ascending) return True
python
def sort(self, column, order=Qt.AscendingOrder): """Overriding sort method.""" ascending = order == Qt.AscendingOrder self.model.sort(self.COLUMN_INDEX, order=ascending) return True
[ "def", "sort", "(", "self", ",", "column", ",", "order", "=", "Qt", ".", "AscendingOrder", ")", ":", "ascending", "=", "order", "==", "Qt", ".", "AscendingOrder", "self", ".", "model", ".", "sort", "(", "self", ".", "COLUMN_INDEX", ",", "order", "=", ...
Overriding sort method.
[ "Overriding", "sort", "method", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L682-L686
30,622
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameHeaderModel.headerData
def headerData(self, section, orientation, role): """Get the information to put in the header.""" if role == Qt.TextAlignmentRole: if orientation == Qt.Horizontal: return Qt.AlignCenter | Qt.AlignBottom else: return Qt.AlignRight | Qt.AlignVCenter if role != Qt.DisplayRole and role != Qt.ToolTipRole: return None if self.axis == 1 and self._shape[1] <= 1: return None orient_axis = 0 if orientation == Qt.Horizontal else 1 if self.model.header_shape[orient_axis] > 1: header = section else: header = self.model.header(self.axis, section) # Don't perform any conversion on strings # because it leads to differences between # the data present in the dataframe and # what is shown by Spyder if not is_type_text_string(header): header = to_text_string(header) return header
python
def headerData(self, section, orientation, role): """Get the information to put in the header.""" if role == Qt.TextAlignmentRole: if orientation == Qt.Horizontal: return Qt.AlignCenter | Qt.AlignBottom else: return Qt.AlignRight | Qt.AlignVCenter if role != Qt.DisplayRole and role != Qt.ToolTipRole: return None if self.axis == 1 and self._shape[1] <= 1: return None orient_axis = 0 if orientation == Qt.Horizontal else 1 if self.model.header_shape[orient_axis] > 1: header = section else: header = self.model.header(self.axis, section) # Don't perform any conversion on strings # because it leads to differences between # the data present in the dataframe and # what is shown by Spyder if not is_type_text_string(header): header = to_text_string(header) return header
[ "def", "headerData", "(", "self", ",", "section", ",", "orientation", ",", "role", ")", ":", "if", "role", "==", "Qt", ".", "TextAlignmentRole", ":", "if", "orientation", "==", "Qt", ".", "Horizontal", ":", "return", "Qt", ".", "AlignCenter", "|", "Qt", ...
Get the information to put in the header.
[ "Get", "the", "information", "to", "put", "in", "the", "header", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L688-L712
30,623
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameHeaderModel.data
def data(self, index, role): """ Get the data for the header. This is used when a header has levels. """ if not index.isValid() or \ index.row() >= self._shape[0] or \ index.column() >= self._shape[1]: return None row, col = ((index.row(), index.column()) if self.axis == 0 else (index.column(), index.row())) if role != Qt.DisplayRole: return None if self.axis == 0 and self._shape[0] <= 1: return None header = self.model.header(self.axis, col, row) # Don't perform any conversion on strings # because it leads to differences between # the data present in the dataframe and # what is shown by Spyder if not is_type_text_string(header): header = to_text_string(header) return header
python
def data(self, index, role): """ Get the data for the header. This is used when a header has levels. """ if not index.isValid() or \ index.row() >= self._shape[0] or \ index.column() >= self._shape[1]: return None row, col = ((index.row(), index.column()) if self.axis == 0 else (index.column(), index.row())) if role != Qt.DisplayRole: return None if self.axis == 0 and self._shape[0] <= 1: return None header = self.model.header(self.axis, col, row) # Don't perform any conversion on strings # because it leads to differences between # the data present in the dataframe and # what is shown by Spyder if not is_type_text_string(header): header = to_text_string(header) return header
[ "def", "data", "(", "self", ",", "index", ",", "role", ")", ":", "if", "not", "index", ".", "isValid", "(", ")", "or", "index", ".", "row", "(", ")", ">=", "self", ".", "_shape", "[", "0", "]", "or", "index", ".", "column", "(", ")", ">=", "s...
Get the data for the header. This is used when a header has levels.
[ "Get", "the", "data", "for", "the", "header", ".", "This", "is", "used", "when", "a", "header", "has", "levels", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L714-L740
30,624
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameLevelModel.headerData
def headerData(self, section, orientation, role): """ Get the text to put in the header of the levels of the indexes. By default it returns 'Index i', where i is the section in the index """ if role == Qt.TextAlignmentRole: if orientation == Qt.Horizontal: return Qt.AlignCenter | Qt.AlignBottom else: return Qt.AlignRight | Qt.AlignVCenter if role != Qt.DisplayRole and role != Qt.ToolTipRole: return None if self.model.header_shape[0] <= 1 and orientation == Qt.Horizontal: if self.model.name(1,section): return self.model.name(1,section) return _('Index') elif self.model.header_shape[0] <= 1: return None elif self.model.header_shape[1] <= 1 and orientation == Qt.Vertical: return None return _('Index') + ' ' + to_text_string(section)
python
def headerData(self, section, orientation, role): """ Get the text to put in the header of the levels of the indexes. By default it returns 'Index i', where i is the section in the index """ if role == Qt.TextAlignmentRole: if orientation == Qt.Horizontal: return Qt.AlignCenter | Qt.AlignBottom else: return Qt.AlignRight | Qt.AlignVCenter if role != Qt.DisplayRole and role != Qt.ToolTipRole: return None if self.model.header_shape[0] <= 1 and orientation == Qt.Horizontal: if self.model.name(1,section): return self.model.name(1,section) return _('Index') elif self.model.header_shape[0] <= 1: return None elif self.model.header_shape[1] <= 1 and orientation == Qt.Vertical: return None return _('Index') + ' ' + to_text_string(section)
[ "def", "headerData", "(", "self", ",", "section", ",", "orientation", ",", "role", ")", ":", "if", "role", "==", "Qt", ".", "TextAlignmentRole", ":", "if", "orientation", "==", "Qt", ".", "Horizontal", ":", "return", "Qt", ".", "AlignCenter", "|", "Qt", ...
Get the text to put in the header of the levels of the indexes. By default it returns 'Index i', where i is the section in the index
[ "Get", "the", "text", "to", "put", "in", "the", "header", "of", "the", "levels", "of", "the", "indexes", ".", "By", "default", "it", "returns", "Index", "i", "where", "i", "is", "the", "section", "in", "the", "index" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L776-L797
30,625
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameLevelModel.data
def data(self, index, role): """Get the information of the levels.""" if not index.isValid(): return None if role == Qt.FontRole: return self._font label = '' if index.column() == self.model.header_shape[1] - 1: label = str(self.model.name(0, index.row())) elif index.row() == self.model.header_shape[0] - 1: label = str(self.model.name(1, index.column())) if role == Qt.DisplayRole and label: return label elif role == Qt.ForegroundRole: return self._foreground elif role == Qt.BackgroundRole: return self._background elif role == Qt.BackgroundRole: return self._palette.window() return None
python
def data(self, index, role): """Get the information of the levels.""" if not index.isValid(): return None if role == Qt.FontRole: return self._font label = '' if index.column() == self.model.header_shape[1] - 1: label = str(self.model.name(0, index.row())) elif index.row() == self.model.header_shape[0] - 1: label = str(self.model.name(1, index.column())) if role == Qt.DisplayRole and label: return label elif role == Qt.ForegroundRole: return self._foreground elif role == Qt.BackgroundRole: return self._background elif role == Qt.BackgroundRole: return self._palette.window() return None
[ "def", "data", "(", "self", ",", "index", ",", "role", ")", ":", "if", "not", "index", ".", "isValid", "(", ")", ":", "return", "None", "if", "role", "==", "Qt", ".", "FontRole", ":", "return", "self", ".", "_font", "label", "=", "''", "if", "ind...
Get the information of the levels.
[ "Get", "the", "information", "of", "the", "levels", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L799-L818
30,626
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor.create_table_level
def create_table_level(self): """Create the QTableView that will hold the level model.""" self.table_level = QTableView() self.table_level.setEditTriggers(QTableWidget.NoEditTriggers) self.table_level.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_level.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_level.setFrameStyle(QFrame.Plain) self.table_level.horizontalHeader().sectionResized.connect( self._index_resized) self.table_level.verticalHeader().sectionResized.connect( self._header_resized) self.table_level.setItemDelegate(QItemDelegate()) self.layout.addWidget(self.table_level, 0, 0) self.table_level.setContentsMargins(0, 0, 0, 0) self.table_level.horizontalHeader().sectionClicked.connect( self.sortByIndex)
python
def create_table_level(self): """Create the QTableView that will hold the level model.""" self.table_level = QTableView() self.table_level.setEditTriggers(QTableWidget.NoEditTriggers) self.table_level.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_level.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_level.setFrameStyle(QFrame.Plain) self.table_level.horizontalHeader().sectionResized.connect( self._index_resized) self.table_level.verticalHeader().sectionResized.connect( self._header_resized) self.table_level.setItemDelegate(QItemDelegate()) self.layout.addWidget(self.table_level, 0, 0) self.table_level.setContentsMargins(0, 0, 0, 0) self.table_level.horizontalHeader().sectionClicked.connect( self.sortByIndex)
[ "def", "create_table_level", "(", "self", ")", ":", "self", ".", "table_level", "=", "QTableView", "(", ")", "self", ".", "table_level", ".", "setEditTriggers", "(", "QTableWidget", ".", "NoEditTriggers", ")", "self", ".", "table_level", ".", "setHorizontalScrol...
Create the QTableView that will hold the level model.
[ "Create", "the", "QTableView", "that", "will", "hold", "the", "level", "model", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L956-L971
30,627
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor.create_table_header
def create_table_header(self): """Create the QTableView that will hold the header model.""" self.table_header = QTableView() self.table_header.verticalHeader().hide() self.table_header.setEditTriggers(QTableWidget.NoEditTriggers) self.table_header.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_header.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_header.setHorizontalScrollMode(QTableView.ScrollPerPixel) self.table_header.setHorizontalScrollBar(self.hscroll) self.table_header.setFrameStyle(QFrame.Plain) self.table_header.horizontalHeader().sectionResized.connect( self._column_resized) self.table_header.setItemDelegate(QItemDelegate()) self.layout.addWidget(self.table_header, 0, 1)
python
def create_table_header(self): """Create the QTableView that will hold the header model.""" self.table_header = QTableView() self.table_header.verticalHeader().hide() self.table_header.setEditTriggers(QTableWidget.NoEditTriggers) self.table_header.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_header.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_header.setHorizontalScrollMode(QTableView.ScrollPerPixel) self.table_header.setHorizontalScrollBar(self.hscroll) self.table_header.setFrameStyle(QFrame.Plain) self.table_header.horizontalHeader().sectionResized.connect( self._column_resized) self.table_header.setItemDelegate(QItemDelegate()) self.layout.addWidget(self.table_header, 0, 1)
[ "def", "create_table_header", "(", "self", ")", ":", "self", ".", "table_header", "=", "QTableView", "(", ")", "self", ".", "table_header", ".", "verticalHeader", "(", ")", ".", "hide", "(", ")", "self", ".", "table_header", ".", "setEditTriggers", "(", "Q...
Create the QTableView that will hold the header model.
[ "Create", "the", "QTableView", "that", "will", "hold", "the", "header", "model", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L973-L986
30,628
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor.create_table_index
def create_table_index(self): """Create the QTableView that will hold the index model.""" self.table_index = QTableView() self.table_index.horizontalHeader().hide() self.table_index.setEditTriggers(QTableWidget.NoEditTriggers) self.table_index.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_index.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_index.setVerticalScrollMode(QTableView.ScrollPerPixel) self.table_index.setVerticalScrollBar(self.vscroll) self.table_index.setFrameStyle(QFrame.Plain) self.table_index.verticalHeader().sectionResized.connect( self._row_resized) self.table_index.setItemDelegate(QItemDelegate()) self.layout.addWidget(self.table_index, 1, 0) self.table_index.setContentsMargins(0, 0, 0, 0)
python
def create_table_index(self): """Create the QTableView that will hold the index model.""" self.table_index = QTableView() self.table_index.horizontalHeader().hide() self.table_index.setEditTriggers(QTableWidget.NoEditTriggers) self.table_index.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_index.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.table_index.setVerticalScrollMode(QTableView.ScrollPerPixel) self.table_index.setVerticalScrollBar(self.vscroll) self.table_index.setFrameStyle(QFrame.Plain) self.table_index.verticalHeader().sectionResized.connect( self._row_resized) self.table_index.setItemDelegate(QItemDelegate()) self.layout.addWidget(self.table_index, 1, 0) self.table_index.setContentsMargins(0, 0, 0, 0)
[ "def", "create_table_index", "(", "self", ")", ":", "self", ".", "table_index", "=", "QTableView", "(", ")", "self", ".", "table_index", ".", "horizontalHeader", "(", ")", ".", "hide", "(", ")", "self", ".", "table_index", ".", "setEditTriggers", "(", "QTa...
Create the QTableView that will hold the index model.
[ "Create", "the", "QTableView", "that", "will", "hold", "the", "index", "model", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L988-L1002
30,629
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor.create_data_table
def create_data_table(self): """Create the QTableView that will hold the data model.""" self.dataTable = DataFrameView(self, self.dataModel, self.table_header.horizontalHeader(), self.hscroll, self.vscroll) self.dataTable.verticalHeader().hide() self.dataTable.horizontalHeader().hide() self.dataTable.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.dataTable.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.dataTable.setHorizontalScrollMode(QTableView.ScrollPerPixel) self.dataTable.setVerticalScrollMode(QTableView.ScrollPerPixel) self.dataTable.setFrameStyle(QFrame.Plain) self.dataTable.setItemDelegate(QItemDelegate()) self.layout.addWidget(self.dataTable, 1, 1) self.setFocusProxy(self.dataTable) self.dataTable.sig_sort_by_column.connect(self._sort_update) self.dataTable.sig_fetch_more_columns.connect(self._fetch_more_columns) self.dataTable.sig_fetch_more_rows.connect(self._fetch_more_rows)
python
def create_data_table(self): """Create the QTableView that will hold the data model.""" self.dataTable = DataFrameView(self, self.dataModel, self.table_header.horizontalHeader(), self.hscroll, self.vscroll) self.dataTable.verticalHeader().hide() self.dataTable.horizontalHeader().hide() self.dataTable.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.dataTable.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.dataTable.setHorizontalScrollMode(QTableView.ScrollPerPixel) self.dataTable.setVerticalScrollMode(QTableView.ScrollPerPixel) self.dataTable.setFrameStyle(QFrame.Plain) self.dataTable.setItemDelegate(QItemDelegate()) self.layout.addWidget(self.dataTable, 1, 1) self.setFocusProxy(self.dataTable) self.dataTable.sig_sort_by_column.connect(self._sort_update) self.dataTable.sig_fetch_more_columns.connect(self._fetch_more_columns) self.dataTable.sig_fetch_more_rows.connect(self._fetch_more_rows)
[ "def", "create_data_table", "(", "self", ")", ":", "self", ".", "dataTable", "=", "DataFrameView", "(", "self", ",", "self", ".", "dataModel", ",", "self", ".", "table_header", ".", "horizontalHeader", "(", ")", ",", "self", ".", "hscroll", ",", "self", ...
Create the QTableView that will hold the data model.
[ "Create", "the", "QTableView", "that", "will", "hold", "the", "data", "model", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1004-L1021
30,630
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor.sortByIndex
def sortByIndex(self, index): """Implement a Index sort.""" self.table_level.horizontalHeader().setSortIndicatorShown(True) sort_order = self.table_level.horizontalHeader().sortIndicatorOrder() self.table_index.model().sort(index, sort_order) self._sort_update()
python
def sortByIndex(self, index): """Implement a Index sort.""" self.table_level.horizontalHeader().setSortIndicatorShown(True) sort_order = self.table_level.horizontalHeader().sortIndicatorOrder() self.table_index.model().sort(index, sort_order) self._sort_update()
[ "def", "sortByIndex", "(", "self", ",", "index", ")", ":", "self", ".", "table_level", ".", "horizontalHeader", "(", ")", ".", "setSortIndicatorShown", "(", "True", ")", "sort_order", "=", "self", ".", "table_level", ".", "horizontalHeader", "(", ")", ".", ...
Implement a Index sort.
[ "Implement", "a", "Index", "sort", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1023-L1028
30,631
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor._column_resized
def _column_resized(self, col, old_width, new_width): """Update the column width.""" self.dataTable.setColumnWidth(col, new_width) self._update_layout()
python
def _column_resized(self, col, old_width, new_width): """Update the column width.""" self.dataTable.setColumnWidth(col, new_width) self._update_layout()
[ "def", "_column_resized", "(", "self", ",", "col", ",", "old_width", ",", "new_width", ")", ":", "self", ".", "dataTable", ".", "setColumnWidth", "(", "col", ",", "new_width", ")", "self", ".", "_update_layout", "(", ")" ]
Update the column width.
[ "Update", "the", "column", "width", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1034-L1037
30,632
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor._row_resized
def _row_resized(self, row, old_height, new_height): """Update the row height.""" self.dataTable.setRowHeight(row, new_height) self._update_layout()
python
def _row_resized(self, row, old_height, new_height): """Update the row height.""" self.dataTable.setRowHeight(row, new_height) self._update_layout()
[ "def", "_row_resized", "(", "self", ",", "row", ",", "old_height", ",", "new_height", ")", ":", "self", ".", "dataTable", ".", "setRowHeight", "(", "row", ",", "new_height", ")", "self", ".", "_update_layout", "(", ")" ]
Update the row height.
[ "Update", "the", "row", "height", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1039-L1042
30,633
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor._index_resized
def _index_resized(self, col, old_width, new_width): """Resize the corresponding column of the index section selected.""" self.table_index.setColumnWidth(col, new_width) self._update_layout()
python
def _index_resized(self, col, old_width, new_width): """Resize the corresponding column of the index section selected.""" self.table_index.setColumnWidth(col, new_width) self._update_layout()
[ "def", "_index_resized", "(", "self", ",", "col", ",", "old_width", ",", "new_width", ")", ":", "self", ".", "table_index", ".", "setColumnWidth", "(", "col", ",", "new_width", ")", "self", ".", "_update_layout", "(", ")" ]
Resize the corresponding column of the index section selected.
[ "Resize", "the", "corresponding", "column", "of", "the", "index", "section", "selected", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1044-L1047
30,634
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor._header_resized
def _header_resized(self, row, old_height, new_height): """Resize the corresponding row of the header section selected.""" self.table_header.setRowHeight(row, new_height) self._update_layout()
python
def _header_resized(self, row, old_height, new_height): """Resize the corresponding row of the header section selected.""" self.table_header.setRowHeight(row, new_height) self._update_layout()
[ "def", "_header_resized", "(", "self", ",", "row", ",", "old_height", ",", "new_height", ")", ":", "self", ".", "table_header", ".", "setRowHeight", "(", "row", ",", "new_height", ")", "self", ".", "_update_layout", "(", ")" ]
Resize the corresponding row of the header section selected.
[ "Resize", "the", "corresponding", "row", "of", "the", "header", "section", "selected", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1049-L1052
30,635
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor._reset_model
def _reset_model(self, table, model): """Set the model in the given table.""" old_sel_model = table.selectionModel() table.setModel(model) if old_sel_model: del old_sel_model
python
def _reset_model(self, table, model): """Set the model in the given table.""" old_sel_model = table.selectionModel() table.setModel(model) if old_sel_model: del old_sel_model
[ "def", "_reset_model", "(", "self", ",", "table", ",", "model", ")", ":", "old_sel_model", "=", "table", ".", "selectionModel", "(", ")", "table", ".", "setModel", "(", "model", ")", "if", "old_sel_model", ":", "del", "old_sel_model" ]
Set the model in the given table.
[ "Set", "the", "model", "in", "the", "given", "table", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1087-L1092
30,636
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor.setCurrentIndex
def setCurrentIndex(self, y, x): """Set current selection.""" self.dataTable.selectionModel().setCurrentIndex( self.dataTable.model().index(y, x), QItemSelectionModel.ClearAndSelect)
python
def setCurrentIndex(self, y, x): """Set current selection.""" self.dataTable.selectionModel().setCurrentIndex( self.dataTable.model().index(y, x), QItemSelectionModel.ClearAndSelect)
[ "def", "setCurrentIndex", "(", "self", ",", "y", ",", "x", ")", ":", "self", ".", "dataTable", ".", "selectionModel", "(", ")", ".", "setCurrentIndex", "(", "self", ".", "dataTable", ".", "model", "(", ")", ".", "index", "(", "y", ",", "x", ")", ",...
Set current selection.
[ "Set", "current", "selection", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1123-L1127
30,637
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor._resizeColumnToContents
def _resizeColumnToContents(self, header, data, col, limit_ms): """Resize a column by its contents.""" hdr_width = self._sizeHintForColumn(header, col, limit_ms) data_width = self._sizeHintForColumn(data, col, limit_ms) if data_width > hdr_width: width = min(self.max_width, data_width) elif hdr_width > data_width * 2: width = max(min(hdr_width, self.min_trunc), min(self.max_width, data_width)) else: width = max(min(self.max_width, hdr_width), self.min_trunc) header.setColumnWidth(col, width)
python
def _resizeColumnToContents(self, header, data, col, limit_ms): """Resize a column by its contents.""" hdr_width = self._sizeHintForColumn(header, col, limit_ms) data_width = self._sizeHintForColumn(data, col, limit_ms) if data_width > hdr_width: width = min(self.max_width, data_width) elif hdr_width > data_width * 2: width = max(min(hdr_width, self.min_trunc), min(self.max_width, data_width)) else: width = max(min(self.max_width, hdr_width), self.min_trunc) header.setColumnWidth(col, width)
[ "def", "_resizeColumnToContents", "(", "self", ",", "header", ",", "data", ",", "col", ",", "limit_ms", ")", ":", "hdr_width", "=", "self", ".", "_sizeHintForColumn", "(", "header", ",", "col", ",", "limit_ms", ")", "data_width", "=", "self", ".", "_sizeHi...
Resize a column by its contents.
[ "Resize", "a", "column", "by", "its", "contents", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1146-L1157
30,638
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor._resizeColumnsToContents
def _resizeColumnsToContents(self, header, data, limit_ms): """Resize all the colummns to its contents.""" max_col = data.model().columnCount() if limit_ms is None: max_col_ms = None else: max_col_ms = limit_ms / max(1, max_col) for col in range(max_col): self._resizeColumnToContents(header, data, col, max_col_ms)
python
def _resizeColumnsToContents(self, header, data, limit_ms): """Resize all the colummns to its contents.""" max_col = data.model().columnCount() if limit_ms is None: max_col_ms = None else: max_col_ms = limit_ms / max(1, max_col) for col in range(max_col): self._resizeColumnToContents(header, data, col, max_col_ms)
[ "def", "_resizeColumnsToContents", "(", "self", ",", "header", ",", "data", ",", "limit_ms", ")", ":", "max_col", "=", "data", ".", "model", "(", ")", ".", "columnCount", "(", ")", "if", "limit_ms", "is", "None", ":", "max_col_ms", "=", "None", "else", ...
Resize all the colummns to its contents.
[ "Resize", "all", "the", "colummns", "to", "its", "contents", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1159-L1167
30,639
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor.eventFilter
def eventFilter(self, obj, event): """Override eventFilter to catch resize event.""" if obj == self.dataTable and event.type() == QEvent.Resize: self._resizeVisibleColumnsToContents() return False
python
def eventFilter(self, obj, event): """Override eventFilter to catch resize event.""" if obj == self.dataTable and event.type() == QEvent.Resize: self._resizeVisibleColumnsToContents() return False
[ "def", "eventFilter", "(", "self", ",", "obj", ",", "event", ")", ":", "if", "obj", "==", "self", ".", "dataTable", "and", "event", ".", "type", "(", ")", "==", "QEvent", ".", "Resize", ":", "self", ".", "_resizeVisibleColumnsToContents", "(", ")", "re...
Override eventFilter to catch resize event.
[ "Override", "eventFilter", "to", "catch", "resize", "event", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1169-L1173
30,640
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor._resizeCurrentColumnToContents
def _resizeCurrentColumnToContents(self, new_index, old_index): """Resize the current column to its contents.""" if new_index.column() not in self._autosized_cols: # Ensure the requested column is fully into view after resizing self._resizeVisibleColumnsToContents() self.dataTable.scrollTo(new_index)
python
def _resizeCurrentColumnToContents(self, new_index, old_index): """Resize the current column to its contents.""" if new_index.column() not in self._autosized_cols: # Ensure the requested column is fully into view after resizing self._resizeVisibleColumnsToContents() self.dataTable.scrollTo(new_index)
[ "def", "_resizeCurrentColumnToContents", "(", "self", ",", "new_index", ",", "old_index", ")", ":", "if", "new_index", ".", "column", "(", ")", "not", "in", "self", ".", "_autosized_cols", ":", "# Ensure the requested column is fully into view after resizing\r", "self",...
Resize the current column to its contents.
[ "Resize", "the", "current", "column", "to", "its", "contents", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1202-L1207
30,641
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor.resizeColumnsToContents
def resizeColumnsToContents(self): """Resize the columns to its contents.""" self._autosized_cols = set() self._resizeColumnsToContents(self.table_level, self.table_index, self._max_autosize_ms) self._update_layout()
python
def resizeColumnsToContents(self): """Resize the columns to its contents.""" self._autosized_cols = set() self._resizeColumnsToContents(self.table_level, self.table_index, self._max_autosize_ms) self._update_layout()
[ "def", "resizeColumnsToContents", "(", "self", ")", ":", "self", ".", "_autosized_cols", "=", "set", "(", ")", "self", ".", "_resizeColumnsToContents", "(", "self", ".", "table_level", ",", "self", ".", "table_index", ",", "self", ".", "_max_autosize_ms", ")",...
Resize the columns to its contents.
[ "Resize", "the", "columns", "to", "its", "contents", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1209-L1214
30,642
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor.change_format
def change_format(self): """ Ask user for display format for floats and use it. This function also checks whether the format is valid and emits `sig_option_changed`. """ format, valid = QInputDialog.getText(self, _('Format'), _("Float formatting"), QLineEdit.Normal, self.dataModel.get_format()) if valid: format = str(format) try: format % 1.1 except: msg = _("Format ({}) is incorrect").format(format) QMessageBox.critical(self, _("Error"), msg) return if not format.startswith('%'): msg = _("Format ({}) should start with '%'").format(format) QMessageBox.critical(self, _("Error"), msg) return self.dataModel.set_format(format) self.sig_option_changed.emit('dataframe_format', format)
python
def change_format(self): """ Ask user for display format for floats and use it. This function also checks whether the format is valid and emits `sig_option_changed`. """ format, valid = QInputDialog.getText(self, _('Format'), _("Float formatting"), QLineEdit.Normal, self.dataModel.get_format()) if valid: format = str(format) try: format % 1.1 except: msg = _("Format ({}) is incorrect").format(format) QMessageBox.critical(self, _("Error"), msg) return if not format.startswith('%'): msg = _("Format ({}) should start with '%'").format(format) QMessageBox.critical(self, _("Error"), msg) return self.dataModel.set_format(format) self.sig_option_changed.emit('dataframe_format', format)
[ "def", "change_format", "(", "self", ")", ":", "format", ",", "valid", "=", "QInputDialog", ".", "getText", "(", "self", ",", "_", "(", "'Format'", ")", ",", "_", "(", "\"Float formatting\"", ")", ",", "QLineEdit", ".", "Normal", ",", "self", ".", "dat...
Ask user for display format for floats and use it. This function also checks whether the format is valid and emits `sig_option_changed`.
[ "Ask", "user", "for", "display", "format", "for", "floats", "and", "use", "it", ".", "This", "function", "also", "checks", "whether", "the", "format", "is", "valid", "and", "emits", "sig_option_changed", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1223-L1247
30,643
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/dataframeeditor.py
DataFrameEditor._update_header_size
def _update_header_size(self): """Update the column width of the header.""" column_count = self.table_header.model().columnCount() for index in range(0, column_count): if index < column_count: column_width = self.dataTable.columnWidth(index) self.table_header.setColumnWidth(index, column_width) else: break
python
def _update_header_size(self): """Update the column width of the header.""" column_count = self.table_header.model().columnCount() for index in range(0, column_count): if index < column_count: column_width = self.dataTable.columnWidth(index) self.table_header.setColumnWidth(index, column_width) else: break
[ "def", "_update_header_size", "(", "self", ")", ":", "column_count", "=", "self", ".", "table_header", ".", "model", "(", ")", ".", "columnCount", "(", ")", "for", "index", "in", "range", "(", "0", ",", "column_count", ")", ":", "if", "index", "<", "co...
Update the column width of the header.
[ "Update", "the", "column", "width", "of", "the", "header", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1259-L1267
30,644
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/namespacebrowser.py
NamespaceBrowser.setup_options_button
def setup_options_button(self): """Add the cog menu button to the toolbar.""" if not self.options_button: self.options_button = create_toolbutton( self, text=_('Options'), icon=ima.icon('tooloptions')) actions = self.actions + [MENU_SEPARATOR] + self.plugin_actions self.options_menu = QMenu(self) add_actions(self.options_menu, actions) self.options_button.setMenu(self.options_menu) if self.tools_layout.itemAt(self.tools_layout.count() - 1) is None: self.tools_layout.insertWidget( self.tools_layout.count() - 1, self.options_button) else: self.tools_layout.addWidget(self.options_button)
python
def setup_options_button(self): """Add the cog menu button to the toolbar.""" if not self.options_button: self.options_button = create_toolbutton( self, text=_('Options'), icon=ima.icon('tooloptions')) actions = self.actions + [MENU_SEPARATOR] + self.plugin_actions self.options_menu = QMenu(self) add_actions(self.options_menu, actions) self.options_button.setMenu(self.options_menu) if self.tools_layout.itemAt(self.tools_layout.count() - 1) is None: self.tools_layout.insertWidget( self.tools_layout.count() - 1, self.options_button) else: self.tools_layout.addWidget(self.options_button)
[ "def", "setup_options_button", "(", "self", ")", ":", "if", "not", "self", ".", "options_button", ":", "self", ".", "options_button", "=", "create_toolbutton", "(", "self", ",", "text", "=", "_", "(", "'Options'", ")", ",", "icon", "=", "ima", ".", "icon...
Add the cog menu button to the toolbar.
[ "Add", "the", "cog", "menu", "button", "to", "the", "toolbar", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/namespacebrowser.py#L217-L232
30,645
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/namespacebrowser.py
NamespaceBrowser.option_changed
def option_changed(self, option, value): """Option has changed""" setattr(self, to_text_string(option), value) self.shellwidget.set_namespace_view_settings() self.refresh_table()
python
def option_changed(self, option, value): """Option has changed""" setattr(self, to_text_string(option), value) self.shellwidget.set_namespace_view_settings() self.refresh_table()
[ "def", "option_changed", "(", "self", ",", "option", ",", "value", ")", ":", "setattr", "(", "self", ",", "to_text_string", "(", "option", ")", ",", "value", ")", "self", ".", "shellwidget", ".", "set_namespace_view_settings", "(", ")", "self", ".", "refre...
Option has changed
[ "Option", "has", "changed" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/namespacebrowser.py#L234-L238
30,646
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/namespacebrowser.py
NamespaceBrowser.get_view_settings
def get_view_settings(self): """Return dict editor view settings""" settings = {} for name in REMOTE_SETTINGS: settings[name] = getattr(self, name) return settings
python
def get_view_settings(self): """Return dict editor view settings""" settings = {} for name in REMOTE_SETTINGS: settings[name] = getattr(self, name) return settings
[ "def", "get_view_settings", "(", "self", ")", ":", "settings", "=", "{", "}", "for", "name", "in", "REMOTE_SETTINGS", ":", "settings", "[", "name", "]", "=", "getattr", "(", "self", ",", "name", ")", "return", "settings" ]
Return dict editor view settings
[ "Return", "dict", "editor", "view", "settings" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/namespacebrowser.py#L240-L245
30,647
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/namespacebrowser.py
NamespaceBrowser.refresh_table
def refresh_table(self): """Refresh variable table""" if self.is_visible and self.isVisible(): self.shellwidget.refresh_namespacebrowser() try: self.editor.resizeRowToContents() except TypeError: pass
python
def refresh_table(self): """Refresh variable table""" if self.is_visible and self.isVisible(): self.shellwidget.refresh_namespacebrowser() try: self.editor.resizeRowToContents() except TypeError: pass
[ "def", "refresh_table", "(", "self", ")", ":", "if", "self", ".", "is_visible", "and", "self", ".", "isVisible", "(", ")", ":", "self", ".", "shellwidget", ".", "refresh_namespacebrowser", "(", ")", "try", ":", "self", ".", "editor", ".", "resizeRowToConte...
Refresh variable table
[ "Refresh", "variable", "table" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/namespacebrowser.py#L247-L254
30,648
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/namespacebrowser.py
NamespaceBrowser.set_data
def set_data(self, data): """Set data.""" if data != self.editor.model.get_data(): self.editor.set_data(data) self.editor.adjust_columns()
python
def set_data(self, data): """Set data.""" if data != self.editor.model.get_data(): self.editor.set_data(data) self.editor.adjust_columns()
[ "def", "set_data", "(", "self", ",", "data", ")", ":", "if", "data", "!=", "self", ".", "editor", ".", "model", ".", "get_data", "(", ")", ":", "self", ".", "editor", ".", "set_data", "(", "data", ")", "self", ".", "editor", ".", "adjust_columns", ...
Set data.
[ "Set", "data", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/namespacebrowser.py#L266-L270
30,649
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/namespacebrowser.py
NamespaceBrowser.import_data
def import_data(self, filenames=None): """Import data from text file.""" title = _("Import data") if filenames is None: if self.filename is None: basedir = getcwd_or_home() else: basedir = osp.dirname(self.filename) filenames, _selfilter = getopenfilenames(self, title, basedir, iofunctions.load_filters) if not filenames: return elif is_text_string(filenames): filenames = [filenames] for filename in filenames: self.filename = to_text_string(filename) ext = osp.splitext(self.filename)[1].lower() if ext not in iofunctions.load_funcs: buttons = QMessageBox.Yes | QMessageBox.Cancel answer = QMessageBox.question(self, title, _("<b>Unsupported file extension '%s'</b><br><br>" "Would you like to import it anyway " "(by selecting a known file format)?" ) % ext, buttons) if answer == QMessageBox.Cancel: return formats = list(iofunctions.load_extensions.keys()) item, ok = QInputDialog.getItem(self, title, _('Open file as:'), formats, 0, False) if ok: ext = iofunctions.load_extensions[to_text_string(item)] else: return load_func = iofunctions.load_funcs[ext] # 'import_wizard' (self.setup_io) if is_text_string(load_func): # Import data with import wizard error_message = None try: text, _encoding = encoding.read(self.filename) base_name = osp.basename(self.filename) editor = ImportWizard(self, text, title=base_name, varname=fix_reference_name(base_name)) if editor.exec_(): var_name, clip_data = editor.get_data() self.editor.new_value(var_name, clip_data) except Exception as error: error_message = str(error) else: QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) QApplication.processEvents() error_message = self.shellwidget.load_data(self.filename, ext) self.shellwidget._kernel_reply = None QApplication.restoreOverrideCursor() QApplication.processEvents() if error_message is not None: QMessageBox.critical(self, title, _("<b>Unable to load '%s'</b>" "<br><br>Error message:<br>%s" ) % (self.filename, error_message)) self.refresh_table()
python
def import_data(self, filenames=None): """Import data from text file.""" title = _("Import data") if filenames is None: if self.filename is None: basedir = getcwd_or_home() else: basedir = osp.dirname(self.filename) filenames, _selfilter = getopenfilenames(self, title, basedir, iofunctions.load_filters) if not filenames: return elif is_text_string(filenames): filenames = [filenames] for filename in filenames: self.filename = to_text_string(filename) ext = osp.splitext(self.filename)[1].lower() if ext not in iofunctions.load_funcs: buttons = QMessageBox.Yes | QMessageBox.Cancel answer = QMessageBox.question(self, title, _("<b>Unsupported file extension '%s'</b><br><br>" "Would you like to import it anyway " "(by selecting a known file format)?" ) % ext, buttons) if answer == QMessageBox.Cancel: return formats = list(iofunctions.load_extensions.keys()) item, ok = QInputDialog.getItem(self, title, _('Open file as:'), formats, 0, False) if ok: ext = iofunctions.load_extensions[to_text_string(item)] else: return load_func = iofunctions.load_funcs[ext] # 'import_wizard' (self.setup_io) if is_text_string(load_func): # Import data with import wizard error_message = None try: text, _encoding = encoding.read(self.filename) base_name = osp.basename(self.filename) editor = ImportWizard(self, text, title=base_name, varname=fix_reference_name(base_name)) if editor.exec_(): var_name, clip_data = editor.get_data() self.editor.new_value(var_name, clip_data) except Exception as error: error_message = str(error) else: QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) QApplication.processEvents() error_message = self.shellwidget.load_data(self.filename, ext) self.shellwidget._kernel_reply = None QApplication.restoreOverrideCursor() QApplication.processEvents() if error_message is not None: QMessageBox.critical(self, title, _("<b>Unable to load '%s'</b>" "<br><br>Error message:<br>%s" ) % (self.filename, error_message)) self.refresh_table()
[ "def", "import_data", "(", "self", ",", "filenames", "=", "None", ")", ":", "title", "=", "_", "(", "\"Import data\"", ")", "if", "filenames", "is", "None", ":", "if", "self", ".", "filename", "is", "None", ":", "basedir", "=", "getcwd_or_home", "(", "...
Import data from text file.
[ "Import", "data", "from", "text", "file", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/namespacebrowser.py#L278-L344
30,650
spyder-ide/spyder
spyder/preferences/configdialog.py
ConfigPage.apply_changes
def apply_changes(self): """Apply changes callback""" if self.is_modified: self.save_to_conf() if self.apply_callback is not None: self.apply_callback() # Since the language cannot be retrieved by CONF and the language # is needed before loading CONF, this is an extra method needed to # ensure that when changes are applied, they are copied to a # specific file storing the language value. This only applies to # the main section config. if self.CONF_SECTION == u'main': self._save_lang() for restart_option in self.restart_options: if restart_option in self.changed_options: self.prompt_restart_required() break # Ensure a single popup is displayed self.set_modified(False)
python
def apply_changes(self): """Apply changes callback""" if self.is_modified: self.save_to_conf() if self.apply_callback is not None: self.apply_callback() # Since the language cannot be retrieved by CONF and the language # is needed before loading CONF, this is an extra method needed to # ensure that when changes are applied, they are copied to a # specific file storing the language value. This only applies to # the main section config. if self.CONF_SECTION == u'main': self._save_lang() for restart_option in self.restart_options: if restart_option in self.changed_options: self.prompt_restart_required() break # Ensure a single popup is displayed self.set_modified(False)
[ "def", "apply_changes", "(", "self", ")", ":", "if", "self", ".", "is_modified", ":", "self", ".", "save_to_conf", "(", ")", "if", "self", ".", "apply_callback", "is", "not", "None", ":", "self", ".", "apply_callback", "(", ")", "# Since the language cannot ...
Apply changes callback
[ "Apply", "changes", "callback" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/configdialog.py#L92-L111
30,651
spyder-ide/spyder
spyder/preferences/configdialog.py
ConfigDialog.get_page
def get_page(self, index=None): """Return page widget""" if index is None: widget = self.pages_widget.currentWidget() else: widget = self.pages_widget.widget(index) return widget.widget()
python
def get_page(self, index=None): """Return page widget""" if index is None: widget = self.pages_widget.currentWidget() else: widget = self.pages_widget.widget(index) return widget.widget()
[ "def", "get_page", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "widget", "=", "self", ".", "pages_widget", ".", "currentWidget", "(", ")", "else", ":", "widget", "=", "self", ".", "pages_widget", ".", "widget", ...
Return page widget
[ "Return", "page", "widget" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/configdialog.py#L197-L203
30,652
spyder-ide/spyder
spyder/preferences/configdialog.py
ConfigDialog.resizeEvent
def resizeEvent(self, event): """ Reimplement Qt method to be able to save the widget's size from the main application """ QDialog.resizeEvent(self, event) self.size_change.emit(self.size())
python
def resizeEvent(self, event): """ Reimplement Qt method to be able to save the widget's size from the main application """ QDialog.resizeEvent(self, event) self.size_change.emit(self.size())
[ "def", "resizeEvent", "(", "self", ",", "event", ")", ":", "QDialog", ".", "resizeEvent", "(", "self", ",", "event", ")", "self", ".", "size_change", ".", "emit", "(", "self", ".", "size", "(", ")", ")" ]
Reimplement Qt method to be able to save the widget's size from the main application
[ "Reimplement", "Qt", "method", "to", "be", "able", "to", "save", "the", "widget", "s", "size", "from", "the", "main", "application" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/configdialog.py#L251-L257
30,653
spyder-ide/spyder
spyder/preferences/configdialog.py
SpyderConfigPage.is_valid
def is_valid(self): """Return True if all widget contents are valid""" for lineedit in self.lineedits: if lineedit in self.validate_data and lineedit.isEnabled(): validator, invalid_msg = self.validate_data[lineedit] text = to_text_string(lineedit.text()) if not validator(text): QMessageBox.critical(self, self.get_name(), "%s:<br><b>%s</b>" % (invalid_msg, text), QMessageBox.Ok) return False return True
python
def is_valid(self): """Return True if all widget contents are valid""" for lineedit in self.lineedits: if lineedit in self.validate_data and lineedit.isEnabled(): validator, invalid_msg = self.validate_data[lineedit] text = to_text_string(lineedit.text()) if not validator(text): QMessageBox.critical(self, self.get_name(), "%s:<br><b>%s</b>" % (invalid_msg, text), QMessageBox.Ok) return False return True
[ "def", "is_valid", "(", "self", ")", ":", "for", "lineedit", "in", "self", ".", "lineedits", ":", "if", "lineedit", "in", "self", ".", "validate_data", "and", "lineedit", ".", "isEnabled", "(", ")", ":", "validator", ",", "invalid_msg", "=", "self", ".",...
Return True if all widget contents are valid
[ "Return", "True", "if", "all", "widget", "contents", "are", "valid" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/configdialog.py#L295-L306
30,654
spyder-ide/spyder
spyder/preferences/configdialog.py
SpyderConfigPage.save_to_conf
def save_to_conf(self): """Save settings to configuration file""" for checkbox, (option, _default) in list(self.checkboxes.items()): self.set_option(option, checkbox.isChecked()) for radiobutton, (option, _default) in list(self.radiobuttons.items()): self.set_option(option, radiobutton.isChecked()) for lineedit, (option, _default) in list(self.lineedits.items()): self.set_option(option, to_text_string(lineedit.text())) for textedit, (option, _default) in list(self.textedits.items()): self.set_option(option, to_text_string(textedit.toPlainText())) for spinbox, (option, _default) in list(self.spinboxes.items()): self.set_option(option, spinbox.value()) for combobox, (option, _default) in list(self.comboboxes.items()): data = combobox.itemData(combobox.currentIndex()) self.set_option(option, from_qvariant(data, to_text_string)) for (fontbox, sizebox), option in list(self.fontboxes.items()): font = fontbox.currentFont() font.setPointSize(sizebox.value()) self.set_font(font, option) for clayout, (option, _default) in list(self.coloredits.items()): self.set_option(option, to_text_string(clayout.lineedit.text())) for (clayout, cb_bold, cb_italic), (option, _default) in list(self.scedits.items()): color = to_text_string(clayout.lineedit.text()) bold = cb_bold.isChecked() italic = cb_italic.isChecked() self.set_option(option, (color, bold, italic))
python
def save_to_conf(self): """Save settings to configuration file""" for checkbox, (option, _default) in list(self.checkboxes.items()): self.set_option(option, checkbox.isChecked()) for radiobutton, (option, _default) in list(self.radiobuttons.items()): self.set_option(option, radiobutton.isChecked()) for lineedit, (option, _default) in list(self.lineedits.items()): self.set_option(option, to_text_string(lineedit.text())) for textedit, (option, _default) in list(self.textedits.items()): self.set_option(option, to_text_string(textedit.toPlainText())) for spinbox, (option, _default) in list(self.spinboxes.items()): self.set_option(option, spinbox.value()) for combobox, (option, _default) in list(self.comboboxes.items()): data = combobox.itemData(combobox.currentIndex()) self.set_option(option, from_qvariant(data, to_text_string)) for (fontbox, sizebox), option in list(self.fontboxes.items()): font = fontbox.currentFont() font.setPointSize(sizebox.value()) self.set_font(font, option) for clayout, (option, _default) in list(self.coloredits.items()): self.set_option(option, to_text_string(clayout.lineedit.text())) for (clayout, cb_bold, cb_italic), (option, _default) in list(self.scedits.items()): color = to_text_string(clayout.lineedit.text()) bold = cb_bold.isChecked() italic = cb_italic.isChecked() self.set_option(option, (color, bold, italic))
[ "def", "save_to_conf", "(", "self", ")", ":", "for", "checkbox", ",", "(", "option", ",", "_default", ")", "in", "list", "(", "self", ".", "checkboxes", ".", "items", "(", ")", ")", ":", "self", ".", "set_option", "(", "option", ",", "checkbox", ".",...
Save settings to configuration file
[ "Save", "settings", "to", "configuration", "file" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/configdialog.py#L412-L437
30,655
spyder-ide/spyder
spyder/preferences/configdialog.py
SpyderConfigPage.create_fontgroup
def create_fontgroup(self, option=None, text=None, title=None, tip=None, fontfilters=None, without_group=False): """Option=None -> setting plugin font""" if title: fontlabel = QLabel(title) else: fontlabel = QLabel(_("Font")) fontbox = QFontComboBox() if fontfilters is not None: fontbox.setFontFilters(fontfilters) sizelabel = QLabel(" "+_("Size")) sizebox = QSpinBox() sizebox.setRange(7, 100) self.fontboxes[(fontbox, sizebox)] = option layout = QHBoxLayout() for subwidget in (fontlabel, fontbox, sizelabel, sizebox): layout.addWidget(subwidget) layout.addStretch(1) widget = QWidget(self) widget.fontlabel = fontlabel widget.sizelabel = sizelabel widget.fontbox = fontbox widget.sizebox = sizebox widget.setLayout(layout) if not without_group: if text is None: text = _("Font style") group = QGroupBox(text) group.setLayout(layout) if tip is not None: group.setToolTip(tip) return group else: return widget
python
def create_fontgroup(self, option=None, text=None, title=None, tip=None, fontfilters=None, without_group=False): """Option=None -> setting plugin font""" if title: fontlabel = QLabel(title) else: fontlabel = QLabel(_("Font")) fontbox = QFontComboBox() if fontfilters is not None: fontbox.setFontFilters(fontfilters) sizelabel = QLabel(" "+_("Size")) sizebox = QSpinBox() sizebox.setRange(7, 100) self.fontboxes[(fontbox, sizebox)] = option layout = QHBoxLayout() for subwidget in (fontlabel, fontbox, sizelabel, sizebox): layout.addWidget(subwidget) layout.addStretch(1) widget = QWidget(self) widget.fontlabel = fontlabel widget.sizelabel = sizelabel widget.fontbox = fontbox widget.sizebox = sizebox widget.setLayout(layout) if not without_group: if text is None: text = _("Font style") group = QGroupBox(text) group.setLayout(layout) if tip is not None: group.setToolTip(tip) return group else: return widget
[ "def", "create_fontgroup", "(", "self", ",", "option", "=", "None", ",", "text", "=", "None", ",", "title", "=", "None", ",", "tip", "=", "None", ",", "fontfilters", "=", "None", ",", "without_group", "=", "False", ")", ":", "if", "title", ":", "font...
Option=None -> setting plugin font
[ "Option", "=", "None", "-", ">", "setting", "plugin", "font" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/configdialog.py#L749-L791
30,656
spyder-ide/spyder
spyder/preferences/configdialog.py
GeneralConfigPage.prompt_restart_required
def prompt_restart_required(self): """Prompt the user with a request to restart.""" restart_opts = self.restart_options changed_opts = self.changed_options options = [restart_opts[o] for o in changed_opts if o in restart_opts] if len(options) == 1: msg_start = _("Spyder needs to restart to change the following " "setting:") else: msg_start = _("Spyder needs to restart to change the following " "settings:") msg_end = _("Do you wish to restart now?") msg_options = u"" for option in options: msg_options += u"<li>{0}</li>".format(option) msg_title = _("Information") msg = u"{0}<ul>{1}</ul><br>{2}".format(msg_start, msg_options, msg_end) answer = QMessageBox.information(self, msg_title, msg, QMessageBox.Yes | QMessageBox.No) if answer == QMessageBox.Yes: self.restart()
python
def prompt_restart_required(self): """Prompt the user with a request to restart.""" restart_opts = self.restart_options changed_opts = self.changed_options options = [restart_opts[o] for o in changed_opts if o in restart_opts] if len(options) == 1: msg_start = _("Spyder needs to restart to change the following " "setting:") else: msg_start = _("Spyder needs to restart to change the following " "settings:") msg_end = _("Do you wish to restart now?") msg_options = u"" for option in options: msg_options += u"<li>{0}</li>".format(option) msg_title = _("Information") msg = u"{0}<ul>{1}</ul><br>{2}".format(msg_start, msg_options, msg_end) answer = QMessageBox.information(self, msg_title, msg, QMessageBox.Yes | QMessageBox.No) if answer == QMessageBox.Yes: self.restart()
[ "def", "prompt_restart_required", "(", "self", ")", ":", "restart_opts", "=", "self", ".", "restart_options", "changed_opts", "=", "self", ".", "changed_options", "options", "=", "[", "restart_opts", "[", "o", "]", "for", "o", "in", "changed_opts", "if", "o", ...
Prompt the user with a request to restart.
[ "Prompt", "the", "user", "with", "a", "request", "to", "restart", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/preferences/configdialog.py#L834-L857
30,657
spyder-ide/spyder
spyder/widgets/helperwidgets.py
IconLineEdit.update_status
def update_status(self, value, value_set): """Update the status and set_status to update the icons to display.""" self._status = value self._status_set = value_set self.repaint() self.update()
python
def update_status(self, value, value_set): """Update the status and set_status to update the icons to display.""" self._status = value self._status_set = value_set self.repaint() self.update()
[ "def", "update_status", "(", "self", ",", "value", ",", "value_set", ")", ":", "self", ".", "_status", "=", "value", "self", ".", "_status_set", "=", "value_set", "self", ".", "repaint", "(", ")", "self", ".", "update", "(", ")" ]
Update the status and set_status to update the icons to display.
[ "Update", "the", "status", "and", "set_status", "to", "update", "the", "icons", "to", "display", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/helperwidgets.py#L248-L253
30,658
spyder-ide/spyder
spyder/plugins/outlineexplorer/plugin.py
OutlineExplorer.restore_scrollbar_position
def restore_scrollbar_position(self): """Restoring scrollbar position after main window is visible""" scrollbar_pos = self.get_option('scrollbar_position', None) if scrollbar_pos is not None: self.explorer.treewidget.set_scrollbar_position(scrollbar_pos)
python
def restore_scrollbar_position(self): """Restoring scrollbar position after main window is visible""" scrollbar_pos = self.get_option('scrollbar_position', None) if scrollbar_pos is not None: self.explorer.treewidget.set_scrollbar_position(scrollbar_pos)
[ "def", "restore_scrollbar_position", "(", "self", ")", ":", "scrollbar_pos", "=", "self", ".", "get_option", "(", "'scrollbar_position'", ",", "None", ")", "if", "scrollbar_pos", "is", "not", "None", ":", "self", ".", "explorer", ".", "treewidget", ".", "set_s...
Restoring scrollbar position after main window is visible
[ "Restoring", "scrollbar", "position", "after", "main", "window", "is", "visible" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/outlineexplorer/plugin.py#L102-L106
30,659
spyder-ide/spyder
spyder/plugins/pylint/widgets/pylintgui.py
PylintWidget.remove_obsolete_items
def remove_obsolete_items(self): """Removing obsolete items""" self.rdata = [(filename, data) for filename, data in self.rdata if is_module_or_package(filename)]
python
def remove_obsolete_items(self): """Removing obsolete items""" self.rdata = [(filename, data) for filename, data in self.rdata if is_module_or_package(filename)]
[ "def", "remove_obsolete_items", "(", "self", ")", ":", "self", ".", "rdata", "=", "[", "(", "filename", ",", "data", ")", "for", "filename", ",", "data", "in", "self", ".", "rdata", "if", "is_module_or_package", "(", "filename", ")", "]" ]
Removing obsolete items
[ "Removing", "obsolete", "items" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/pylint/widgets/pylintgui.py#L257-L260
30,660
spyder-ide/spyder
spyder/workers/updates.py
WorkerUpdates.check_update_available
def check_update_available(self): """Checks if there is an update available. It takes as parameters the current version of Spyder and a list of valid cleaned releases in chronological order. Example: ['2.3.2', '2.3.3' ...] or with github ['2.3.4', '2.3.3' ...] """ # Don't perform any check for development versions if 'dev' in self.version: return (False, latest_release) # Filter releases if is_stable_version(self.version): releases = [r for r in self.releases if is_stable_version(r)] else: releases = [r for r in self.releases if not is_stable_version(r) or r in self.version] latest_release = releases[-1] return (check_version(self.version, latest_release, '<'), latest_release)
python
def check_update_available(self): """Checks if there is an update available. It takes as parameters the current version of Spyder and a list of valid cleaned releases in chronological order. Example: ['2.3.2', '2.3.3' ...] or with github ['2.3.4', '2.3.3' ...] """ # Don't perform any check for development versions if 'dev' in self.version: return (False, latest_release) # Filter releases if is_stable_version(self.version): releases = [r for r in self.releases if is_stable_version(r)] else: releases = [r for r in self.releases if not is_stable_version(r) or r in self.version] latest_release = releases[-1] return (check_version(self.version, latest_release, '<'), latest_release)
[ "def", "check_update_available", "(", "self", ")", ":", "# Don't perform any check for development versions", "if", "'dev'", "in", "self", ".", "version", ":", "return", "(", "False", ",", "latest_release", ")", "# Filter releases", "if", "is_stable_version", "(", "se...
Checks if there is an update available. It takes as parameters the current version of Spyder and a list of valid cleaned releases in chronological order. Example: ['2.3.2', '2.3.3' ...] or with github ['2.3.4', '2.3.3' ...]
[ "Checks", "if", "there", "is", "an", "update", "available", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/workers/updates.py#L54-L75
30,661
spyder-ide/spyder
spyder/workers/updates.py
WorkerUpdates.start
def start(self): """Main method of the WorkerUpdates worker""" if is_anaconda(): self.url = 'https://repo.anaconda.com/pkgs/main' if os.name == 'nt': self.url += '/win-64/repodata.json' elif sys.platform == 'darwin': self.url += '/osx-64/repodata.json' else: self.url += '/linux-64/repodata.json' else: self.url = ('https://api.github.com/repos/' 'spyder-ide/spyder/releases') self.update_available = False self.latest_release = __version__ error_msg = None try: if hasattr(ssl, '_create_unverified_context'): # Fix for issue # 2685 [Works only with Python >=2.7.9] # More info: https://www.python.org/dev/peps/pep-0476/#opting-out context = ssl._create_unverified_context() page = urlopen(self.url, context=context) else: page = urlopen(self.url) try: data = page.read() # Needed step for python3 compatibility if not is_text_string(data): data = data.decode() data = json.loads(data) if is_anaconda(): if self.releases is None: self.releases = [] for item in data['packages']: if ('spyder' in item and not re.search(r'spyder-[a-zA-Z]', item)): self.releases.append(item.split('-')[1]) result = self.check_update_available() else: if self.releases is None: self.releases = [item['tag_name'].replace('v', '') for item in data] self.releases = list(reversed(self.releases)) result = self.check_update_available() self.update_available, self.latest_release = result except Exception: error_msg = _('Unable to retrieve information.') except HTTPError: error_msg = _('Unable to retrieve information.') except URLError: error_msg = _('Unable to connect to the internet. <br><br>Make ' 'sure the connection is working properly.') except Exception: error_msg = _('Unable to check for updates.') # Don't show dialog when starting up spyder and an error occur if not (self.startup and error_msg is not None): self.error = error_msg self.sig_ready.emit()
python
def start(self): """Main method of the WorkerUpdates worker""" if is_anaconda(): self.url = 'https://repo.anaconda.com/pkgs/main' if os.name == 'nt': self.url += '/win-64/repodata.json' elif sys.platform == 'darwin': self.url += '/osx-64/repodata.json' else: self.url += '/linux-64/repodata.json' else: self.url = ('https://api.github.com/repos/' 'spyder-ide/spyder/releases') self.update_available = False self.latest_release = __version__ error_msg = None try: if hasattr(ssl, '_create_unverified_context'): # Fix for issue # 2685 [Works only with Python >=2.7.9] # More info: https://www.python.org/dev/peps/pep-0476/#opting-out context = ssl._create_unverified_context() page = urlopen(self.url, context=context) else: page = urlopen(self.url) try: data = page.read() # Needed step for python3 compatibility if not is_text_string(data): data = data.decode() data = json.loads(data) if is_anaconda(): if self.releases is None: self.releases = [] for item in data['packages']: if ('spyder' in item and not re.search(r'spyder-[a-zA-Z]', item)): self.releases.append(item.split('-')[1]) result = self.check_update_available() else: if self.releases is None: self.releases = [item['tag_name'].replace('v', '') for item in data] self.releases = list(reversed(self.releases)) result = self.check_update_available() self.update_available, self.latest_release = result except Exception: error_msg = _('Unable to retrieve information.') except HTTPError: error_msg = _('Unable to retrieve information.') except URLError: error_msg = _('Unable to connect to the internet. <br><br>Make ' 'sure the connection is working properly.') except Exception: error_msg = _('Unable to check for updates.') # Don't show dialog when starting up spyder and an error occur if not (self.startup and error_msg is not None): self.error = error_msg self.sig_ready.emit()
[ "def", "start", "(", "self", ")", ":", "if", "is_anaconda", "(", ")", ":", "self", ".", "url", "=", "'https://repo.anaconda.com/pkgs/main'", "if", "os", ".", "name", "==", "'nt'", ":", "self", ".", "url", "+=", "'/win-64/repodata.json'", "elif", "sys", "."...
Main method of the WorkerUpdates worker
[ "Main", "method", "of", "the", "WorkerUpdates", "worker" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/workers/updates.py#L77-L140
30,662
spyder-ide/spyder
spyder/widgets/findreplace.py
FindReplace.create_shortcuts
def create_shortcuts(self, parent): """Create shortcuts for this widget""" # Configurable findnext = config_shortcut(self.find_next, context='_', name='Find next', parent=parent) findprev = config_shortcut(self.find_previous, context='_', name='Find previous', parent=parent) togglefind = config_shortcut(self.show, context='_', name='Find text', parent=parent) togglereplace = config_shortcut(self.show_replace, context='_', name='Replace text', parent=parent) hide = config_shortcut(self.hide, context='_', name='hide find and replace', parent=self) return [findnext, findprev, togglefind, togglereplace, hide]
python
def create_shortcuts(self, parent): """Create shortcuts for this widget""" # Configurable findnext = config_shortcut(self.find_next, context='_', name='Find next', parent=parent) findprev = config_shortcut(self.find_previous, context='_', name='Find previous', parent=parent) togglefind = config_shortcut(self.show, context='_', name='Find text', parent=parent) togglereplace = config_shortcut(self.show_replace, context='_', name='Replace text', parent=parent) hide = config_shortcut(self.hide, context='_', name='hide find and replace', parent=self) return [findnext, findprev, togglefind, togglereplace, hide]
[ "def", "create_shortcuts", "(", "self", ",", "parent", ")", ":", "# Configurable\r", "findnext", "=", "config_shortcut", "(", "self", ".", "find_next", ",", "context", "=", "'_'", ",", "name", "=", "'Find next'", ",", "parent", "=", "parent", ")", "findprev"...
Create shortcuts for this widget
[ "Create", "shortcuts", "for", "this", "widget" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/findreplace.py#L207-L222
30,663
spyder-ide/spyder
spyder/widgets/findreplace.py
FindReplace.toggle_highlighting
def toggle_highlighting(self, state): """Toggle the 'highlight all results' feature""" if self.editor is not None: if state: self.highlight_matches() else: self.clear_matches()
python
def toggle_highlighting(self, state): """Toggle the 'highlight all results' feature""" if self.editor is not None: if state: self.highlight_matches() else: self.clear_matches()
[ "def", "toggle_highlighting", "(", "self", ",", "state", ")", ":", "if", "self", ".", "editor", "is", "not", "None", ":", "if", "state", ":", "self", ".", "highlight_matches", "(", ")", "else", ":", "self", ".", "clear_matches", "(", ")" ]
Toggle the 'highlight all results' feature
[ "Toggle", "the", "highlight", "all", "results", "feature" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/findreplace.py#L251-L257
30,664
spyder-ide/spyder
spyder/widgets/findreplace.py
FindReplace.show_replace
def show_replace(self): """Show replace widgets""" self.show(hide_replace=False) for widget in self.replace_widgets: widget.show()
python
def show_replace(self): """Show replace widgets""" self.show(hide_replace=False) for widget in self.replace_widgets: widget.show()
[ "def", "show_replace", "(", "self", ")", ":", "self", ".", "show", "(", "hide_replace", "=", "False", ")", "for", "widget", "in", "self", ".", "replace_widgets", ":", "widget", ".", "show", "(", ")" ]
Show replace widgets
[ "Show", "replace", "widgets" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/findreplace.py#L305-L309
30,665
spyder-ide/spyder
spyder/widgets/findreplace.py
FindReplace.find_next
def find_next(self): """Find next occurrence""" state = self.find(changed=False, forward=True, rehighlight=False, multiline_replace_check=False) self.editor.setFocus() self.search_text.add_current_text() return state
python
def find_next(self): """Find next occurrence""" state = self.find(changed=False, forward=True, rehighlight=False, multiline_replace_check=False) self.editor.setFocus() self.search_text.add_current_text() return state
[ "def", "find_next", "(", "self", ")", ":", "state", "=", "self", ".", "find", "(", "changed", "=", "False", ",", "forward", "=", "True", ",", "rehighlight", "=", "False", ",", "multiline_replace_check", "=", "False", ")", "self", ".", "editor", ".", "s...
Find next occurrence
[ "Find", "next", "occurrence" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/findreplace.py#L352-L358
30,666
spyder-ide/spyder
spyder/widgets/findreplace.py
FindReplace.find_previous
def find_previous(self): """Find previous occurrence""" state = self.find(changed=False, forward=False, rehighlight=False, multiline_replace_check=False) self.editor.setFocus() return state
python
def find_previous(self): """Find previous occurrence""" state = self.find(changed=False, forward=False, rehighlight=False, multiline_replace_check=False) self.editor.setFocus() return state
[ "def", "find_previous", "(", "self", ")", ":", "state", "=", "self", ".", "find", "(", "changed", "=", "False", ",", "forward", "=", "False", ",", "rehighlight", "=", "False", ",", "multiline_replace_check", "=", "False", ")", "self", ".", "editor", ".",...
Find previous occurrence
[ "Find", "previous", "occurrence" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/findreplace.py#L361-L366
30,667
spyder-ide/spyder
spyder/widgets/findreplace.py
FindReplace.highlight_matches
def highlight_matches(self): """Highlight found results""" if self.is_code_editor and self.highlight_button.isChecked(): text = self.search_text.currentText() words = self.words_button.isChecked() regexp = self.re_button.isChecked() self.editor.highlight_found_results(text, words=words, regexp=regexp)
python
def highlight_matches(self): """Highlight found results""" if self.is_code_editor and self.highlight_button.isChecked(): text = self.search_text.currentText() words = self.words_button.isChecked() regexp = self.re_button.isChecked() self.editor.highlight_found_results(text, words=words, regexp=regexp)
[ "def", "highlight_matches", "(", "self", ")", ":", "if", "self", ".", "is_code_editor", "and", "self", ".", "highlight_button", ".", "isChecked", "(", ")", ":", "text", "=", "self", ".", "search_text", ".", "currentText", "(", ")", "words", "=", "self", ...
Highlight found results
[ "Highlight", "found", "results" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/findreplace.py#L373-L380
30,668
spyder-ide/spyder
spyder/widgets/findreplace.py
FindReplace.replace_find
def replace_find(self, focus_replace_text=False, replace_all=False): """Replace and find""" if (self.editor is not None): replace_text = to_text_string(self.replace_text.currentText()) search_text = to_text_string(self.search_text.currentText()) re_pattern = None # Check regexp before proceeding if self.re_button.isChecked(): try: re_pattern = re.compile(search_text) # Check if replace_text can be substituted in re_pattern # Fixes issue #7177 re_pattern.sub(replace_text, '') except re.error: # Do nothing with an invalid regexp return case = self.case_button.isChecked() first = True cursor = None while True: if first: # First found seltxt = to_text_string(self.editor.get_selected_text()) cmptxt1 = search_text if case else search_text.lower() cmptxt2 = seltxt if case else seltxt.lower() if re_pattern is None: has_selected = self.editor.has_selected_text() if has_selected and cmptxt1 == cmptxt2: # Text was already found, do nothing pass else: if not self.find(changed=False, forward=True, rehighlight=False): break else: if len(re_pattern.findall(cmptxt2)) > 0: pass else: if not self.find(changed=False, forward=True, rehighlight=False): break first = False wrapped = False position = self.editor.get_position('cursor') position0 = position cursor = self.editor.textCursor() cursor.beginEditBlock() else: position1 = self.editor.get_position('cursor') if is_position_inf(position1, position0 + len(replace_text) - len(search_text) + 1): # Identify wrapping even when the replace string # includes part of the search string wrapped = True if wrapped: if position1 == position or \ is_position_sup(position1, position): # Avoid infinite loop: replace string includes # part of the search string break if position1 == position0: # Avoid infinite loop: single found occurrence break position0 = position1 if re_pattern is None: cursor.removeSelectedText() cursor.insertText(replace_text) else: seltxt = to_text_string(cursor.selectedText()) cursor.removeSelectedText() cursor.insertText(re_pattern.sub(replace_text, seltxt)) if self.find_next(): found_cursor = self.editor.textCursor() cursor.setPosition(found_cursor.selectionStart(), QTextCursor.MoveAnchor) cursor.setPosition(found_cursor.selectionEnd(), QTextCursor.KeepAnchor) else: break if not replace_all: break if cursor is not None: cursor.endEditBlock() if focus_replace_text: self.replace_text.setFocus()
python
def replace_find(self, focus_replace_text=False, replace_all=False): """Replace and find""" if (self.editor is not None): replace_text = to_text_string(self.replace_text.currentText()) search_text = to_text_string(self.search_text.currentText()) re_pattern = None # Check regexp before proceeding if self.re_button.isChecked(): try: re_pattern = re.compile(search_text) # Check if replace_text can be substituted in re_pattern # Fixes issue #7177 re_pattern.sub(replace_text, '') except re.error: # Do nothing with an invalid regexp return case = self.case_button.isChecked() first = True cursor = None while True: if first: # First found seltxt = to_text_string(self.editor.get_selected_text()) cmptxt1 = search_text if case else search_text.lower() cmptxt2 = seltxt if case else seltxt.lower() if re_pattern is None: has_selected = self.editor.has_selected_text() if has_selected and cmptxt1 == cmptxt2: # Text was already found, do nothing pass else: if not self.find(changed=False, forward=True, rehighlight=False): break else: if len(re_pattern.findall(cmptxt2)) > 0: pass else: if not self.find(changed=False, forward=True, rehighlight=False): break first = False wrapped = False position = self.editor.get_position('cursor') position0 = position cursor = self.editor.textCursor() cursor.beginEditBlock() else: position1 = self.editor.get_position('cursor') if is_position_inf(position1, position0 + len(replace_text) - len(search_text) + 1): # Identify wrapping even when the replace string # includes part of the search string wrapped = True if wrapped: if position1 == position or \ is_position_sup(position1, position): # Avoid infinite loop: replace string includes # part of the search string break if position1 == position0: # Avoid infinite loop: single found occurrence break position0 = position1 if re_pattern is None: cursor.removeSelectedText() cursor.insertText(replace_text) else: seltxt = to_text_string(cursor.selectedText()) cursor.removeSelectedText() cursor.insertText(re_pattern.sub(replace_text, seltxt)) if self.find_next(): found_cursor = self.editor.textCursor() cursor.setPosition(found_cursor.selectionStart(), QTextCursor.MoveAnchor) cursor.setPosition(found_cursor.selectionEnd(), QTextCursor.KeepAnchor) else: break if not replace_all: break if cursor is not None: cursor.endEditBlock() if focus_replace_text: self.replace_text.setFocus()
[ "def", "replace_find", "(", "self", ",", "focus_replace_text", "=", "False", ",", "replace_all", "=", "False", ")", ":", "if", "(", "self", ".", "editor", "is", "not", "None", ")", ":", "replace_text", "=", "to_text_string", "(", "self", ".", "replace_text...
Replace and find
[ "Replace", "and", "find" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/findreplace.py#L446-L533
30,669
spyder-ide/spyder
spyder/widgets/findreplace.py
FindReplace.replace_find_selection
def replace_find_selection(self, focus_replace_text=False): """Replace and find in the current selection""" if self.editor is not None: replace_text = to_text_string(self.replace_text.currentText()) search_text = to_text_string(self.search_text.currentText()) case = self.case_button.isChecked() words = self.words_button.isChecked() re_flags = re.MULTILINE if case else re.IGNORECASE|re.MULTILINE re_pattern = None if self.re_button.isChecked(): pattern = search_text else: pattern = re.escape(search_text) replace_text = re.escape(replace_text) if words: # match whole words only pattern = r'\b{pattern}\b'.format(pattern=pattern) # Check regexp before proceeding try: re_pattern = re.compile(pattern, flags=re_flags) # Check if replace_text can be substituted in re_pattern # Fixes issue #7177 re_pattern.sub(replace_text, '') except re.error as e: # Do nothing with an invalid regexp return selected_text = to_text_string(self.editor.get_selected_text()) replacement = re_pattern.sub(replace_text, selected_text) if replacement != selected_text: cursor = self.editor.textCursor() cursor.beginEditBlock() cursor.removeSelectedText() if not self.re_button.isChecked(): replacement = re.sub(r'\\(?![nrtf])(.)', r'\1', replacement) cursor.insertText(replacement) cursor.endEditBlock() if focus_replace_text: self.replace_text.setFocus() else: self.editor.setFocus()
python
def replace_find_selection(self, focus_replace_text=False): """Replace and find in the current selection""" if self.editor is not None: replace_text = to_text_string(self.replace_text.currentText()) search_text = to_text_string(self.search_text.currentText()) case = self.case_button.isChecked() words = self.words_button.isChecked() re_flags = re.MULTILINE if case else re.IGNORECASE|re.MULTILINE re_pattern = None if self.re_button.isChecked(): pattern = search_text else: pattern = re.escape(search_text) replace_text = re.escape(replace_text) if words: # match whole words only pattern = r'\b{pattern}\b'.format(pattern=pattern) # Check regexp before proceeding try: re_pattern = re.compile(pattern, flags=re_flags) # Check if replace_text can be substituted in re_pattern # Fixes issue #7177 re_pattern.sub(replace_text, '') except re.error as e: # Do nothing with an invalid regexp return selected_text = to_text_string(self.editor.get_selected_text()) replacement = re_pattern.sub(replace_text, selected_text) if replacement != selected_text: cursor = self.editor.textCursor() cursor.beginEditBlock() cursor.removeSelectedText() if not self.re_button.isChecked(): replacement = re.sub(r'\\(?![nrtf])(.)', r'\1', replacement) cursor.insertText(replacement) cursor.endEditBlock() if focus_replace_text: self.replace_text.setFocus() else: self.editor.setFocus()
[ "def", "replace_find_selection", "(", "self", ",", "focus_replace_text", "=", "False", ")", ":", "if", "self", ".", "editor", "is", "not", "None", ":", "replace_text", "=", "to_text_string", "(", "self", ".", "replace_text", ".", "currentText", "(", ")", ")"...
Replace and find in the current selection
[ "Replace", "and", "find", "in", "the", "current", "selection" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/findreplace.py#L542-L583
30,670
spyder-ide/spyder
spyder/widgets/findreplace.py
FindReplace.change_number_matches
def change_number_matches(self, current_match=0, total_matches=0): """Change number of match and total matches.""" if current_match and total_matches: matches_string = u"{} {} {}".format(current_match, _(u"of"), total_matches) self.number_matches_text.setText(matches_string) elif total_matches: matches_string = u"{} {}".format(total_matches, _(u"matches")) self.number_matches_text.setText(matches_string) else: self.number_matches_text.setText(_(u"no matches"))
python
def change_number_matches(self, current_match=0, total_matches=0): """Change number of match and total matches.""" if current_match and total_matches: matches_string = u"{} {} {}".format(current_match, _(u"of"), total_matches) self.number_matches_text.setText(matches_string) elif total_matches: matches_string = u"{} {}".format(total_matches, _(u"matches")) self.number_matches_text.setText(matches_string) else: self.number_matches_text.setText(_(u"no matches"))
[ "def", "change_number_matches", "(", "self", ",", "current_match", "=", "0", ",", "total_matches", "=", "0", ")", ":", "if", "current_match", "and", "total_matches", ":", "matches_string", "=", "u\"{} {} {}\"", ".", "format", "(", "current_match", ",", "_", "(...
Change number of match and total matches.
[ "Change", "number", "of", "match", "and", "total", "matches", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/findreplace.py#L585-L595
30,671
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.set_rich_text_font
def set_rich_text_font(self, font): """Set rich text mode font""" self.rich_text.set_font(font, fixed_font=self.get_plugin_font())
python
def set_rich_text_font(self, font): """Set rich text mode font""" self.rich_text.set_font(font, fixed_font=self.get_plugin_font())
[ "def", "set_rich_text_font", "(", "self", ",", "font", ")", ":", "self", ".", "rich_text", ".", "set_font", "(", "font", ",", "fixed_font", "=", "self", ".", "get_plugin_font", "(", ")", ")" ]
Set rich text mode font
[ "Set", "rich", "text", "mode", "font" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L328-L330
30,672
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.set_plain_text_font
def set_plain_text_font(self, font, color_scheme=None): """Set plain text mode font""" self.plain_text.set_font(font, color_scheme=color_scheme)
python
def set_plain_text_font(self, font, color_scheme=None): """Set plain text mode font""" self.plain_text.set_font(font, color_scheme=color_scheme)
[ "def", "set_plain_text_font", "(", "self", ",", "font", ",", "color_scheme", "=", "None", ")", ":", "self", ".", "plain_text", ".", "set_font", "(", "font", ",", "color_scheme", "=", "color_scheme", ")" ]
Set plain text mode font
[ "Set", "plain", "text", "mode", "font" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L332-L334
30,673
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.switch_to_plain_text
def switch_to_plain_text(self): """Switch to plain text mode""" self.rich_help = False self.plain_text.show() self.rich_text.hide() self.plain_text_action.setChecked(True)
python
def switch_to_plain_text(self): """Switch to plain text mode""" self.rich_help = False self.plain_text.show() self.rich_text.hide() self.plain_text_action.setChecked(True)
[ "def", "switch_to_plain_text", "(", "self", ")", ":", "self", ".", "rich_help", "=", "False", "self", ".", "plain_text", ".", "show", "(", ")", "self", ".", "rich_text", ".", "hide", "(", ")", "self", ".", "plain_text_action", ".", "setChecked", "(", "Tr...
Switch to plain text mode
[ "Switch", "to", "plain", "text", "mode" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L358-L363
30,674
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.switch_to_rich_text
def switch_to_rich_text(self): """Switch to rich text mode""" self.rich_help = True self.plain_text.hide() self.rich_text.show() self.rich_text_action.setChecked(True) self.show_source_action.setChecked(False)
python
def switch_to_rich_text(self): """Switch to rich text mode""" self.rich_help = True self.plain_text.hide() self.rich_text.show() self.rich_text_action.setChecked(True) self.show_source_action.setChecked(False)
[ "def", "switch_to_rich_text", "(", "self", ")", ":", "self", ".", "rich_help", "=", "True", "self", ".", "plain_text", ".", "hide", "(", ")", "self", ".", "rich_text", ".", "show", "(", ")", "self", ".", "rich_text_action", ".", "setChecked", "(", "True"...
Switch to rich text mode
[ "Switch", "to", "rich", "text", "mode" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L365-L371
30,675
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.set_plain_text
def set_plain_text(self, text, is_code): """Set plain text docs""" # text is coming from utils.dochelpers.getdoc if type(text) is dict: name = text['name'] if name: rst_title = ''.join(['='*len(name), '\n', name, '\n', '='*len(name), '\n\n']) else: rst_title = '' if text['argspec']: definition = ''.join(['Definition: ', name, text['argspec'], '\n']) else: definition = '' if text['note']: note = ''.join(['Type: ', text['note'], '\n\n----\n\n']) else: note = '' full_text = ''.join([rst_title, definition, note, text['docstring']]) else: full_text = text self.plain_text.set_text(full_text, is_code) self.save_text([self.plain_text.set_text, full_text, is_code])
python
def set_plain_text(self, text, is_code): """Set plain text docs""" # text is coming from utils.dochelpers.getdoc if type(text) is dict: name = text['name'] if name: rst_title = ''.join(['='*len(name), '\n', name, '\n', '='*len(name), '\n\n']) else: rst_title = '' if text['argspec']: definition = ''.join(['Definition: ', name, text['argspec'], '\n']) else: definition = '' if text['note']: note = ''.join(['Type: ', text['note'], '\n\n----\n\n']) else: note = '' full_text = ''.join([rst_title, definition, note, text['docstring']]) else: full_text = text self.plain_text.set_text(full_text, is_code) self.save_text([self.plain_text.set_text, full_text, is_code])
[ "def", "set_plain_text", "(", "self", ",", "text", ",", "is_code", ")", ":", "# text is coming from utils.dochelpers.getdoc\r", "if", "type", "(", "text", ")", "is", "dict", ":", "name", "=", "text", "[", "'name'", "]", "if", "name", ":", "rst_title", "=", ...
Set plain text docs
[ "Set", "plain", "text", "docs" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L373-L402
30,676
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.set_rich_text_html
def set_rich_text_html(self, html_text, base_url): """Set rich text""" self.rich_text.set_html(html_text, base_url) self.save_text([self.rich_text.set_html, html_text, base_url])
python
def set_rich_text_html(self, html_text, base_url): """Set rich text""" self.rich_text.set_html(html_text, base_url) self.save_text([self.rich_text.set_html, html_text, base_url])
[ "def", "set_rich_text_html", "(", "self", ",", "html_text", ",", "base_url", ")", ":", "self", ".", "rich_text", ".", "set_html", "(", "html_text", ",", "base_url", ")", "self", ".", "save_text", "(", "[", "self", ".", "rich_text", ".", "set_html", ",", ...
Set rich text
[ "Set", "rich", "text" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L404-L407
30,677
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.show_rich_text
def show_rich_text(self, text, collapse=False, img_path=''): """Show text in rich mode""" self.switch_to_plugin() self.switch_to_rich_text() context = generate_context(collapse=collapse, img_path=img_path, css_path=self.css_path) self.render_sphinx_doc(text, context)
python
def show_rich_text(self, text, collapse=False, img_path=''): """Show text in rich mode""" self.switch_to_plugin() self.switch_to_rich_text() context = generate_context(collapse=collapse, img_path=img_path, css_path=self.css_path) self.render_sphinx_doc(text, context)
[ "def", "show_rich_text", "(", "self", ",", "text", ",", "collapse", "=", "False", ",", "img_path", "=", "''", ")", ":", "self", ".", "switch_to_plugin", "(", ")", "self", ".", "switch_to_rich_text", "(", ")", "context", "=", "generate_context", "(", "colla...
Show text in rich mode
[ "Show", "text", "in", "rich", "mode" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L440-L446
30,678
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.show_plain_text
def show_plain_text(self, text): """Show text in plain mode""" self.switch_to_plugin() self.switch_to_plain_text() self.set_plain_text(text, is_code=False)
python
def show_plain_text(self, text): """Show text in plain mode""" self.switch_to_plugin() self.switch_to_plain_text() self.set_plain_text(text, is_code=False)
[ "def", "show_plain_text", "(", "self", ",", "text", ")", ":", "self", ".", "switch_to_plugin", "(", ")", "self", ".", "switch_to_plain_text", "(", ")", "self", ".", "set_plain_text", "(", "text", ",", "is_code", "=", "False", ")" ]
Show text in plain mode
[ "Show", "text", "in", "plain", "mode" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L448-L452
30,679
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.show_tutorial
def show_tutorial(self): """Show the Spyder tutorial in the Help plugin, opening it if needed""" self.switch_to_plugin() tutorial_path = get_module_source_path('spyder.plugins.help.utils') tutorial = osp.join(tutorial_path, 'tutorial.rst') text = open(tutorial).read() self.show_rich_text(text, collapse=True)
python
def show_tutorial(self): """Show the Spyder tutorial in the Help plugin, opening it if needed""" self.switch_to_plugin() tutorial_path = get_module_source_path('spyder.plugins.help.utils') tutorial = osp.join(tutorial_path, 'tutorial.rst') text = open(tutorial).read() self.show_rich_text(text, collapse=True)
[ "def", "show_tutorial", "(", "self", ")", ":", "self", ".", "switch_to_plugin", "(", ")", "tutorial_path", "=", "get_module_source_path", "(", "'spyder.plugins.help.utils'", ")", "tutorial", "=", "osp", ".", "join", "(", "tutorial_path", ",", "'tutorial.rst'", ")"...
Show the Spyder tutorial in the Help plugin, opening it if needed
[ "Show", "the", "Spyder", "tutorial", "in", "the", "Help", "plugin", "opening", "it", "if", "needed" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L455-L461
30,680
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.set_object_text
def set_object_text(self, text, force_refresh=False, ignore_unknown=False): """Set object analyzed by Help""" if (self.locked and not force_refresh): return self.switch_to_console_source() add_to_combo = True if text is None: text = to_text_string(self.combo.currentText()) add_to_combo = False found = self.show_help(text, ignore_unknown=ignore_unknown) if ignore_unknown and not found: return if add_to_combo: self.combo.add_text(text) if found: self.save_history() if self.dockwidget is not None: self.dockwidget.blockSignals(True) self.__eventually_raise_help(text, force=force_refresh) if self.dockwidget is not None: self.dockwidget.blockSignals(False)
python
def set_object_text(self, text, force_refresh=False, ignore_unknown=False): """Set object analyzed by Help""" if (self.locked and not force_refresh): return self.switch_to_console_source() add_to_combo = True if text is None: text = to_text_string(self.combo.currentText()) add_to_combo = False found = self.show_help(text, ignore_unknown=ignore_unknown) if ignore_unknown and not found: return if add_to_combo: self.combo.add_text(text) if found: self.save_history() if self.dockwidget is not None: self.dockwidget.blockSignals(True) self.__eventually_raise_help(text, force=force_refresh) if self.dockwidget is not None: self.dockwidget.blockSignals(False)
[ "def", "set_object_text", "(", "self", ",", "text", ",", "force_refresh", "=", "False", ",", "ignore_unknown", "=", "False", ")", ":", "if", "(", "self", ".", "locked", "and", "not", "force_refresh", ")", ":", "return", "self", ".", "switch_to_console_source...
Set object analyzed by Help
[ "Set", "object", "analyzed", "by", "Help" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L483-L507
30,681
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.set_editor_doc
def set_editor_doc(self, doc, force_refresh=False): """ Use the help plugin to show docstring dictionary computed with introspection plugin from the Editor plugin """ if (self.locked and not force_refresh): return self.switch_to_editor_source() self._last_editor_doc = doc self.object_edit.setText(doc['obj_text']) if self.rich_help: self.render_sphinx_doc(doc) else: self.set_plain_text(doc, is_code=False) if self.dockwidget is not None: self.dockwidget.blockSignals(True) self.__eventually_raise_help(doc['docstring'], force=force_refresh) if self.dockwidget is not None: self.dockwidget.blockSignals(False)
python
def set_editor_doc(self, doc, force_refresh=False): """ Use the help plugin to show docstring dictionary computed with introspection plugin from the Editor plugin """ if (self.locked and not force_refresh): return self.switch_to_editor_source() self._last_editor_doc = doc self.object_edit.setText(doc['obj_text']) if self.rich_help: self.render_sphinx_doc(doc) else: self.set_plain_text(doc, is_code=False) if self.dockwidget is not None: self.dockwidget.blockSignals(True) self.__eventually_raise_help(doc['docstring'], force=force_refresh) if self.dockwidget is not None: self.dockwidget.blockSignals(False)
[ "def", "set_editor_doc", "(", "self", ",", "doc", ",", "force_refresh", "=", "False", ")", ":", "if", "(", "self", ".", "locked", "and", "not", "force_refresh", ")", ":", "return", "self", ".", "switch_to_editor_source", "(", ")", "self", ".", "_last_edito...
Use the help plugin to show docstring dictionary computed with introspection plugin from the Editor plugin
[ "Use", "the", "help", "plugin", "to", "show", "docstring", "dictionary", "computed", "with", "introspection", "plugin", "from", "the", "Editor", "plugin" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L509-L529
30,682
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.toggle_plain_text
def toggle_plain_text(self, checked): """Toggle plain text docstring""" if checked: self.docstring = checked self.switch_to_plain_text() self.force_refresh() self.set_option('rich_mode', not checked)
python
def toggle_plain_text(self, checked): """Toggle plain text docstring""" if checked: self.docstring = checked self.switch_to_plain_text() self.force_refresh() self.set_option('rich_mode', not checked)
[ "def", "toggle_plain_text", "(", "self", ",", "checked", ")", ":", "if", "checked", ":", "self", ".", "docstring", "=", "checked", "self", ".", "switch_to_plain_text", "(", ")", "self", ".", "force_refresh", "(", ")", "self", ".", "set_option", "(", "'rich...
Toggle plain text docstring
[ "Toggle", "plain", "text", "docstring" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L567-L573
30,683
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.toggle_show_source
def toggle_show_source(self, checked): """Toggle show source code""" if checked: self.switch_to_plain_text() self.docstring = not checked self.force_refresh() self.set_option('rich_mode', not checked)
python
def toggle_show_source(self, checked): """Toggle show source code""" if checked: self.switch_to_plain_text() self.docstring = not checked self.force_refresh() self.set_option('rich_mode', not checked)
[ "def", "toggle_show_source", "(", "self", ",", "checked", ")", ":", "if", "checked", ":", "self", ".", "switch_to_plain_text", "(", ")", "self", ".", "docstring", "=", "not", "checked", "self", ".", "force_refresh", "(", ")", "self", ".", "set_option", "("...
Toggle show source code
[ "Toggle", "show", "source", "code" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L576-L582
30,684
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.toggle_rich_text
def toggle_rich_text(self, checked): """Toggle between sphinxified docstrings or plain ones""" if checked: self.docstring = not checked self.switch_to_rich_text() self.set_option('rich_mode', checked)
python
def toggle_rich_text(self, checked): """Toggle between sphinxified docstrings or plain ones""" if checked: self.docstring = not checked self.switch_to_rich_text() self.set_option('rich_mode', checked)
[ "def", "toggle_rich_text", "(", "self", ",", "checked", ")", ":", "if", "checked", ":", "self", ".", "docstring", "=", "not", "checked", "self", ".", "switch_to_rich_text", "(", ")", "self", ".", "set_option", "(", "'rich_mode'", ",", "checked", ")" ]
Toggle between sphinxified docstrings or plain ones
[ "Toggle", "between", "sphinxified", "docstrings", "or", "plain", "ones" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L585-L590
30,685
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.toggle_auto_import
def toggle_auto_import(self, checked): """Toggle automatic import feature""" self.combo.validate_current_text() self.set_option('automatic_import', checked) self.force_refresh()
python
def toggle_auto_import(self, checked): """Toggle automatic import feature""" self.combo.validate_current_text() self.set_option('automatic_import', checked) self.force_refresh()
[ "def", "toggle_auto_import", "(", "self", ",", "checked", ")", ":", "self", ".", "combo", ".", "validate_current_text", "(", ")", "self", ".", "set_option", "(", "'automatic_import'", ",", "checked", ")", "self", ".", "force_refresh", "(", ")" ]
Toggle automatic import feature
[ "Toggle", "automatic", "import", "feature" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L593-L597
30,686
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help._update_lock_icon
def _update_lock_icon(self): """Update locked state icon""" icon = ima.icon('lock') if self.locked else ima.icon('lock_open') self.locked_button.setIcon(icon) tip = _("Unlock") if self.locked else _("Lock") self.locked_button.setToolTip(tip)
python
def _update_lock_icon(self): """Update locked state icon""" icon = ima.icon('lock') if self.locked else ima.icon('lock_open') self.locked_button.setIcon(icon) tip = _("Unlock") if self.locked else _("Lock") self.locked_button.setToolTip(tip)
[ "def", "_update_lock_icon", "(", "self", ")", ":", "icon", "=", "ima", ".", "icon", "(", "'lock'", ")", "if", "self", ".", "locked", "else", "ima", ".", "icon", "(", "'lock_open'", ")", "self", ".", "locked_button", ".", "setIcon", "(", "icon", ")", ...
Update locked state icon
[ "Update", "locked", "state", "icon" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L608-L613
30,687
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.get_shell
def get_shell(self): """ Return shell which is currently bound to Help, or another running shell if it has been terminated """ if (not hasattr(self.shell, 'get_doc') or (hasattr(self.shell, 'is_running') and not self.shell.is_running())): self.shell = None if self.main.ipyconsole is not None: shell = self.main.ipyconsole.get_current_shellwidget() if shell is not None and shell.kernel_client is not None: self.shell = shell if self.shell is None: self.shell = self.internal_shell return self.shell
python
def get_shell(self): """ Return shell which is currently bound to Help, or another running shell if it has been terminated """ if (not hasattr(self.shell, 'get_doc') or (hasattr(self.shell, 'is_running') and not self.shell.is_running())): self.shell = None if self.main.ipyconsole is not None: shell = self.main.ipyconsole.get_current_shellwidget() if shell is not None and shell.kernel_client is not None: self.shell = shell if self.shell is None: self.shell = self.internal_shell return self.shell
[ "def", "get_shell", "(", "self", ")", ":", "if", "(", "not", "hasattr", "(", "self", ".", "shell", ",", "'get_doc'", ")", "or", "(", "hasattr", "(", "self", ".", "shell", ",", "'is_running'", ")", "and", "not", "self", ".", "shell", ".", "is_running"...
Return shell which is currently bound to Help, or another running shell if it has been terminated
[ "Return", "shell", "which", "is", "currently", "bound", "to", "Help", "or", "another", "running", "shell", "if", "it", "has", "been", "terminated" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L619-L634
30,688
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help.render_sphinx_doc
def render_sphinx_doc(self, doc, context=None, css_path=CSS_PATH): """Transform doc string dictionary to HTML and show it""" # Math rendering option could have changed if self.main.editor is not None: fname = self.main.editor.get_current_filename() dname = osp.dirname(fname) else: dname = '' self._sphinx_thread.render(doc, context, self.get_option('math'), dname, css_path=self.css_path)
python
def render_sphinx_doc(self, doc, context=None, css_path=CSS_PATH): """Transform doc string dictionary to HTML and show it""" # Math rendering option could have changed if self.main.editor is not None: fname = self.main.editor.get_current_filename() dname = osp.dirname(fname) else: dname = '' self._sphinx_thread.render(doc, context, self.get_option('math'), dname, css_path=self.css_path)
[ "def", "render_sphinx_doc", "(", "self", ",", "doc", ",", "context", "=", "None", ",", "css_path", "=", "CSS_PATH", ")", ":", "# Math rendering option could have changed\r", "if", "self", ".", "main", ".", "editor", "is", "not", "None", ":", "fname", "=", "s...
Transform doc string dictionary to HTML and show it
[ "Transform", "doc", "string", "dictionary", "to", "HTML", "and", "show", "it" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L636-L645
30,689
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help._on_sphinx_thread_html_ready
def _on_sphinx_thread_html_ready(self, html_text): """Set our sphinx documentation based on thread result""" self._sphinx_thread.wait() self.set_rich_text_html(html_text, QUrl.fromLocalFile(self.css_path))
python
def _on_sphinx_thread_html_ready(self, html_text): """Set our sphinx documentation based on thread result""" self._sphinx_thread.wait() self.set_rich_text_html(html_text, QUrl.fromLocalFile(self.css_path))
[ "def", "_on_sphinx_thread_html_ready", "(", "self", ",", "html_text", ")", ":", "self", ".", "_sphinx_thread", ".", "wait", "(", ")", "self", ".", "set_rich_text_html", "(", "html_text", ",", "QUrl", ".", "fromLocalFile", "(", "self", ".", "css_path", ")", "...
Set our sphinx documentation based on thread result
[ "Set", "our", "sphinx", "documentation", "based", "on", "thread", "result" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L647-L650
30,690
spyder-ide/spyder
spyder/plugins/help/plugin.py
Help._on_sphinx_thread_error_msg
def _on_sphinx_thread_error_msg(self, error_msg): """ Display error message on Sphinx rich text failure""" self._sphinx_thread.wait() self.plain_text_action.setChecked(True) sphinx_ver = programs.get_module_version('sphinx') QMessageBox.critical(self, _('Help'), _("The following error occured when calling " "<b>Sphinx %s</b>. <br>Incompatible Sphinx " "version or doc string decoding failed." "<br><br>Error message:<br>%s" ) % (sphinx_ver, error_msg))
python
def _on_sphinx_thread_error_msg(self, error_msg): """ Display error message on Sphinx rich text failure""" self._sphinx_thread.wait() self.plain_text_action.setChecked(True) sphinx_ver = programs.get_module_version('sphinx') QMessageBox.critical(self, _('Help'), _("The following error occured when calling " "<b>Sphinx %s</b>. <br>Incompatible Sphinx " "version or doc string decoding failed." "<br><br>Error message:<br>%s" ) % (sphinx_ver, error_msg))
[ "def", "_on_sphinx_thread_error_msg", "(", "self", ",", "error_msg", ")", ":", "self", ".", "_sphinx_thread", ".", "wait", "(", ")", "self", ".", "plain_text_action", ".", "setChecked", "(", "True", ")", "sphinx_ver", "=", "programs", ".", "get_module_version", ...
Display error message on Sphinx rich text failure
[ "Display", "error", "message", "on", "Sphinx", "rich", "text", "failure" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/plugin.py#L652-L663
30,691
spyder-ide/spyder
spyder/plugins/editor/api/decoration.py
TextDecoration.contains_cursor
def contains_cursor(self, cursor): """ Checks if the textCursor is in the decoration. :param cursor: The text cursor to test :type cursor: QtGui.QTextCursor :returns: True if the cursor is over the selection """ start = self.cursor.selectionStart() end = self.cursor.selectionEnd() if cursor.atBlockEnd(): end -= 1 return start <= cursor.position() <= end
python
def contains_cursor(self, cursor): """ Checks if the textCursor is in the decoration. :param cursor: The text cursor to test :type cursor: QtGui.QTextCursor :returns: True if the cursor is over the selection """ start = self.cursor.selectionStart() end = self.cursor.selectionEnd() if cursor.atBlockEnd(): end -= 1 return start <= cursor.position() <= end
[ "def", "contains_cursor", "(", "self", ",", "cursor", ")", ":", "start", "=", "self", ".", "cursor", ".", "selectionStart", "(", ")", "end", "=", "self", ".", "cursor", ".", "selectionEnd", "(", ")", "if", "cursor", ".", "atBlockEnd", "(", ")", ":", ...
Checks if the textCursor is in the decoration. :param cursor: The text cursor to test :type cursor: QtGui.QTextCursor :returns: True if the cursor is over the selection
[ "Checks", "if", "the", "textCursor", "is", "in", "the", "decoration", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/api/decoration.py#L117-L130
30,692
spyder-ide/spyder
spyder/plugins/editor/api/decoration.py
TextDecoration.set_as_underlined
def set_as_underlined(self, color=Qt.blue): """ Underlines the text. :param color: underline color. """ self.format.setUnderlineStyle( QTextCharFormat.SingleUnderline) self.format.setUnderlineColor(color)
python
def set_as_underlined(self, color=Qt.blue): """ Underlines the text. :param color: underline color. """ self.format.setUnderlineStyle( QTextCharFormat.SingleUnderline) self.format.setUnderlineColor(color)
[ "def", "set_as_underlined", "(", "self", ",", "color", "=", "Qt", ".", "blue", ")", ":", "self", ".", "format", ".", "setUnderlineStyle", "(", "QTextCharFormat", ".", "SingleUnderline", ")", "self", ".", "format", ".", "setUnderlineColor", "(", "color", ")" ...
Underlines the text. :param color: underline color.
[ "Underlines", "the", "text", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/api/decoration.py#L190-L198
30,693
spyder-ide/spyder
spyder/plugins/editor/api/decoration.py
TextDecoration.set_as_spell_check
def set_as_spell_check(self, color=Qt.blue): """ Underlines text as a spellcheck error. :param color: Underline color :type color: QtGui.QColor """ self.format.setUnderlineStyle( QTextCharFormat.SpellCheckUnderline) self.format.setUnderlineColor(color)
python
def set_as_spell_check(self, color=Qt.blue): """ Underlines text as a spellcheck error. :param color: Underline color :type color: QtGui.QColor """ self.format.setUnderlineStyle( QTextCharFormat.SpellCheckUnderline) self.format.setUnderlineColor(color)
[ "def", "set_as_spell_check", "(", "self", ",", "color", "=", "Qt", ".", "blue", ")", ":", "self", ".", "format", ".", "setUnderlineStyle", "(", "QTextCharFormat", ".", "SpellCheckUnderline", ")", "self", ".", "format", ".", "setUnderlineColor", "(", "color", ...
Underlines text as a spellcheck error. :param color: Underline color :type color: QtGui.QColor
[ "Underlines", "text", "as", "a", "spellcheck", "error", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/api/decoration.py#L200-L209
30,694
spyder-ide/spyder
spyder/plugins/editor/api/decoration.py
TextDecoration.set_as_error
def set_as_error(self, color=Qt.red): """ Highlights text as a syntax error. :param color: Underline color :type color: QtGui.QColor """ self.format.setUnderlineStyle( QTextCharFormat.WaveUnderline) self.format.setUnderlineColor(color)
python
def set_as_error(self, color=Qt.red): """ Highlights text as a syntax error. :param color: Underline color :type color: QtGui.QColor """ self.format.setUnderlineStyle( QTextCharFormat.WaveUnderline) self.format.setUnderlineColor(color)
[ "def", "set_as_error", "(", "self", ",", "color", "=", "Qt", ".", "red", ")", ":", "self", ".", "format", ".", "setUnderlineStyle", "(", "QTextCharFormat", ".", "WaveUnderline", ")", "self", ".", "format", ".", "setUnderlineColor", "(", "color", ")" ]
Highlights text as a syntax error. :param color: Underline color :type color: QtGui.QColor
[ "Highlights", "text", "as", "a", "syntax", "error", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/api/decoration.py#L211-L220
30,695
spyder-ide/spyder
spyder/plugins/editor/api/decoration.py
TextDecoration.set_as_warning
def set_as_warning(self, color=QColor("orange")): """ Highlights text as a syntax warning. :param color: Underline color :type color: QtGui.QColor """ self.format.setUnderlineStyle( QTextCharFormat.WaveUnderline) self.format.setUnderlineColor(color)
python
def set_as_warning(self, color=QColor("orange")): """ Highlights text as a syntax warning. :param color: Underline color :type color: QtGui.QColor """ self.format.setUnderlineStyle( QTextCharFormat.WaveUnderline) self.format.setUnderlineColor(color)
[ "def", "set_as_warning", "(", "self", ",", "color", "=", "QColor", "(", "\"orange\"", ")", ")", ":", "self", ".", "format", ".", "setUnderlineStyle", "(", "QTextCharFormat", ".", "WaveUnderline", ")", "self", ".", "format", ".", "setUnderlineColor", "(", "co...
Highlights text as a syntax warning. :param color: Underline color :type color: QtGui.QColor
[ "Highlights", "text", "as", "a", "syntax", "warning", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/api/decoration.py#L222-L231
30,696
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
ThreadManager.close_threads
def close_threads(self, parent): """Close threads associated to parent_id""" logger.debug("Call ThreadManager's 'close_threads'") if parent is None: # Closing all threads self.pending_threads = [] threadlist = [] for threads in list(self.started_threads.values()): threadlist += threads else: parent_id = id(parent) self.pending_threads = [(_th, _id) for (_th, _id) in self.pending_threads if _id != parent_id] threadlist = self.started_threads.get(parent_id, []) for thread in threadlist: logger.debug("Waiting for thread %r to finish" % thread) while thread.isRunning(): # We can't terminate thread safely, so we simply wait... QApplication.processEvents()
python
def close_threads(self, parent): """Close threads associated to parent_id""" logger.debug("Call ThreadManager's 'close_threads'") if parent is None: # Closing all threads self.pending_threads = [] threadlist = [] for threads in list(self.started_threads.values()): threadlist += threads else: parent_id = id(parent) self.pending_threads = [(_th, _id) for (_th, _id) in self.pending_threads if _id != parent_id] threadlist = self.started_threads.get(parent_id, []) for thread in threadlist: logger.debug("Waiting for thread %r to finish" % thread) while thread.isRunning(): # We can't terminate thread safely, so we simply wait... QApplication.processEvents()
[ "def", "close_threads", "(", "self", ",", "parent", ")", ":", "logger", ".", "debug", "(", "\"Call ThreadManager's 'close_threads'\"", ")", "if", "parent", "is", "None", ":", "# Closing all threads\r", "self", ".", "pending_threads", "=", "[", "]", "threadlist", ...
Close threads associated to parent_id
[ "Close", "threads", "associated", "to", "parent_id" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L93-L112
30,697
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
ThreadManager.add_thread
def add_thread(self, checker, end_callback, source_code, parent): """Add thread to queue""" parent_id = id(parent) thread = AnalysisThread(self, checker, source_code) self.end_callbacks[id(thread)] = end_callback self.pending_threads.append((thread, parent_id)) logger.debug("Added thread %r to queue" % thread) QTimer.singleShot(50, self.update_queue)
python
def add_thread(self, checker, end_callback, source_code, parent): """Add thread to queue""" parent_id = id(parent) thread = AnalysisThread(self, checker, source_code) self.end_callbacks[id(thread)] = end_callback self.pending_threads.append((thread, parent_id)) logger.debug("Added thread %r to queue" % thread) QTimer.singleShot(50, self.update_queue)
[ "def", "add_thread", "(", "self", ",", "checker", ",", "end_callback", ",", "source_code", ",", "parent", ")", ":", "parent_id", "=", "id", "(", "parent", ")", "thread", "=", "AnalysisThread", "(", "self", ",", "checker", ",", "source_code", ")", "self", ...
Add thread to queue
[ "Add", "thread", "to", "queue" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L119-L126
30,698
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
FileInfo.text_changed
def text_changed(self): """Editor's text has changed""" self.default = False self.editor.document().changed_since_autosave = True self.text_changed_at.emit(self.filename, self.editor.get_position('cursor'))
python
def text_changed(self): """Editor's text has changed""" self.default = False self.editor.document().changed_since_autosave = True self.text_changed_at.emit(self.filename, self.editor.get_position('cursor'))
[ "def", "text_changed", "(", "self", ")", ":", "self", ".", "default", "=", "False", "self", ".", "editor", ".", "document", "(", ")", ".", "changed_since_autosave", "=", "True", "self", ".", "text_changed_at", ".", "emit", "(", "self", ".", "filename", "...
Editor's text has changed
[ "Editor", "s", "text", "has", "changed" ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L197-L202
30,699
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
FileInfo.bookmarks_changed
def bookmarks_changed(self): """Bookmarks list has changed.""" bookmarks = self.editor.get_bookmarks() if self.editor.bookmarks != bookmarks: self.editor.bookmarks = bookmarks self.sig_save_bookmarks.emit(self.filename, repr(bookmarks))
python
def bookmarks_changed(self): """Bookmarks list has changed.""" bookmarks = self.editor.get_bookmarks() if self.editor.bookmarks != bookmarks: self.editor.bookmarks = bookmarks self.sig_save_bookmarks.emit(self.filename, repr(bookmarks))
[ "def", "bookmarks_changed", "(", "self", ")", ":", "bookmarks", "=", "self", ".", "editor", ".", "get_bookmarks", "(", ")", "if", "self", ".", "editor", ".", "bookmarks", "!=", "bookmarks", ":", "self", ".", "editor", ".", "bookmarks", "=", "bookmarks", ...
Bookmarks list has changed.
[ "Bookmarks", "list", "has", "changed", "." ]
f76836ce1b924bcc4efd3f74f2960d26a4e528e0
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L229-L234