Code stringlengths 103 85.9k | Summary listlengths 0 94 |
|---|---|
Please provide a description of the function:def path_manager_callback(self):
from spyder.widgets.pathmanager import PathManager
self.remove_path_from_sys_path()
project_path = self.projects.get_pythonpath()
dialog = PathManager(self, self.path, project_path,
... | [
"Spyder path manager"
] |
Please provide a description of the function:def pythonpath_changed(self):
self.remove_path_from_sys_path()
self.project_path = self.projects.get_pythonpath()
self.add_path_to_sys_path()
self.sig_pythonpath_changed.emit() | [
"Projects PYTHONPATH contribution has changed"
] |
Please provide a description of the function:def apply_settings(self):
qapp = QApplication.instance()
# Set 'gtk+' as the default theme in Gtk-based desktops
# Fixes Issue 2036
if is_gtk_desktop() and ('GTK+' in QStyleFactory.keys()):
try:
qapp... | [
"Apply settings changed in 'Preferences' dialog box"
] |
Please provide a description of the function:def apply_panes_settings(self):
for plugin in (self.widgetlist + self.thirdparty_plugins):
features = plugin.FEATURES
if CONF.get('main', 'vertical_dockwidget_titlebars'):
features = features | QDockWidget.DockWid... | [
"Update dockwidgets features settings"
] |
Please provide a description of the function:def apply_statusbar_settings(self):
show_status_bar = CONF.get('main', 'show_status_bar')
self.statusBar().setVisible(show_status_bar)
if show_status_bar:
for widget, name in ((self.mem_status, 'memory_usage'),
... | [
"Update status bar widgets settings"
] |
Please provide a description of the function:def edit_preferences(self):
from spyder.preferences.configdialog import ConfigDialog
dlg = ConfigDialog(self)
dlg.size_change.connect(self.set_prefs_size)
if self.prefs_dialog_size is not None:
dlg.resize(self.prefs_... | [
"Edit Spyder preferences"
] |
Please provide a description of the function:def register_shortcut(self, qaction_or_qshortcut, context, name,
add_sc_to_tip=False):
self.shortcut_data.append( (qaction_or_qshortcut, context,
name, add_sc_to_tip) ) | [
"\r\n Register QAction or QShortcut to Spyder main application,\r\n with shortcut (context, name, default)\r\n "
] |
Please provide a description of the function:def apply_shortcuts(self):
toberemoved = []
for index, (qobject, context, name,
add_sc_to_tip) in enumerate(self.shortcut_data):
keyseq = QKeySequence( get_shortcut(context, name) )
try:
... | [
"Apply shortcuts settings to all widgets/plugins"
] |
Please provide a description of the function:def reset_spyder(self):
answer = QMessageBox.warning(self, _("Warning"),
_("Spyder will restart and reset to default settings: <br><br>"
"Do you want to continue?"),
QMessageBox.Yes | QMessageBox.No)
if ... | [
"\r\n Quit and reset Spyder and then Restart application.\r\n "
] |
Please provide a description of the function:def restart(self, reset=False):
# Get start path to use in restart script
spyder_start_directory = get_module_path('spyder')
restart_script = osp.join(spyder_start_directory, 'app', 'restart.py')
# Get any initial argument pass... | [
"\r\n Quit and Restart Spyder application.\r\n\r\n If reset True it allows to reset spyder on restart.\r\n "
] |
Please provide a description of the function:def show_tour(self, index):
self.maximize_dockwidget(restore=True)
frames = self.tours_available[index]
self.tour.set_tour(index, frames, self)
self.tour.start_tour() | [
"Show interactive tour."
] |
Please provide a description of the function:def open_fileswitcher(self, symbol=False):
if self.fileswitcher is not None and \
self.fileswitcher.is_visible:
self.fileswitcher.hide()
self.fileswitcher.is_visible = False
return
if symbol:
... | [
"Open file list management dialog box."
] |
Please provide a description of the function:def add_to_fileswitcher(self, plugin, tabs, data, icon):
if self.fileswitcher is None:
from spyder.widgets.fileswitcher import FileSwitcher
self.fileswitcher = FileSwitcher(self, plugin, tabs, data, icon)
else:
... | [
"Add a plugin to the File Switcher."
] |
Please provide a description of the function:def _check_updates_ready(self):
from spyder.widgets.helperwidgets import MessageCheckBox
# feedback` = False is used on startup, so only positive feedback is
# given. `feedback` = True is used when after startup (when using the
... | [
"Called by WorkerUpdates when ready"
] |
Please provide a description of the function:def check_updates(self, startup=False):
from spyder.workers.updates import WorkerUpdates
# Disable check_updates_action while the thread is working
self.check_updates_action.setDisabled(True)
if self.thread_updates is not Non... | [
"\r\n Check for spyder updates on github releases using a QThread.\r\n "
] |
Please provide a description of the function:def _set(self, section, option, value, verbose):
if not self.has_section(section):
self.add_section( section )
if not is_text_string(value):
value = repr( value )
if verbose:
print('%s[ %s ] = %s' % ... | [
"\r\n Private set method\r\n "
] |
Please provide a description of the function:def _save(self):
# See Issue 1086 and 1242 for background on why this
# method contains all the exception handling.
fname = self.filename()
def _write_file(fname):
if PY2:
# Python 2
... | [
"\r\n Save config into the associated .ini file\r\n "
] |
Please provide a description of the function:def filename(self):
# Needs to be done this way to be used by the project config.
# To fix on a later PR
self._filename = getattr(self, '_filename', None)
self._root_path = getattr(self, '_root_path', None)
if self._fi... | [
"Defines the name of the configuration file to use."
] |
Please provide a description of the function:def _filename_global(self):
if self.subfolder is None:
config_file = osp.join(get_home_dir(), '.%s.ini' % self.name)
return config_file
else:
folder = get_conf_path()
# Save defaults in a "defaul... | [
"Create a .ini filename located in user home directory.\r\n This .ini files stores the global spyder preferences.\r\n "
] |
Please provide a description of the function:def set_version(self, version='0.0.0', save=True):
self.set(self.DEFAULT_SECTION_NAME, 'version', version, save=save) | [
"Set configuration (not application!) version"
] |
Please provide a description of the function:def load_from_ini(self):
try:
if PY2:
# Python 2
fname = self.filename()
if osp.isfile(fname):
try:
with codecs.open(fname, encoding='utf-8') as c... | [
"\r\n Load config from the associated .ini file\r\n "
] |
Please provide a description of the function:def _load_old_defaults(self, old_version):
old_defaults = cp.ConfigParser()
if check_version(old_version, '3.0.0', '<='):
path = get_module_source_path('spyder')
else:
path = osp.dirname(self.filename())
... | [
"Read old defaults"
] |
Please provide a description of the function:def _save_new_defaults(self, defaults, new_version, subfolder):
new_defaults = DefaultsConfig(name='defaults-'+new_version,
subfolder=subfolder)
if not osp.isfile(new_defaults.filename()):
new_de... | [
"Save new defaults"
] |
Please provide a description of the function:def _update_defaults(self, defaults, old_version, verbose=False):
old_defaults = self._load_old_defaults(old_version)
for section, options in defaults:
for option in options:
new_value = options[ option ]
... | [
"Update defaults after a change in version"
] |
Please provide a description of the function:def _remove_deprecated_options(self, old_version):
old_defaults = self._load_old_defaults(old_version)
for section in old_defaults.sections():
for option, _ in old_defaults.items(section, raw=self.raw):
if self.get_de... | [
"\r\n Remove options which are present in the .ini file but not in defaults\r\n "
] |
Please provide a description of the function:def set_as_defaults(self):
self.defaults = []
for section in self.sections():
secdict = {}
for option, value in self.items(section, raw=self.raw):
secdict[option] = value
self.defaults.append... | [
"\r\n Set defaults from the current config\r\n "
] |
Please provide a description of the function:def reset_to_defaults(self, save=True, verbose=False, section=None):
for sec, options in self.defaults:
if section == None or section == sec:
for option in options:
value = options[ option ]
... | [
"\r\n Reset config to Default values\r\n "
] |
Please provide a description of the function:def _check_section_option(self, section, option):
if section is None:
section = self.DEFAULT_SECTION_NAME
elif not is_text_string(section):
raise RuntimeError("Argument 'section' must be a string")
if not is_text... | [
"\r\n Private method to check section and option types\r\n "
] |
Please provide a description of the function:def get_default(self, section, option):
section = self._check_section_option(section, option)
for sec, options in self.defaults:
if sec == section:
if option in options:
return options[ option ]
... | [
"\r\n Get Default value for a given (section, option)\r\n -> useful for type checking in 'get' method\r\n "
] |
Please provide a description of the function:def get(self, section, option, default=NoDefault):
section = self._check_section_option(section, option)
if not self.has_section(section):
if default is NoDefault:
raise cp.NoSectionError(section)
else:... | [
"\r\n Get an option\r\n section=None: attribute a default section name\r\n default: default value (if not specified, an exception\r\n will be raised if option doesn't exist)\r\n "
] |
Please provide a description of the function:def set_default(self, section, option, default_value):
section = self._check_section_option(section, option)
for sec, options in self.defaults:
if sec == section:
options[ option ] = default_value | [
"\r\n Set Default value for a given (section, option)\r\n -> called when a new (section, option) is set and no default exists\r\n "
] |
Please provide a description of the function:def set(self, section, option, value, verbose=False, save=True):
section = self._check_section_option(section, option)
default_value = self.get_default(section, option)
if default_value is NoDefault:
# This let us save correc... | [
"\r\n Set an option\r\n section=None: attribute a default section name\r\n "
] |
Please provide a description of the function:def get_temp_dir(suffix=None):
to_join = [tempfile.gettempdir()]
if os.name == 'nt':
to_join.append('spyder')
else:
username = encoding.to_unicode_from_fs(getuser())
to_join.append('spyder-' + username)
if suffix is no... | [
"\r\n Return temporary Spyder directory, checking previously that it exists.\r\n "
] |
Please provide a description of the function:def is_program_installed(basename):
for path in os.environ["PATH"].split(os.pathsep):
abspath = osp.join(path, basename)
if osp.isfile(abspath):
return abspath | [
"\r\n Return program absolute path if installed in PATH.\r\n\r\n Otherwise, return None\r\n "
] |
Please provide a description of the function:def find_program(basename):
names = [basename]
if os.name == 'nt':
# Windows platforms
extensions = ('.exe', '.bat', '.cmd')
if not basename.endswith(extensions):
names = [basename+ext for ext in extensions]+[basename]
... | [
"\r\n Find program in PATH and return absolute path\r\n\r\n Try adding .exe or .bat to basename on Windows platforms\r\n (return None if not found)\r\n "
] |
Please provide a description of the function:def alter_subprocess_kwargs_by_platform(**kwargs):
kwargs.setdefault('close_fds', os.name == 'posix')
if os.name == 'nt':
CONSOLE_CREATION_FLAGS = 0 # Default value
# See: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684863%28... | [
"\r\n Given a dict, populate kwargs to create a generally\r\n useful default setup for running subprocess processes\r\n on different platforms. For example, `close_fds` is\r\n set on posix and creation of a new console window is\r\n disabled on Windows.\r\n\r\n This function will alter the given k... |
Please provide a description of the function:def run_shell_command(cmdstr, **subprocess_kwargs):
if 'shell' in subprocess_kwargs and not subprocess_kwargs['shell']:
raise ProgramError(
'The "shell" kwarg may be omitted, but if '
'provided it must be True.')
els... | [
"\r\n Execute the given shell command.\r\n \r\n Note that *args and **kwargs will be passed to the subprocess call.\r\n\r\n If 'shell' is given in subprocess_kwargs it must be True,\r\n otherwise ProgramError will be raised.\r\n .\r\n If 'executable' is not given in subprocess_kwargs, it will\r... |
Please provide a description of the function:def run_program(program, args=None, **subprocess_kwargs):
if 'shell' in subprocess_kwargs and subprocess_kwargs['shell']:
raise ProgramError(
"This function is only for non-shell programs, "
"use run_shell_command() inste... | [
"\r\n Run program in a separate process.\r\n\r\n NOTE: returns the process object created by\r\n `subprocess.Popen()`. This can be used with\r\n `proc.communicate()` for example.\r\n\r\n If 'shell' appears in the kwargs, it must be False,\r\n otherwise ProgramError will be raised.\r\n\r\n If on... |
Please provide a description of the function:def start_file(filename):
from qtpy.QtCore import QUrl
from qtpy.QtGui import QDesktopServices
# We need to use setUrl instead of setPath because this is the only
# cross-platform way to open external files. setPath fails completely on
# Mac ... | [
"\r\n Generalized os.startfile for all platforms supported by Qt\r\n\r\n This function is simply wrapping QDesktopServices.openUrl\r\n\r\n Returns True if successfull, otherwise returns False.\r\n "
] |
Please provide a description of the function:def python_script_exists(package=None, module=None):
assert module is not None
try:
if package is None:
path = imp.find_module(module)[1]
else:
path = osp.join(imp.find_module(package)[1], module)+'.py'
except ... | [
"\r\n Return absolute path if Python script exists (otherwise, return None)\r\n package=None -> module is in sys.path (standard library modules)\r\n "
] |
Please provide a description of the function:def run_python_script(package=None, module=None, args=[], p_args=[]):
assert module is not None
assert isinstance(args, (tuple, list)) and isinstance(p_args, (tuple, list))
path = python_script_exists(package, module)
run_program(sys.executable, p_a... | [
"\r\n Run Python script in a separate process\r\n package=None -> module is in sys.path (standard library modules)\r\n "
] |
Please provide a description of the function:def shell_split(text):
assert is_text_string(text) # in case a QString is passed...
pattern = r'(\s+|(?<!\\)".*?(?<!\\)"|(?<!\\)\'.*?(?<!\\)\')'
out = []
for token in re.split(pattern, text):
if token.strip():
out.append(token... | [
"\r\n Split the string `text` using shell-like syntax\r\n\r\n This avoids breaking single/double-quoted strings (e.g. containing\r\n strings with spaces). This function is almost equivalent to the shlex.split\r\n function (see standard library `shlex`) except that it is supporting\r\n unicode strings... |
Please provide a description of the function:def get_python_args(fname, python_args, interact, debug, end_args):
p_args = []
if python_args is not None:
p_args += python_args.split()
if interact:
p_args.append('-i')
if debug:
p_args.extend(['-m', 'pdb'])
if fnam... | [
"Construct Python interpreter arguments"
] |
Please provide a description of the function:def run_python_script_in_terminal(fname, wdir, args, interact,
debug, python_args, executable=None):
if executable is None:
executable = get_python_executable()
# If fname or python_exe contains spaces, it can't b... | [
"\r\n Run Python script in an external system terminal.\r\n\r\n :str wdir: working directory, may be empty.\r\n "
] |
Please provide a description of the function:def check_version(actver, version, cmp_op):
if isinstance(actver, tuple):
actver = '.'.join([str(i) for i in actver])
# Hacks needed so that LooseVersion understands that (for example)
# version = '3.0.0' is in fact bigger than actver = '3.0.0... | [
"\r\n Check version string of an active module against a required version.\r\n\r\n If dev/prerelease tags result in TypeError for string-number comparison,\r\n it is assumed that the dependency is satisfied.\r\n Users on dev branches are responsible for keeping their own packages up to\r\n date.\r\n ... |
Please provide a description of the function:def is_module_installed(module_name, version=None, installed_version=None,
interpreter=None):
if interpreter:
if osp.isfile(interpreter) and ('python' in interpreter):
checkver = inspect.getsource(check_version)
... | [
"\r\n Return True if module *module_name* is installed\r\n\r\n If version is not None, checking module version\r\n (module must have an attribute named '__version__')\r\n\r\n version may starts with =, >=, > or < to specify the exact requirement ;\r\n multiple conditions may be separated by ';' (e.g.... |
Please provide a description of the function:def is_python_interpreter_valid_name(filename):
pattern = r'.*python(\d\.?\d*)?(w)?(.exe)?$'
if re.match(pattern, filename, flags=re.I) is None:
return False
else:
return True | [
"Check that the python interpreter file has a valid name."
] |
Please provide a description of the function:def is_python_interpreter(filename):
real_filename = os.path.realpath(filename) # To follow symlink if existent
if (not osp.isfile(real_filename) or
not is_python_interpreter_valid_name(filename)):
return False
elif is_pythonw(filenam... | [
"Evaluate wether a file is a python interpreter or not."
] |
Please provide a description of the function:def is_pythonw(filename):
pattern = r'.*python(\d\.?\d*)?w(.exe)?$'
if re.match(pattern, filename, flags=re.I) is None:
return False
else:
return True | [
"Check that the python interpreter has 'pythonw'."
] |
Please provide a description of the function:def check_python_help(filename):
try:
proc = run_program(filename, ["-h"])
output = to_text_string(proc.communicate()[0])
valid = ("Options and arguments (and corresponding environment "
"variables)")
if 'usage... | [
"Check that the python interpreter can execute help."
] |
Please provide a description of the function:def sizeHint(self):
fm = QFontMetrics(self.editor.font())
size_hint = QSize(fm.height(), fm.height())
if size_hint.width() > 16:
size_hint.setWidth(16)
return size_hint | [
"Override Qt method.\n\n Returns the widget size hint (based on the editor font size).\n "
] |
Please provide a description of the function:def _draw_breakpoint_icon(self, top, painter, icon_name):
rect = QRect(0, top, self.sizeHint().width(),
self.sizeHint().height())
try:
icon = self.icons[icon_name]
except KeyError as e:
debug_print... | [
"Draw the given breakpoint pixmap.\n\n Args:\n top (int): top of the line to draw the breakpoint icon.\n painter (QPainter)\n icon_name (srt): key of icon to draw (see: self.icons)\n "
] |
Please provide a description of the function:def paintEvent(self, event):
super(DebuggerPanel, self).paintEvent(event)
painter = QPainter(self)
painter.fillRect(event.rect(), self.editor.sideareas_color)
for top, line_number, block in self.editor.visible_blocks:
if ... | [
"Override Qt method.\n\n Paint breakpoints icons.\n "
] |
Please provide a description of the function:def mousePressEvent(self, event):
line_number = self.editor.get_linenumber_from_mouse_event(event)
shift = event.modifiers() & Qt.ShiftModifier
self.editor.debugger.toogle_breakpoint(line_number,
... | [
"Override Qt method\n\n Add/remove breakpoints by single click.\n "
] |
Please provide a description of the function:def mouseMoveEvent(self, event):
self.line_number_hint = self.editor.get_linenumber_from_mouse_event(
event)
self.update() | [
"Override Qt method.\n\n Draw semitransparent breakpoint hint.\n "
] |
Please provide a description of the function:def on_state_changed(self, state):
if state:
self.editor.sig_breakpoints_changed.connect(self.repaint)
self.editor.sig_debug_stop.connect(self.set_current_line_arrow)
self.editor.sig_debug_stop[()].connect(self.stop_clean)... | [
"Change visibility and connect/disconnect signal.\n\n Args:\n state (bool): Activate/deactivate.\n "
] |
Please provide a description of the function:def handle_qbytearray(obj, encoding):
if isinstance(obj, QByteArray):
obj = obj.data()
return to_text_string(obj, encoding=encoding) | [
"Qt/Python2/3 compatibility helper."
] |
Please provide a description of the function:def sleeping_func(arg, secs=10, result_queue=None):
import time
time.sleep(secs)
if result_queue is not None:
result_queue.put(arg)
else:
return arg | [
"This methods illustrates how the workers can be used."
] |
Please provide a description of the function:def start(self):
if not self._started:
self.sig_started.emit(self)
self._started = True | [
"Start the worker (emits sig_started signal with worker as arg)."
] |
Please provide a description of the function:def _start(self):
error = None
output = None
try:
output = self.func(*self.args, **self.kwargs)
except Exception as err:
error = err
if not self._is_finished:
self.sig_finished.emit(self, ... | [
"Start process worker for given method args and kwargs."
] |
Please provide a description of the function:def _get_encoding(self):
enco = 'utf-8'
# Currently only cp1252 is allowed?
if WIN:
import ctypes
codepage = to_text_string(ctypes.cdll.kernel32.GetACP())
# import locale
# locale.getpreferred... | [
"Return the encoding/codepage to use."
] |
Please provide a description of the function:def _set_environment(self, environ):
if environ:
q_environ = self._process.processEnvironment()
for k, v in environ.items():
q_environ.insert(k, v)
self._process.setProcessEnvironment(q_environ) | [
"Set the environment on the QProcess."
] |
Please provide a description of the function:def _partial(self):
raw_stdout = self._process.readAllStandardOutput()
stdout = handle_qbytearray(raw_stdout, self._get_encoding())
if self._partial_stdout is None:
self._partial_stdout = stdout
else:
self._pa... | [
"Callback for partial output."
] |
Please provide a description of the function:def _communicate(self):
if (not self._communicate_first and
self._process.state() == QProcess.NotRunning):
self.communicate()
elif self._fired:
self._timer.stop() | [
"Callback for communicate."
] |
Please provide a description of the function:def communicate(self):
self._communicate_first = True
self._process.waitForFinished()
enco = self._get_encoding()
if self._partial_stdout is None:
raw_stdout = self._process.readAllStandardOutput()
stdout = ha... | [
"Retrieve information."
] |
Please provide a description of the function:def _start(self):
if not self._fired:
self._partial_ouput = None
self._process.start(self._cmd_list[0], self._cmd_list[1:])
self._timer.start() | [
"Start process."
] |
Please provide a description of the function:def terminate(self):
if self._process.state() == QProcess.Running:
try:
self._process.terminate()
except Exception:
pass
self._fired = True | [
"Terminate running processes."
] |
Please provide a description of the function:def _clean_workers(self):
while self._bag_collector:
self._bag_collector.popleft()
self._timer_worker_delete.stop() | [
"Delete periodically workers in workers bag."
] |
Please provide a description of the function:def _start(self, worker=None):
if worker:
self._queue_workers.append(worker)
if self._queue_workers and self._running_threads < self._max_threads:
#print('Queue: {0} Running: {1} Workers: {2} '
# 'Threads: {... | [
"Start threads and check for inactive workers."
] |
Please provide a description of the function:def create_python_worker(self, func, *args, **kwargs):
worker = PythonWorker(func, args, kwargs)
self._create_worker(worker)
return worker | [
"Create a new python worker instance."
] |
Please provide a description of the function:def create_process_worker(self, cmd_list, environ=None):
worker = ProcessWorker(cmd_list, environ=environ)
self._create_worker(worker)
return worker | [
"Create a new process worker instance."
] |
Please provide a description of the function:def terminate_all(self):
for worker in self._workers:
worker.terminate()
# for thread in self._threads:
# try:
# thread.terminate()
# thread.wait()
# except Exception:
# ... | [
"Terminate all worker processes."
] |
Please provide a description of the function:def _create_worker(self, worker):
worker.sig_started.connect(self._start)
self._workers.append(worker) | [
"Common worker setup."
] |
Please provide a description of the function:def gather_file_data(name):
res = {'name': name}
try:
res['mtime'] = osp.getmtime(name)
res['size'] = osp.getsize(name)
except OSError:
pass
return res | [
"\n Gather data about a given file.\n\n Returns a dict with fields name, mtime and size, containing the relevant\n data for the fiel.\n "
] |
Please provide a description of the function:def file_data_to_str(data):
if not data:
return _('<i>File name not recorded</i>')
res = data['name']
try:
mtime_as_str = time.strftime('%Y-%m-%d %H:%M:%S',
time.localtime(data['mtime']))
res += '<... | [
"\n Convert file data to a string for display.\n\n This function takes the file data produced by gather_file_data().\n "
] |
Please provide a description of the function:def make_temporary_files(tempdir):
orig_dir = osp.join(tempdir, 'orig')
os.mkdir(orig_dir)
autosave_dir = osp.join(tempdir, 'autosave')
os.mkdir(autosave_dir)
autosave_mapping = {}
# ham.py: Both original and autosave files exist, mentioned in m... | [
"\n Make temporary files to simulate a recovery use case.\n\n Create a directory under tempdir containing some original files and another\n directory with autosave files. Return a tuple with the name of the\n directory with the original files, the name of the directory with the\n autosave files, and ... |
Please provide a description of the function:def gather_data(self):
self.data = []
try:
FileNotFoundError
except NameError: # Python 2
FileNotFoundError = OSError
# In Python 3, easier to use os.scandir()
try:
for name in os.listdir(s... | [
"\n Gather data about files which may be recovered.\n\n The data is stored in self.data as a list of tuples with the data\n pertaining to the original file and the autosave file. Each element of\n the tuple is a dict as returned by gather_file_data().\n "
] |
Please provide a description of the function:def add_label(self):
txt = _('Autosave files found. What would you like to do?\n\n'
'This dialog will be shown again on next startup if any '
'autosave files are not restored, moved or deleted.')
label = QLabel(txt, se... | [
"Add label with explanation at top of dialog window."
] |
Please provide a description of the function:def add_label_to_table(self, row, col, txt):
label = QLabel(txt)
label.setMargin(5)
label.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
self.table.setCellWidget(row, col, label) | [
"Add a label to specified cell in table."
] |
Please provide a description of the function:def add_table(self):
table = QTableWidget(len(self.data), 3, self)
self.table = table
labels = [_('Original file'), _('Autosave file'), _('Actions')]
table.setHorizontalHeaderLabels(labels)
table.verticalHeader().hide()
... | [
"Add table with info about files to be recovered."
] |
Please provide a description of the function:def add_cancel_button(self):
button_box = QDialogButtonBox(QDialogButtonBox.Cancel, self)
button_box.rejected.connect(self.reject)
self.layout.addWidget(button_box) | [
"Add a cancel button at the bottom of the dialog window."
] |
Please provide a description of the function:def register_plugin(self):
self.redirect_stdio.connect(self.main.redirect_internalshell_stdio)
self.main.console.shell.refresh.connect(self.refresh_plugin)
iconsize = 24
self.toolbar.setIconSize(QSize(iconsize, iconsize))
... | [
"Register plugin in Spyder's main window"
] |
Please provide a description of the function:def refresh_plugin(self):
curdir = getcwd_or_home()
self.pathedit.add_text(curdir)
self.save_wdhistory()
self.set_previous_enabled.emit(
self.histindex is not None and self.histindex > 0)
se... | [
"Refresh widget"
] |
Please provide a description of the function:def load_wdhistory(self, workdir=None):
if osp.isfile(self.LOG_PATH):
wdhistory, _ = encoding.readlines(self.LOG_PATH)
wdhistory = [name for name in wdhistory if os.path.isdir(name)]
else:
if workdir is None:... | [
"Load history from a text file in user home directory"
] |
Please provide a description of the function:def save_wdhistory(self):
text = [ to_text_string( self.pathedit.itemText(index) ) \
for index in range(self.pathedit.count()) ]
try:
encoding.writelines(text, self.LOG_PATH)
except EnvironmentError:
... | [
"Save history to a text file in user home directory"
] |
Please provide a description of the function:def select_directory(self):
self.redirect_stdio.emit(False)
directory = getexistingdirectory(self.main, _("Select directory"),
getcwd_or_home())
if directory:
self.chdir(directory)
... | [
"Select directory"
] |
Please provide a description of the function:def parent_directory(self):
self.chdir(os.path.join(getcwd_or_home(), os.path.pardir)) | [
"Change working directory to parent directory"
] |
Please provide a description of the function:def chdir(self, directory, browsing_history=False,
refresh_explorer=True, refresh_console=True):
if directory:
directory = osp.abspath(to_text_string(directory))
# Working directory history management
if brow... | [
"Set directory as working directory"
] |
Please provide a description of the function:def toogle_breakpoint(self, line_number=None, condition=None,
edit_condition=False):
if not self.editor.is_python_like():
return
if line_number is None:
block = self.editor.textCursor().block()
... | [
"Add/remove breakpoint."
] |
Please provide a description of the function:def get_breakpoints(self):
breakpoints = []
block = self.editor.document().firstBlock()
for line_number in range(1, self.editor.document().blockCount()+1):
data = block.userData()
if data and data.breakpoint:
... | [
"Get breakpoints"
] |
Please provide a description of the function:def clear_breakpoints(self):
self.breakpoints = []
for data in self.editor.blockuserdata_list[:]:
data.breakpoint = False
# data.breakpoint_condition = None # not necessary, but logical
if data.is_empty():
... | [
"Clear breakpoints"
] |
Please provide a description of the function:def set_breakpoints(self, breakpoints):
self.clear_breakpoints()
for line_number, condition in breakpoints:
self.toogle_breakpoint(line_number, condition)
self.breakpoints = self.get_breakpoints() | [
"Set breakpoints"
] |
Please provide a description of the function:def breakpoints_changed(self):
breakpoints = self.get_breakpoints()
if self.breakpoints != breakpoints:
self.breakpoints = breakpoints
self.save_breakpoints() | [
"Breakpoint list has changed"
] |
Please provide a description of the function:def unmatched_quotes_in_line(text):
# We check " first, then ', so complex cases with nested quotes will
# get the " to take precedence.
text = text.replace("\\'", "")
text = text.replace('\\"', '')
if text.count('"') % 2:
return '"'
elif... | [
"Return whether a string has open quotes.\n\n This simply counts whether the number of quote characters of either\n type in the string is odd.\n\n Take from the IPython project (in IPython/core/completer.py in v0.13)\n Spyder team: Add some changes to deal with escaped quotes\n\n - Copyright (C) 2008... |
Please provide a description of the function:def on_state_changed(self, state):
if state:
self.editor.sig_key_pressed.connect(self._on_key_pressed)
else:
self.editor.sig_key_pressed.disconnect(self._on_key_pressed) | [
"Connect/disconnect sig_key_pressed signal."
] |
Please provide a description of the function:def _autoinsert_quotes(self, key):
char = {Qt.Key_QuoteDbl: '"', Qt.Key_Apostrophe: '\''}[key]
line_text = self.editor.get_text('sol', 'eol')
line_to_cursor = self.editor.get_text('sol', 'cursor')
cursor = self.editor.textCursor()
... | [
"Control how to automatically insert quotes in various situations."
] |
Please provide a description of the function:def populate(combobox, data):
combobox.clear()
combobox.addItem("<None>", 0)
# First create a list of fully-qualified names.
cb_data = []
for item in data:
fqn = item.name
for parent in reversed(item.parents):
fqn = paren... | [
"\n Populate the given ``combobox`` with the class or function names.\n\n Parameters\n ----------\n combobox : :class:`qtpy.QtWidets.QComboBox`\n The combobox to populate\n data : list of :class:`FoldScopeHelper`\n The data to populate with. There should be one list element per\n ... |
Please provide a description of the function:def _get_fold_levels(editor):
block = editor.document().firstBlock()
oed = editor.get_outlineexplorer_data()
folds = []
parents = []
prev = None
while block.isValid():
if TextBlockHelper.is_fold_trigger(block):
try:
... | [
"\n Return a list of all the class/function definition ranges.\n\n Parameters\n ----------\n editor : :class:`spyder.plugins.editor.widgets.codeeditor.CodeEditor`\n\n Returns\n -------\n folds : list of :class:`FoldScopeHelper`\n A list of all the class or function defintion fold points.... |
Please provide a description of the function:def _adjust_parent_stack(fsh, prev, parents):
if prev is None:
return
if fsh.fold_scope.trigger_level < prev.fold_scope.trigger_level:
diff = prev.fold_scope.trigger_level - fsh.fold_scope.trigger_level
del parents[-diff:]
elif fsh.f... | [
"\n Adjust the parent stack in-place as the trigger level changes.\n\n Parameters\n ----------\n fsh : :class:`FoldScopeHelper`\n The :class:`FoldScopeHelper` object to act on.\n prev : :class:`FoldScopeHelper`\n The previous :class:`FoldScopeHelper` object.\n parents : list of :clas... |
Please provide a description of the function:def _split_classes_and_methods(folds):
classes = []
functions = []
for fold in folds:
if fold.def_type == OED.FUNCTION_TOKEN:
functions.append(fold)
elif fold.def_type == OED.CLASS_TOKEN:
classes.append(fold)
retu... | [
"\n Split out classes and methods into two separate lists.\n\n Parameters\n ----------\n folds : list of :class:`FoldScopeHelper`\n The result of :func:`_get_fold_levels`.\n\n Returns\n -------\n classes, functions: list of :class:`FoldScopeHelper`\n Two separate lists of :class:`... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.