Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def get_character(self, position, offset=0):
position = self.get_position(position) + offset
cursor = self.textCursor()
cursor.movePosition(QTextCursor.End)
if position < cursor.position():
cursor.setPosition(positio... | [
"Return character at *position* with the given offset."
] |
Please provide a description of the function:def get_current_word_and_position(self, completion=False):
cursor = self.textCursor()
if cursor.hasSelection():
# Removes the selection and moves the cursor to the left side
# of the selection: this is required to be ab... | [
"Return current word, i.e. word at cursor position,\r\n and the start position"
] |
Please provide a description of the function:def get_current_word(self, completion=False):
ret = self.get_current_word_and_position(completion)
if ret is not None:
return ret[0] | [
"Return current word, i.e. word at cursor position"
] |
Please provide a description of the function:def get_current_line(self):
cursor = self.textCursor()
cursor.select(QTextCursor.BlockUnderCursor)
return to_text_string(cursor.selectedText()) | [
"Return current line's text"
] |
Please provide a description of the function:def get_line_at(self, coordinates):
cursor = self.cursorForPosition(coordinates)
cursor.select(QTextCursor.BlockUnderCursor)
return to_text_string(cursor.selectedText()).replace(u'\u2029', '') | [
"Return line at *coordinates* (QPoint)"
] |
Please provide a description of the function:def get_word_at(self, coordinates):
cursor = self.cursorForPosition(coordinates)
cursor.select(QTextCursor.WordUnderCursor)
return to_text_string(cursor.selectedText()) | [
"Return word at *coordinates* (QPoint)"
] |
Please provide a description of the function:def get_block_indentation(self, block_nb):
text = to_text_string(self.document().findBlockByNumber(block_nb).text())
text = text.replace("\t", " "*self.tab_stop_width_spaces)
return len(text)-len(text.lstrip()) | [
"Return line indentation (character number)"
] |
Please provide a description of the function:def get_selection_bounds(self):
cursor = self.textCursor()
start, end = cursor.selectionStart(), cursor.selectionEnd()
block_start = self.document().findBlock(start)
block_end = self.document().findBlock(end)
return sort... | [
"Return selection bounds (block numbers)"
] |
Please provide a description of the function:def get_selected_text(self):
return to_text_string(self.textCursor().selectedText()).replace(u"\u2029",
self.get_line_separator()) | [
"\r\n Return text selected by current text cursor, converted in unicode\r\n\r\n Replace the unicode line separator character \\u2029 by\r\n the line separator characters returned by get_line_separator\r\n "
] |
Please provide a description of the function:def replace(self, text, pattern=None):
cursor = self.textCursor()
cursor.beginEditBlock()
if pattern is not None:
seltxt = to_text_string(cursor.selectedText())
cursor.removeSelectedText()
if pattern is not ... | [
"Replace selected text by *text*\r\n If *pattern* is not None, replacing selected text using regular\r\n expression text substitution"
] |
Please provide a description of the function:def find_multiline_pattern(self, regexp, cursor, findflag):
pattern = to_text_string(regexp.pattern())
text = to_text_string(self.toPlainText())
try:
regobj = re.compile(pattern)
except sre_constants.error:
... | [
"Reimplement QTextDocument's find method\r\n\r\n Add support for *multiline* regular expressions"
] |
Please provide a description of the function:def find_text(self, text, changed=True, forward=True, case=False,
words=False, regexp=False):
cursor = self.textCursor()
findflag = QTextDocument.FindFlag()
if not forward:
findflag = findflag | QTextDocu... | [
"Find text"
] |
Please provide a description of the function:def get_number_matches(self, pattern, source_text='', case=False,
regexp=False):
pattern = to_text_string(pattern)
if not pattern:
return 0
if not regexp:
pattern = re.escape(pattern... | [
"Get the number of matches for the searched text."
] |
Please provide a description of the function:def get_match_number(self, pattern, case=False, regexp=False):
position = self.textCursor().position()
source_text = self.get_text(position_from='sof', position_to=position)
match_number = self.get_number_matches(pattern,
... | [
"Get number of the match for the searched text."
] |
Please provide a description of the function:def mouseReleaseEvent(self, event):
self.QT_CLASS.mouseReleaseEvent(self, event)
text = self.get_line_at(event.pos())
if get_error_match(text) and not self.has_selected_text():
if self.go_to_error is not None:
... | [
"Go to error"
] |
Please provide a description of the function:def mouseMoveEvent(self, event):
text = self.get_line_at(event.pos())
if get_error_match(text):
if not self.__cursor_changed:
QApplication.setOverrideCursor(QCursor(Qt.PointingHandCursor))
self.__curs... | [
"Show Pointing Hand Cursor on error messages"
] |
Please provide a description of the function:def leaveEvent(self, event):
if self.__cursor_changed:
QApplication.restoreOverrideCursor()
self.__cursor_changed = False
self.QT_CLASS.leaveEvent(self, event) | [
"If cursor has not been restored yet, do it now"
] |
Please provide a description of the function:def show_object_info(self, text, call=False, force=False):
text = to_text_string(text)
# Show docstring
help_enabled = self.help_enabled or force
if force and self.help is not None:
self.help.dockwidget.setVisible(... | [
"Show signature calltip and/or docstring in the Help plugin"
] |
Please provide a description of the function:def create_history_filename(self):
if self.history_filename and not osp.isfile(self.history_filename):
try:
encoding.writelines(self.INITHISTORY, self.history_filename)
except EnvironmentError:
pa... | [
"Create history_filename with INITHISTORY if it doesn't exist."
] |
Please provide a description of the function:def add_to_history(self, command):
command = to_text_string(command)
if command in ['', '\n'] or command.startswith('Traceback'):
return
if command.endswith('\n'):
command = command[:-1]
self.histidx = N... | [
"Add command to history"
] |
Please provide a description of the function:def browse_history(self, backward):
if self.is_cursor_before('eol') and self.hist_wholeline:
self.hist_wholeline = False
tocursor = self.get_current_line_to_cursor()
text, self.histidx = self.find_in_history(tocursor, self.hi... | [
"Browse history"
] |
Please provide a description of the function:def find_in_history(self, tocursor, start_idx, backward):
if start_idx is None:
start_idx = len(self.history)
# Finding text in history
step = -1 if backward else 1
idx = start_idx
if len(tocursor) == 0 or s... | [
"Find text 'tocursor' in history, from index 'start_idx'"
] |
Please provide a description of the function:def keyevent_to_keyseq(self, event):
self.keyPressEvent(event)
event.accept()
return self.keySequence() | [
"Return a QKeySequence representation of the provided QKeyEvent."
] |
Please provide a description of the function:def setText(self, sequence):
self.setToolTip(sequence)
super(ShortcutLineEdit, self).setText(sequence) | [
"Qt method extension."
] |
Please provide a description of the function:def set_text(self, text):
text = text.strip()
new_text = self.text() + text
self.setText(new_text) | [
"Set the filter text."
] |
Please provide a description of the function:def keyPressEvent(self, event):
key = event.key()
if key in [Qt.Key_Up]:
self._parent.previous_row()
elif key in [Qt.Key_Down]:
self._parent.next_row()
elif key in [Qt.Key_Enter, Qt.Key_Return]:
... | [
"Qt Override."
] |
Please provide a description of the function:def setup(self):
# Widgets
icon_info = HelperToolButton()
icon_info.setIcon(get_std_icon('MessageBoxInformation'))
layout_icon_info = QVBoxLayout()
layout_icon_info.setContentsMargins(0, 0, 0, 0)
layout_icon_inf... | [
"Setup the ShortcutEditor with the provided arguments.",
"\r\n QToolButton {\r\n margin:1px;\r\n border: 0px solid grey;\r\n padding:0px;\r\n border-radius: 0px;\r\n }"
] |
Please provide a description of the function:def event(self, event):
if event.type() in (QEvent.Shortcut, QEvent.ShortcutOverride):
return True
else:
return super(ShortcutEditor, self).event(event) | [
"Qt method override."
] |
Please provide a description of the function:def keyPressEvent(self, event):
event_key = event.key()
if not event_key or event_key == Qt.Key_unknown:
return
if len(self._qsequences) == 4:
# QKeySequence accepts a maximum of 4 different sequences.
... | [
"Qt method override."
] |
Please provide a description of the function:def check_conflicts(self):
conflicts = []
if len(self._qsequences) == 0:
return conflicts
new_qsequence = self.new_qsequence
for shortcut in self.shortcuts:
shortcut_qsequence = QKeySequence.fromString... | [
"Check shortcuts for conflicts."
] |
Please provide a description of the function:def check_singlekey(self):
if len(self._qsequences) == 0:
return True
else:
keystr = self._qsequences[0]
valid_single_keys = (EDITOR_SINGLE_KEYS if
self.context == 'editor' e... | [
"Check if the first sub-sequence of the new key sequence is valid."
] |
Please provide a description of the function:def update_warning(self):
new_qsequence = self.new_qsequence
new_sequence = self.new_sequence
self.text_new_sequence.setText(
new_qsequence.toString(QKeySequence.NativeText))
conflicts = self.check_conflicts()
... | [
"Update the warning label, buttons state and sequence text."
] |
Please provide a description of the function:def set_sequence_from_str(self, sequence):
self._qsequences = [QKeySequence(s) for s in sequence.split(', ')]
self.update_warning() | [
"\r\n This is a convenience method to set the new QKeySequence of the\r\n shortcut editor from a string.\r\n "
] |
Please provide a description of the function:def set_sequence_to_default(self):
sequence = CONF.get_default(
'shortcuts', "{}/{}".format(self.context, self.name))
self._qsequences = sequence.split(', ')
self.update_warning() | [
"Set the new sequence to the default value defined in the config."
] |
Please provide a description of the function:def accept_override(self):
conflicts = self.check_conflicts()
if conflicts:
for shortcut in conflicts:
shortcut.key = ''
self.accept() | [
"Unbind all conflicted shortcuts, and accept the new one"
] |
Please provide a description of the function:def current_index(self):
i = self._parent.proxy_model.mapToSource(self._parent.currentIndex())
return i | [
"Get the currently selected index in the parent table view."
] |
Please provide a description of the function:def sortByName(self):
self.shortcuts = sorted(self.shortcuts,
key=lambda x: x.context+'/'+x.name)
self.reset() | [
"Qt Override."
] |
Please provide a description of the function:def data(self, index, role=Qt.DisplayRole):
row = index.row()
if not index.isValid() or not (0 <= row < len(self.shortcuts)):
return to_qvariant()
shortcut = self.shortcuts[row]
key = shortcut.key
column =... | [
"Qt Override."
] |
Please provide a description of the function:def headerData(self, section, orientation, role=Qt.DisplayRole):
if role == Qt.TextAlignmentRole:
if orientation == Qt.Horizontal:
return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
return to_qvariant(int(... | [
"Qt Override."
] |
Please provide a description of the function:def setData(self, index, value, role=Qt.EditRole):
if index.isValid() and 0 <= index.row() < len(self.shortcuts):
shortcut = self.shortcuts[index.row()]
column = index.column()
text = from_qvariant(value, str)
... | [
"Qt Override."
] |
Please provide a description of the function:def update_search_letters(self, text):
self.letters = text
names = [shortcut.name for shortcut in self.shortcuts]
results = get_search_scores(text, names, template='<b>{0}</b>')
self.normal_text, self.rich_text, self.scores = zip... | [
"Update search letters with text input in search box."
] |
Please provide a description of the function:def set_filter(self, text):
self.pattern = get_search_regex(text)
if self.pattern:
self._parent.setSortingEnabled(False)
else:
self._parent.setSortingEnabled(True)
self.invalidateFilter() | [
"Set regular expression for filter."
] |
Please provide a description of the function:def filterAcceptsRow(self, row_num, parent):
model = self.sourceModel()
name = model.row(row_num).name
r = re.search(self.pattern, name)
if r is None:
return False
else:
return True | [
"Qt override.\r\n\r\n Reimplemented from base class to allow the use of custom filtering.\r\n "
] |
Please provide a description of the function:def focusOutEvent(self, e):
self.source_model.update_active_row()
super(ShortcutsTable, self).focusOutEvent(e) | [
"Qt Override."
] |
Please provide a description of the function:def focusInEvent(self, e):
super(ShortcutsTable, self).focusInEvent(e)
self.selectRow(self.currentIndex().row()) | [
"Qt Override."
] |
Please provide a description of the function:def adjust_cells(self):
self.resizeColumnsToContents()
fm = self.horizontalHeader().fontMetrics()
names = [fm.width(s.name + ' '*9) for s in self.source_model.shortcuts]
self.setColumnWidth(NAME, max(names))
self.horizon... | [
"Adjust column size based on contents."
] |
Please provide a description of the function:def load_shortcuts(self):
shortcuts = []
for context, name, keystr in iter_shortcuts():
shortcut = Shortcut(context, name, keystr)
shortcuts.append(shortcut)
shortcuts = sorted(shortcuts, key=lambda x: x.context+... | [
"Load shortcuts and assign to table model."
] |
Please provide a description of the function:def check_shortcuts(self):
conflicts = []
for index, sh1 in enumerate(self.source_model.shortcuts):
if index == len(self.source_model.shortcuts)-1:
break
if str(sh1.key) == '':
continue
... | [
"Check shortcuts for conflicts."
] |
Please provide a description of the function:def save_shortcuts(self):
self.check_shortcuts()
for shortcut in self.source_model.shortcuts:
shortcut.save() | [
"Save shortcuts from table model."
] |
Please provide a description of the function:def show_editor(self):
index = self.proxy_model.mapToSource(self.currentIndex())
row, column = index.row(), index.column()
shortcuts = self.source_model.shortcuts
context = shortcuts[row].context
name = shortcuts[row].na... | [
"Create, setup and display the shortcut editor dialog."
] |
Please provide a description of the function:def set_regex(self, regex=None, reset=False):
if reset:
text = ''
else:
text = self.finder.text().replace(' ', '').lower()
self.proxy_model.set_filter(text)
self.source_model.update_search_letters(text... | [
"Update the regex text for the shortcut finder."
] |
Please provide a description of the function:def next_row(self):
row = self.currentIndex().row()
rows = self.proxy_model.rowCount()
if row + 1 == rows:
row = -1
self.selectRow(row + 1) | [
"Move to next row from currently selected row."
] |
Please provide a description of the function:def previous_row(self):
row = self.currentIndex().row()
rows = self.proxy_model.rowCount()
if row == 0:
row = rows
self.selectRow(row - 1) | [
"Move to previous row from currently selected row."
] |
Please provide a description of the function:def keyPressEvent(self, event):
key = event.key()
if key in [Qt.Key_Enter, Qt.Key_Return]:
self.show_editor()
elif key in [Qt.Key_Tab]:
self.finder.setFocus()
elif key in [Qt.Key_Backtab]:
s... | [
"Qt Override."
] |
Please provide a description of the function:def reset_to_default(self):
reset = QMessageBox.warning(self, _("Shortcuts reset"),
_("Do you want to reset "
"to default values?"),
QMessageBo... | [
"Reset to default values of the shortcuts making a confirmation."
] |
Please provide a description of the function:def get_color_scheme(name):
name = name.lower()
scheme = {}
for key in COLOR_SCHEME_KEYS:
try:
scheme[key] = CONF.get('appearance', name+'/'+key)
except:
scheme[key] = CONF.get('appearance', 'spyder/'+key)
... | [
"Get a color scheme from config using its name"
] |
Please provide a description of the function:def make_python_patterns(additional_keywords=[], additional_builtins=[]):
"Strongly inspired from idlelib.ColorDelegator.make_pat"
kwlist = keyword.kwlist + additional_keywords
builtinlist = [str(name) for name in dir(builtins)
if not name.... | [
"[^\"\\\\]*((\\\\.|\"(?!\"\"))[^\"\\\\]*)*(",
"[^\"\\\\]*((\\\\.|\"(?!\"\"))[^\"\\\\]*)*(\\\\)?(?!"
] |
Please provide a description of the function:def get_code_cell_name(text):
name = text.strip().lstrip("#% ")
if name.startswith("<codecell>"):
name = name[10:].lstrip()
elif name.startswith("In["):
name = name[2:]
if name.endswith("]:"):
name = name[:-1]
... | [
"Returns a code cell name from a code cell comment."
] |
Please provide a description of the function:def make_generic_c_patterns(keywords, builtins,
instance=None, define=None, comment=None):
"Strongly inspired from idlelib.ColorDelegator.make_pat"
kw = r"\b" + any("keyword", keywords.split()) + r"\b"
builtin = r"\b" + any("builti... | [] |
Please provide a description of the function:def make_fortran_patterns():
"Strongly inspired from idlelib.ColorDelegator.make_pat"
kwstr = 'access action advance allocatable allocate apostrophe assign assignment associate asynchronous backspace bind blank blockdata call case character class close common compl... | [] |
Please provide a description of the function:def make_nsis_patterns():
"Strongly inspired from idlelib.ColorDelegator.make_pat"
kwstr1 = 'Abort AddBrandingImage AddSize AllowRootDirInstall AllowSkipFiles AutoCloseWindow BGFont BGGradient BrandingText BringToFront Call CallInstDLL Caption ClearErrors Completed... | [] |
Please provide a description of the function:def make_gettext_patterns():
"Strongly inspired from idlelib.ColorDelegator.make_pat"
kwstr = 'msgid msgstr'
kw = r"\b" + any("keyword", kwstr.split()) + r"\b"
fuzzy = any("builtin", [r"#,[^\n]*"])
links = any("normal", [r"#:[^\n]*"])
comment = ... | [] |
Please provide a description of the function:def make_yaml_patterns():
"Strongly inspired from sublime highlighter "
kw = any("keyword", [r":|>|-|\||\[|\]|[A-Za-z][\w\s\-\_ ]+(?=:)"])
links = any("normal", [r"#:[^\n]*"])
comment = any("comment", [r"#[^\n]*"])
number = any("number",
... | [] |
Please provide a description of the function:def make_html_patterns():
tags = any("builtin", [r"<", r"[\?/]?>", r"(?<=<).*?(?=[ >])"])
keywords = any("keyword", [r" [\w:-]*?(?==)"])
string = any("string", [r'".*?"'])
comment = any("comment", [r"<!--.*?-->"])
multiline_comment_start = any(... | [
"Strongly inspired from idlelib.ColorDelegator.make_pat "
] |
Please provide a description of the function:def guess_pygments_highlighter(filename):
try:
from pygments.lexers import get_lexer_for_filename, get_lexer_by_name
except Exception:
return TextSH
root, ext = os.path.splitext(filename)
if ext in custom_extension_lexer_mapping:
... | [
"Factory to generate syntax highlighter for the given filename.\r\n\r\n If a syntax highlighter is not available for a particular file, this\r\n function will attempt to generate one based on the lexers in Pygments. If\r\n Pygments is not available or does not have an appropriate lexer, TextSH\r\n will... |
Please provide a description of the function:def highlightBlock(self, text):
self.highlight_block(text)
# Process blocks for fold detection
current_block = self.currentBlock()
previous_block = self._find_prev_non_blank_block(current_block)
if self.editor:
... | [
"\r\n Highlights a block of text. Please do not override, this method.\r\n Instead you should implement\r\n :func:`spyder.utils.syntaxhighplighters.SyntaxHighlighter.highlight_block`.\r\n\r\n :param text: text to highlight.\r\n "
] |
Please provide a description of the function:def highlight_spaces(self, text, offset=0):
flags_text = self.document().defaultTextOption().flags()
show_blanks = flags_text & QTextOption.ShowTabsAndSpaces
if show_blanks:
format_leading = self.formats.get("leading", None)... | [
"\r\n Make blank space less apparent by setting the foreground alpha.\r\n This only has an effect when 'Show blank space' is turned on.\r\n Derived classes could call this function at the end of\r\n highlightBlock().\r\n "
] |
Please provide a description of the function:def highlight_block(self, text):
text = to_text_string(text)
prev_state = tbh.get_state(self.currentBlock().previous())
if prev_state == self.INSIDE_DQ3STRING:
offset = -4
text = r'""" '+text
elif prev_s... | [
"Implement specific highlight for Python."
] |
Please provide a description of the function:def highlight_block(self, text):
text = to_text_string(text)
inside_comment = tbh.get_state(self.currentBlock().previous()) == self.INSIDE_COMMENT
self.setFormat(0, len(text),
self.formats["comment" if inside_comme... | [
"Implement highlight specific for C/C++."
] |
Please provide a description of the function:def highlight_block(self, text):
text = to_text_string(text)
self.setFormat(0, len(text), self.formats["normal"])
match = self.PROG.search(text)
index = 0
while match:
for key, value in list(match.... | [
"Implement highlight specific for Fortran."
] |
Please provide a description of the function:def highlight_block(self, text):
text = to_text_string(text)
if text.startswith(("c", "C")):
self.setFormat(0, len(text), self.formats["comment"])
self.highlight_spaces(text)
else:
FortranSH.highligh... | [
"Implement highlight specific for Fortran77."
] |
Please provide a description of the function:def highlight_block(self, text):
text = to_text_string(text)
if text.startswith("+++"):
self.setFormat(0, len(text), self.formats["keyword"])
elif text.startswith("---"):
self.setFormat(0, len(text), self.formats... | [
"Implement highlight specific Diff/Patch files."
] |
Please provide a description of the function:def highlight_block(self, text):
text = to_text_string(text)
previous_state = tbh.get_state(self.currentBlock().previous())
if previous_state == self.COMMENT:
self.setFormat(0, len(text), self.formats["comment"])
... | [
"Implement highlight specific for CSS and HTML."
] |
Please provide a description of the function:def make_charlist(self):
def worker_output(worker, output, error):
self._charlist = output
if error is None and output:
self._allow_highlight = True
self.rehighlight()
... | [
"Parses the complete text and stores format for each character.",
"Worker finished callback."
] |
Please provide a description of the function:def _make_charlist(self, tokens, tokmap, formats):
def _get_fmt(typ):
# Exact matches first
if typ in tokmap:
return tokmap[typ]
# Partial (parent-> child) matches
for key... | [
"\r\n Parses the complete text and stores format for each character.\r\n\r\n Uses the attached lexer to parse into a list of tokens and Pygments\r\n token types. Then breaks tokens into individual letters, each with a\r\n Spyder token type attached. Stores this list as self._charlist.\... |
Please provide a description of the function:def highlightBlock(self, text):
# Note that an undefined blockstate is equal to -1, so the first block
# will have the correct behaviour of starting at 0.
if self._allow_highlight:
start = self.previousBlockState() + 1
... | [
" Actually highlight the block"
] |
Please provide a description of the function:def get_submodules(mod):
def catch_exceptions(module):
pass
try:
m = __import__(mod)
submodules = [mod]
submods = pkgutil.walk_packages(m.__path__, m.__name__ + '.',
catch_exceptions... | [
"Get all submodules of a given module"
] |
Please provide a description of the function:def get_preferred_submodules():
# Path to the modules database
modules_path = get_conf_path('db')
# Modules database
modules_db = PickleShareDB(modules_path)
if 'submodules' in modules_db:
return modules_db['submodules']
sub... | [
"\r\n Get all submodules of the main scientific modules and others of our\r\n interest\r\n "
] |
Please provide a description of the function:def is_stable_version(version):
if not isinstance(version, tuple):
version = version.split('.')
last_part = version[-1]
if not re.search(r'[a-zA-Z]', last_part):
return True
else:
return False | [
"\r\n Return true if version is stable, i.e. with letters in the final component.\r\n\r\n Stable version examples: ``1.2``, ``1.3.4``, ``1.0.5``.\r\n Non-stable version examples: ``1.3.4beta``, ``0.1.0rc1``, ``3.0.0dev0``.\r\n "
] |
Please provide a description of the function:def use_dev_config_dir(use_dev_config_dir=USE_DEV_CONFIG_DIR):
if use_dev_config_dir is not None:
if use_dev_config_dir.lower() in {'false', '0'}:
use_dev_config_dir = False
else:
use_dev_config_dir = DEV or not is_stable_versio... | [
"Return whether the dev configuration directory should used."
] |
Please provide a description of the function:def debug_print(*message):
warnings.warn("debug_print is deprecated; use the logging module instead.")
if get_debug_level():
ss = STDOUT
if PY3:
# This is needed after restarting and using debug_print
for m in messa... | [
"Output debug messages to stdout"
] |
Please provide a description of the function:def get_home_dir():
try:
# expanduser() returns a raw byte string which needs to be
# decoded with the codec that the OS is using to represent
# file paths.
path = encoding.to_unicode_from_fs(osp.expanduser('~'))
except Exc... | [
"\r\n Return user home directory\r\n "
] |
Please provide a description of the function:def get_clean_conf_dir():
if sys.platform.startswith("win"):
current_user = ''
else:
current_user = '-' + str(getpass.getuser())
conf_dir = osp.join(str(tempfile.gettempdir()),
'pytest-spyder{0!s}'.format(curr... | [
"\r\n Return the path to a temp clean configuration dir, for tests and safe mode.\r\n "
] |
Please provide a description of the function:def get_conf_path(filename=None):
# Define conf_dir
if running_under_pytest() or SAFE_MODE:
# Use clean config dir if running tests or the user requests it.
conf_dir = get_clean_conf_dir()
elif sys.platform.startswith('linux'):
... | [
"Return absolute path to the config file with the specified filename."
] |
Please provide a description of the function:def get_module_path(modname):
return osp.abspath(osp.dirname(sys.modules[modname].__file__)) | [
"Return module *modname* base path"
] |
Please provide a description of the function:def get_module_data_path(modname, relpath=None, attr_name='DATAPATH'):
datapath = getattr(sys.modules[modname], attr_name, '')
if datapath:
return datapath
else:
datapath = get_module_path(modname)
parentdir = osp.join(datapath... | [
"Return module *modname* data path\r\n Note: relpath is ignored if module has an attribute named *attr_name*\r\n \r\n Handles py2exe/cx_Freeze distributions"
] |
Please provide a description of the function:def get_module_source_path(modname, basename=None):
srcpath = get_module_path(modname)
parentdir = osp.join(srcpath, osp.pardir)
if osp.isfile(parentdir):
# Parent directory is not a directory but the 'library.zip' file:
# this is eithe... | [
"Return module *modname* source path\r\n If *basename* is specified, return *modname.basename* path where \r\n *modname* is a package containing the module *basename*\r\n \r\n *basename* is a filename (not a module name), so it must include the\r\n file extension: .py or .pyw\r\n \r\n Handles p... |
Please provide a description of the function:def get_image_path(name, default="not_found.png"):
for img_path in IMG_PATH:
full_path = osp.join(img_path, name)
if osp.isfile(full_path):
return osp.abspath(full_path)
if default is not None:
img_path = osp.join(get_m... | [
"Return image absolute path"
] |
Please provide a description of the function:def get_available_translations():
locale_path = get_module_data_path("spyder", relpath="locale",
attr_name='LOCALEPATH')
listdir = os.listdir(locale_path)
langs = [d for d in listdir if osp.isdir(osp.join(locale_pa... | [
"\r\n List available translations for spyder based on the folders found in the\r\n locale folder. This function checks if LANGUAGE_CODES contain the same\r\n information that is found in the 'locale' folder to ensure that when a new\r\n language is added, LANGUAGE_CODES is updated.\r\n "
] |
Please provide a description of the function:def get_interface_language():
# Solves issue #3627
try:
locale_language = locale.getdefaultlocale()[0]
except ValueError:
locale_language = DEFAULT_LANGUAGE
# Tests expect English as the interface language
if running_under... | [
"\r\n If Spyder has a translation available for the locale language, it will\r\n return the version provided by Spyder adjusted for language subdifferences,\r\n otherwise it will return DEFAULT_LANGUAGE.\r\n\r\n Example:\r\n 1.) Spyder provides ('en', 'de', 'fr', 'es' 'hu' and 'pt_BR'), if the\r\n ... |
Please provide a description of the function:def load_lang_conf():
if osp.isfile(LANG_FILE):
with open(LANG_FILE, 'r') as f:
lang = f.read()
else:
lang = get_interface_language()
save_lang_conf(lang)
# Save language again if it's been disabled
if lang.... | [
"\r\n Load language setting from language config file if it exists, otherwise\r\n try to use the local settings if Spyder provides a translation, or\r\n return the default if no translation provided.\r\n "
] |
Please provide a description of the function:def get_translation(modname, dirname=None):
if dirname is None:
dirname = modname
def translate_dumb(x):
if not is_unicode(x):
return to_text_string(x, "utf-8")
return x
locale_path = get_module_data_... | [
"Return translation callback for module *modname*",
"Dumb function to not use translations."
] |
Please provide a description of the function:def reset_config_files():
print("*** Reset Spyder settings to defaults ***", file=STDERR)
for fname in SAVED_CONFIG_FILES:
cfg_fname = get_conf_path(fname)
if osp.isfile(cfg_fname) or osp.islink(cfg_fname):
os.remove(cfg_fname)
... | [
"Remove all config files"
] |
Please provide a description of the function:def register_plugin(self):
ipyconsole = self.main.ipyconsole
treewidget = self.fileexplorer.treewidget
self.main.add_dockwidget(self)
self.fileexplorer.sig_open_file.connect(self.main.open_file)
self.register_widget_sh... | [
"Register plugin in Spyder's main window"
] |
Please provide a description of the function:def refresh_plugin(self, new_path=None, force_current=True):
self.fileexplorer.treewidget.update_history(new_path)
self.fileexplorer.treewidget.refresh(new_path,
force_current=force_current) | [
"Refresh explorer widget"
] |
Please provide a description of the function:def is_type_text_string(obj):
if PY2:
# Python 2
return type(obj) in [str, unicode]
else:
# Python 3
return type(obj) in [str, bytes] | [
"Return True if `obj` is type text string, False if it is anything else,\r\n like an instance of a class that extends the basestring class."
] |
Please provide a description of the function:def to_binary_string(obj, encoding=None):
if PY2:
# Python 2
if encoding is None:
return str(obj)
else:
return obj.encode(encoding)
else:
# Python 3
return bytes(obj, 'utf-8' if encoding i... | [
"Convert `obj` to binary string (bytes in Python 3, str in Python 2)"
] |
Please provide a description of the function:def save_history(self):
open(self.LOG_PATH, 'w').write("\n".join( \
[to_text_string(self.pydocbrowser.url_combo.itemText(index))
for index in range(self.pydocbrowser.url_combo.count())])) | [
"Save history to a text file in user home directory"
] |
Please provide a description of the function:def visibility_changed(self, enable):
super(SpyderPluginWidget, self).visibility_changed(enable)
if enable and not self.pydocbrowser.is_server_running():
self.pydocbrowser.initialize() | [
"DockWidget visibility has changed"
] |
Please provide a description of the function:def get_focus_widget(self):
self.pydocbrowser.url_combo.lineEdit().selectAll()
return self.pydocbrowser.url_combo | [
"\r\n Return the widget to give focus to when\r\n this plugin's dockwidget is raised on top-level\r\n "
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.