repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
spyder-ide/spyder | spyder/plugins/editor/utils/autosave.py | AutosaveForStack.remove_autosave_file | def remove_autosave_file(self, fileinfo):
"""
Remove autosave file for specified file.
This function also updates `self.autosave_mapping` and clears the
`changed_since_autosave` flag.
"""
filename = fileinfo.filename
if filename not in self.name_mapping:
... | python | def remove_autosave_file(self, fileinfo):
"""
Remove autosave file for specified file.
This function also updates `self.autosave_mapping` and clears the
`changed_since_autosave` flag.
"""
filename = fileinfo.filename
if filename not in self.name_mapping:
... | [
"def",
"remove_autosave_file",
"(",
"self",
",",
"fileinfo",
")",
":",
"filename",
"=",
"fileinfo",
".",
"filename",
"if",
"filename",
"not",
"in",
"self",
".",
"name_mapping",
":",
"return",
"autosave_filename",
"=",
"self",
".",
"name_mapping",
"[",
"filenam... | Remove autosave file for specified file.
This function also updates `self.autosave_mapping` and clears the
`changed_since_autosave` flag. | [
"Remove",
"autosave",
"file",
"for",
"specified",
"file",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/autosave.py#L154-L175 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/autosave.py | AutosaveForStack.get_autosave_filename | def get_autosave_filename(self, filename):
"""
Get name of autosave file for specified file name.
This function uses the dict in `self.name_mapping`. If `filename` is
in the mapping, then return the corresponding autosave file name.
Otherwise, construct a unique file name and up... | python | def get_autosave_filename(self, filename):
"""
Get name of autosave file for specified file name.
This function uses the dict in `self.name_mapping`. If `filename` is
in the mapping, then return the corresponding autosave file name.
Otherwise, construct a unique file name and up... | [
"def",
"get_autosave_filename",
"(",
"self",
",",
"filename",
")",
":",
"try",
":",
"autosave_filename",
"=",
"self",
".",
"name_mapping",
"[",
"filename",
"]",
"except",
"KeyError",
":",
"autosave_dir",
"=",
"get_conf_path",
"(",
"'autosave'",
")",
"if",
"not... | Get name of autosave file for specified file name.
This function uses the dict in `self.name_mapping`. If `filename` is
in the mapping, then return the corresponding autosave file name.
Otherwise, construct a unique file name and update the mapping.
Args:
filename (str): or... | [
"Get",
"name",
"of",
"autosave",
"file",
"for",
"specified",
"file",
"name",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/autosave.py#L177-L205 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/autosave.py | AutosaveForStack.autosave | def autosave(self, index):
"""
Autosave a file.
Do nothing if the `changed_since_autosave` flag is not set or the file
is newly created (and thus not named by the user). Otherwise, save a
copy of the file with the name given by `self.get_autosave_filename()`
and clear th... | python | def autosave(self, index):
"""
Autosave a file.
Do nothing if the `changed_since_autosave` flag is not set or the file
is newly created (and thus not named by the user). Otherwise, save a
copy of the file with the name given by `self.get_autosave_filename()`
and clear th... | [
"def",
"autosave",
"(",
"self",
",",
"index",
")",
":",
"finfo",
"=",
"self",
".",
"stack",
".",
"data",
"[",
"index",
"]",
"document",
"=",
"finfo",
".",
"editor",
".",
"document",
"(",
")",
"if",
"not",
"document",
".",
"changed_since_autosave",
"or"... | Autosave a file.
Do nothing if the `changed_since_autosave` flag is not set or the file
is newly created (and thus not named by the user). Otherwise, save a
copy of the file with the name given by `self.get_autosave_filename()`
and clear the `changed_since_autosave` flag. Errors raised ... | [
"Autosave",
"a",
"file",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/autosave.py#L207-L233 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/autosave.py | AutosaveForStack.autosave_all | def autosave_all(self):
"""Autosave all opened files."""
for index in range(self.stack.get_stack_count()):
self.autosave(index) | python | def autosave_all(self):
"""Autosave all opened files."""
for index in range(self.stack.get_stack_count()):
self.autosave(index) | [
"def",
"autosave_all",
"(",
"self",
")",
":",
"for",
"index",
"in",
"range",
"(",
"self",
".",
"stack",
".",
"get_stack_count",
"(",
")",
")",
":",
"self",
".",
"autosave",
"(",
"index",
")"
] | Autosave all opened files. | [
"Autosave",
"all",
"opened",
"files",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/autosave.py#L235-L238 | train |
spyder-ide/spyder | spyder/utils/fixtures.py | tmpconfig | def tmpconfig(request):
"""
Fixtures that returns a temporary CONF element.
"""
SUBFOLDER = tempfile.mkdtemp()
CONF = UserConfig('spyder-test',
defaults=DEFAULTS,
version=CONF_VERSION,
subfolder=SUBFOLDER,
raw_mo... | python | def tmpconfig(request):
"""
Fixtures that returns a temporary CONF element.
"""
SUBFOLDER = tempfile.mkdtemp()
CONF = UserConfig('spyder-test',
defaults=DEFAULTS,
version=CONF_VERSION,
subfolder=SUBFOLDER,
raw_mo... | [
"def",
"tmpconfig",
"(",
"request",
")",
":",
"SUBFOLDER",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"CONF",
"=",
"UserConfig",
"(",
"'spyder-test'",
",",
"defaults",
"=",
"DEFAULTS",
",",
"version",
"=",
"CONF_VERSION",
",",
"subfolder",
"=",
"SUBFOLDER",
... | Fixtures that returns a temporary CONF element. | [
"Fixtures",
"that",
"returns",
"a",
"temporary",
"CONF",
"element",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/fixtures.py#L27-L46 | train |
spyder-ide/spyder | spyder/utils/debug.py | log_last_error | def log_last_error(fname, context=None):
"""Log last error in filename *fname* -- *context*: string (optional)"""
fd = open(fname, 'a')
log_time(fd)
if context:
print("Context", file=fd)
print("-------", file=fd)
print("", file=fd)
if PY2:
print(u' '.... | python | def log_last_error(fname, context=None):
"""Log last error in filename *fname* -- *context*: string (optional)"""
fd = open(fname, 'a')
log_time(fd)
if context:
print("Context", file=fd)
print("-------", file=fd)
print("", file=fd)
if PY2:
print(u' '.... | [
"def",
"log_last_error",
"(",
"fname",
",",
"context",
"=",
"None",
")",
":",
"fd",
"=",
"open",
"(",
"fname",
",",
"'a'",
")",
"log_time",
"(",
"fd",
")",
"if",
"context",
":",
"print",
"(",
"\"Context\"",
",",
"file",
"=",
"fd",
")",
"print",
"("... | Log last error in filename *fname* -- *context*: string (optional) | [
"Log",
"last",
"error",
"in",
"filename",
"*",
"fname",
"*",
"--",
"*",
"context",
"*",
":",
"string",
"(",
"optional",
")"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/debug.py#L30-L48 | train |
spyder-ide/spyder | spyder/utils/debug.py | log_methods_calls | def log_methods_calls(fname, some_class, prefix=None):
"""
Hack `some_class` to log all method calls into `fname` file.
If `prefix` format is not set, each log entry is prefixed with:
--[ asked / called / defined ] --
asked - name of `some_class`
called - name of class for whi... | python | def log_methods_calls(fname, some_class, prefix=None):
"""
Hack `some_class` to log all method calls into `fname` file.
If `prefix` format is not set, each log entry is prefixed with:
--[ asked / called / defined ] --
asked - name of `some_class`
called - name of class for whi... | [
"def",
"log_methods_calls",
"(",
"fname",
",",
"some_class",
",",
"prefix",
"=",
"None",
")",
":",
"# test if file is writable\r",
"open",
"(",
"fname",
",",
"'a'",
")",
".",
"close",
"(",
")",
"FILENAME",
"=",
"fname",
"CLASS",
"=",
"some_class",
"PREFIX",
... | Hack `some_class` to log all method calls into `fname` file.
If `prefix` format is not set, each log entry is prefixed with:
--[ asked / called / defined ] --
asked - name of `some_class`
called - name of class for which a method is called
defined - name of class where method i... | [
"Hack",
"some_class",
"to",
"log",
"all",
"method",
"calls",
"into",
"fname",
"file",
".",
"If",
"prefix",
"format",
"is",
"not",
"set",
"each",
"log",
"entry",
"is",
"prefixed",
"with",
":",
"--",
"[",
"asked",
"/",
"called",
"/",
"defined",
"]",
"--"... | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/debug.py#L95-L146 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.offset | def offset(self):
"""This property holds the vertical offset of the scroll flag area
relative to the top of the text editor."""
vsb = self.editor.verticalScrollBar()
style = vsb.style()
opt = QStyleOptionSlider()
vsb.initStyleOption(opt)
# Get the area in which t... | python | def offset(self):
"""This property holds the vertical offset of the scroll flag area
relative to the top of the text editor."""
vsb = self.editor.verticalScrollBar()
style = vsb.style()
opt = QStyleOptionSlider()
vsb.initStyleOption(opt)
# Get the area in which t... | [
"def",
"offset",
"(",
"self",
")",
":",
"vsb",
"=",
"self",
".",
"editor",
".",
"verticalScrollBar",
"(",
")",
"style",
"=",
"vsb",
".",
"style",
"(",
")",
"opt",
"=",
"QStyleOptionSlider",
"(",
")",
"vsb",
".",
"initStyleOption",
"(",
"opt",
")",
"#... | This property holds the vertical offset of the scroll flag area
relative to the top of the text editor. | [
"This",
"property",
"holds",
"the",
"vertical",
"offset",
"of",
"the",
"scroll",
"flag",
"area",
"relative",
"to",
"the",
"top",
"of",
"the",
"text",
"editor",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L49-L61 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.paintEvent | def paintEvent(self, event):
"""
Override Qt method.
Painting the scroll flag area
"""
make_flag = self.make_flag_qrect
# Fill the whole painting area
painter = QPainter(self)
painter.fillRect(event.rect(), self.editor.sideareas_color)
# Paint wa... | python | def paintEvent(self, event):
"""
Override Qt method.
Painting the scroll flag area
"""
make_flag = self.make_flag_qrect
# Fill the whole painting area
painter = QPainter(self)
painter.fillRect(event.rect(), self.editor.sideareas_color)
# Paint wa... | [
"def",
"paintEvent",
"(",
"self",
",",
"event",
")",
":",
"make_flag",
"=",
"self",
".",
"make_flag_qrect",
"# Fill the whole painting area",
"painter",
"=",
"QPainter",
"(",
"self",
")",
"painter",
".",
"fillRect",
"(",
"event",
".",
"rect",
"(",
")",
",",
... | Override Qt method.
Painting the scroll flag area | [
"Override",
"Qt",
"method",
".",
"Painting",
"the",
"scroll",
"flag",
"area"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L67-L138 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.mousePressEvent | def mousePressEvent(self, event):
"""Override Qt method"""
if self.slider and event.button() == Qt.LeftButton:
vsb = self.editor.verticalScrollBar()
value = self.position_to_value(event.pos().y())
vsb.setValue(value-vsb.pageStep()/2) | python | def mousePressEvent(self, event):
"""Override Qt method"""
if self.slider and event.button() == Qt.LeftButton:
vsb = self.editor.verticalScrollBar()
value = self.position_to_value(event.pos().y())
vsb.setValue(value-vsb.pageStep()/2) | [
"def",
"mousePressEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"self",
".",
"slider",
"and",
"event",
".",
"button",
"(",
")",
"==",
"Qt",
".",
"LeftButton",
":",
"vsb",
"=",
"self",
".",
"editor",
".",
"verticalScrollBar",
"(",
")",
"value",
"... | Override Qt method | [
"Override",
"Qt",
"method"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L152-L157 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.keyReleaseEvent | def keyReleaseEvent(self, event):
"""Override Qt method."""
if event.key() == Qt.Key_Alt:
self._alt_key_is_down = False
self.update() | python | def keyReleaseEvent(self, event):
"""Override Qt method."""
if event.key() == Qt.Key_Alt:
self._alt_key_is_down = False
self.update() | [
"def",
"keyReleaseEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"key",
"(",
")",
"==",
"Qt",
".",
"Key_Alt",
":",
"self",
".",
"_alt_key_is_down",
"=",
"False",
"self",
".",
"update",
"(",
")"
] | Override Qt method. | [
"Override",
"Qt",
"method",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L159-L163 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.keyPressEvent | def keyPressEvent(self, event):
"""Override Qt method"""
if event.key() == Qt.Key_Alt:
self._alt_key_is_down = True
self.update() | python | def keyPressEvent(self, event):
"""Override Qt method"""
if event.key() == Qt.Key_Alt:
self._alt_key_is_down = True
self.update() | [
"def",
"keyPressEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"key",
"(",
")",
"==",
"Qt",
".",
"Key_Alt",
":",
"self",
".",
"_alt_key_is_down",
"=",
"True",
"self",
".",
"update",
"(",
")"
] | Override Qt method | [
"Override",
"Qt",
"method"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L165-L169 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.get_scrollbar_position_height | def get_scrollbar_position_height(self):
"""Return the pixel span height of the scrollbar area in which
the slider handle may move"""
vsb = self.editor.verticalScrollBar()
style = vsb.style()
opt = QStyleOptionSlider()
vsb.initStyleOption(opt)
# Get the area in w... | python | def get_scrollbar_position_height(self):
"""Return the pixel span height of the scrollbar area in which
the slider handle may move"""
vsb = self.editor.verticalScrollBar()
style = vsb.style()
opt = QStyleOptionSlider()
vsb.initStyleOption(opt)
# Get the area in w... | [
"def",
"get_scrollbar_position_height",
"(",
"self",
")",
":",
"vsb",
"=",
"self",
".",
"editor",
".",
"verticalScrollBar",
"(",
")",
"style",
"=",
"vsb",
".",
"style",
"(",
")",
"opt",
"=",
"QStyleOptionSlider",
"(",
")",
"vsb",
".",
"initStyleOption",
"(... | Return the pixel span height of the scrollbar area in which
the slider handle may move | [
"Return",
"the",
"pixel",
"span",
"height",
"of",
"the",
"scrollbar",
"area",
"in",
"which",
"the",
"slider",
"handle",
"may",
"move"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L171-L183 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.get_scrollbar_value_height | def get_scrollbar_value_height(self):
"""Return the value span height of the scrollbar"""
vsb = self.editor.verticalScrollBar()
return vsb.maximum()-vsb.minimum()+vsb.pageStep() | python | def get_scrollbar_value_height(self):
"""Return the value span height of the scrollbar"""
vsb = self.editor.verticalScrollBar()
return vsb.maximum()-vsb.minimum()+vsb.pageStep() | [
"def",
"get_scrollbar_value_height",
"(",
"self",
")",
":",
"vsb",
"=",
"self",
".",
"editor",
".",
"verticalScrollBar",
"(",
")",
"return",
"vsb",
".",
"maximum",
"(",
")",
"-",
"vsb",
".",
"minimum",
"(",
")",
"+",
"vsb",
".",
"pageStep",
"(",
")"
] | Return the value span height of the scrollbar | [
"Return",
"the",
"value",
"span",
"height",
"of",
"the",
"scrollbar"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L185-L188 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.value_to_position | def value_to_position(self, y):
"""Convert value to position in pixels"""
vsb = self.editor.verticalScrollBar()
return (y-vsb.minimum())*self.get_scale_factor()+self.offset | python | def value_to_position(self, y):
"""Convert value to position in pixels"""
vsb = self.editor.verticalScrollBar()
return (y-vsb.minimum())*self.get_scale_factor()+self.offset | [
"def",
"value_to_position",
"(",
"self",
",",
"y",
")",
":",
"vsb",
"=",
"self",
".",
"editor",
".",
"verticalScrollBar",
"(",
")",
"return",
"(",
"y",
"-",
"vsb",
".",
"minimum",
"(",
")",
")",
"*",
"self",
".",
"get_scale_factor",
"(",
")",
"+",
... | Convert value to position in pixels | [
"Convert",
"value",
"to",
"position",
"in",
"pixels"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L196-L199 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.position_to_value | def position_to_value(self, y):
"""Convert position in pixels to value"""
vsb = self.editor.verticalScrollBar()
return vsb.minimum()+max([0, (y-self.offset)/self.get_scale_factor()]) | python | def position_to_value(self, y):
"""Convert position in pixels to value"""
vsb = self.editor.verticalScrollBar()
return vsb.minimum()+max([0, (y-self.offset)/self.get_scale_factor()]) | [
"def",
"position_to_value",
"(",
"self",
",",
"y",
")",
":",
"vsb",
"=",
"self",
".",
"editor",
".",
"verticalScrollBar",
"(",
")",
"return",
"vsb",
".",
"minimum",
"(",
")",
"+",
"max",
"(",
"[",
"0",
",",
"(",
"y",
"-",
"self",
".",
"offset",
"... | Convert position in pixels to value | [
"Convert",
"position",
"in",
"pixels",
"to",
"value"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L201-L204 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.make_flag_qrect | def make_flag_qrect(self, value):
"""Make flag QRect"""
if self.slider:
position = self.value_to_position(value+0.5)
# The 0.5 offset is used to align the flags with the center of
# their corresponding text edit block before scaling.
return QRect(self.FLA... | python | def make_flag_qrect(self, value):
"""Make flag QRect"""
if self.slider:
position = self.value_to_position(value+0.5)
# The 0.5 offset is used to align the flags with the center of
# their corresponding text edit block before scaling.
return QRect(self.FLA... | [
"def",
"make_flag_qrect",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"slider",
":",
"position",
"=",
"self",
".",
"value_to_position",
"(",
"value",
"+",
"0.5",
")",
"# The 0.5 offset is used to align the flags with the center of",
"# their corresponding ... | Make flag QRect | [
"Make",
"flag",
"QRect"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L206-L226 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.make_slider_range | def make_slider_range(self, cursor_pos):
"""Make slider range QRect"""
# The slider range indicator position follows the mouse vertical
# position while its height corresponds to the part of the file that
# is currently visible on screen.
vsb = self.editor.verticalScrollBar()
... | python | def make_slider_range(self, cursor_pos):
"""Make slider range QRect"""
# The slider range indicator position follows the mouse vertical
# position while its height corresponds to the part of the file that
# is currently visible on screen.
vsb = self.editor.verticalScrollBar()
... | [
"def",
"make_slider_range",
"(",
"self",
",",
"cursor_pos",
")",
":",
"# The slider range indicator position follows the mouse vertical",
"# position while its height corresponds to the part of the file that",
"# is currently visible on screen.",
"vsb",
"=",
"self",
".",
"editor",
".... | Make slider range QRect | [
"Make",
"slider",
"range",
"QRect"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L228-L247 | train |
spyder-ide/spyder | spyder/plugins/editor/panels/scrollflag.py | ScrollFlagArea.set_painter | def set_painter(self, painter, light_color):
"""Set scroll flag area painter pen and brush colors"""
painter.setPen(QColor(light_color).darker(120))
painter.setBrush(QBrush(QColor(light_color))) | python | def set_painter(self, painter, light_color):
"""Set scroll flag area painter pen and brush colors"""
painter.setPen(QColor(light_color).darker(120))
painter.setBrush(QBrush(QColor(light_color))) | [
"def",
"set_painter",
"(",
"self",
",",
"painter",
",",
"light_color",
")",
":",
"painter",
".",
"setPen",
"(",
"QColor",
"(",
"light_color",
")",
".",
"darker",
"(",
"120",
")",
")",
"painter",
".",
"setBrush",
"(",
"QBrush",
"(",
"QColor",
"(",
"ligh... | Set scroll flag area painter pen and brush colors | [
"Set",
"scroll",
"flag",
"area",
"painter",
"pen",
"and",
"brush",
"colors"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/panels/scrollflag.py#L253-L256 | train |
spyder-ide/spyder | spyder/plugins/profiler/plugin.py | Profiler.on_first_registration | def on_first_registration(self):
"""Action to be performed on first plugin registration"""
self.main.tabify_plugins(self.main.help, self)
self.dockwidget.hide() | python | def on_first_registration(self):
"""Action to be performed on first plugin registration"""
self.main.tabify_plugins(self.main.help, self)
self.dockwidget.hide() | [
"def",
"on_first_registration",
"(",
"self",
")",
":",
"self",
".",
"main",
".",
"tabify_plugins",
"(",
"self",
".",
"main",
".",
"help",
",",
"self",
")",
"self",
".",
"dockwidget",
".",
"hide",
"(",
")"
] | Action to be performed on first plugin registration | [
"Action",
"to",
"be",
"performed",
"on",
"first",
"plugin",
"registration"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/profiler/plugin.py#L75-L78 | train |
spyder-ide/spyder | spyder/plugins/profiler/plugin.py | Profiler.register_plugin | def register_plugin(self):
"""Register plugin in Spyder's main window"""
self.profiler.datatree.sig_edit_goto.connect(self.main.editor.load)
self.profiler.redirect_stdio.connect(
self.main.redirect_internalshell_stdio)
self.main.add_dockwidget(self)
profiler_act = cr... | python | def register_plugin(self):
"""Register plugin in Spyder's main window"""
self.profiler.datatree.sig_edit_goto.connect(self.main.editor.load)
self.profiler.redirect_stdio.connect(
self.main.redirect_internalshell_stdio)
self.main.add_dockwidget(self)
profiler_act = cr... | [
"def",
"register_plugin",
"(",
"self",
")",
":",
"self",
".",
"profiler",
".",
"datatree",
".",
"sig_edit_goto",
".",
"connect",
"(",
"self",
".",
"main",
".",
"editor",
".",
"load",
")",
"self",
".",
"profiler",
".",
"redirect_stdio",
".",
"connect",
"(... | Register plugin in Spyder's main window | [
"Register",
"plugin",
"in",
"Spyder",
"s",
"main",
"window"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/profiler/plugin.py#L80-L95 | train |
spyder-ide/spyder | spyder/plugins/profiler/plugin.py | Profiler.run_profiler | def run_profiler(self):
"""Run profiler"""
if self.main.editor.save():
self.switch_to_plugin()
self.analyze(self.main.editor.get_current_filename()) | python | def run_profiler(self):
"""Run profiler"""
if self.main.editor.save():
self.switch_to_plugin()
self.analyze(self.main.editor.get_current_filename()) | [
"def",
"run_profiler",
"(",
"self",
")",
":",
"if",
"self",
".",
"main",
".",
"editor",
".",
"save",
"(",
")",
":",
"self",
".",
"switch_to_plugin",
"(",
")",
"self",
".",
"analyze",
"(",
"self",
".",
"main",
".",
"editor",
".",
"get_current_filename",... | Run profiler | [
"Run",
"profiler"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/profiler/plugin.py#L112-L116 | train |
spyder-ide/spyder | spyder/plugins/profiler/plugin.py | Profiler.analyze | def analyze(self, filename):
"""Reimplement analyze method"""
if self.dockwidget and not self.ismaximized:
self.dockwidget.setVisible(True)
self.dockwidget.setFocus()
self.dockwidget.raise_()
pythonpath = self.main.get_spyder_pythonpath()
runconf = get... | python | def analyze(self, filename):
"""Reimplement analyze method"""
if self.dockwidget and not self.ismaximized:
self.dockwidget.setVisible(True)
self.dockwidget.setFocus()
self.dockwidget.raise_()
pythonpath = self.main.get_spyder_pythonpath()
runconf = get... | [
"def",
"analyze",
"(",
"self",
",",
"filename",
")",
":",
"if",
"self",
".",
"dockwidget",
"and",
"not",
"self",
".",
"ismaximized",
":",
"self",
".",
"dockwidget",
".",
"setVisible",
"(",
"True",
")",
"self",
".",
"dockwidget",
".",
"setFocus",
"(",
"... | Reimplement analyze method | [
"Reimplement",
"analyze",
"method"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/profiler/plugin.py#L118-L133 | train |
spyder-ide/spyder | spyder/utils/system.py | windows_memory_usage | def windows_memory_usage():
"""Return physical memory usage (float)
Works on Windows platforms only"""
from ctypes import windll, Structure, c_uint64, sizeof, byref
from ctypes.wintypes import DWORD
class MemoryStatus(Structure):
_fields_ = [('dwLength', DWORD),
('... | python | def windows_memory_usage():
"""Return physical memory usage (float)
Works on Windows platforms only"""
from ctypes import windll, Structure, c_uint64, sizeof, byref
from ctypes.wintypes import DWORD
class MemoryStatus(Structure):
_fields_ = [('dwLength', DWORD),
('... | [
"def",
"windows_memory_usage",
"(",
")",
":",
"from",
"ctypes",
"import",
"windll",
",",
"Structure",
",",
"c_uint64",
",",
"sizeof",
",",
"byref",
"from",
"ctypes",
".",
"wintypes",
"import",
"DWORD",
"class",
"MemoryStatus",
"(",
"Structure",
")",
":",
"_f... | Return physical memory usage (float)
Works on Windows platforms only | [
"Return",
"physical",
"memory",
"usage",
"(",
"float",
")",
"Works",
"on",
"Windows",
"platforms",
"only"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/system.py#L22-L43 | train |
spyder-ide/spyder | spyder/utils/system.py | psutil_phymem_usage | def psutil_phymem_usage():
"""
Return physical memory usage (float)
Requires the cross-platform psutil (>=v0.3) library
(https://github.com/giampaolo/psutil)
"""
import psutil
# This is needed to avoid a deprecation warning error with
# newer psutil versions
try:
pe... | python | def psutil_phymem_usage():
"""
Return physical memory usage (float)
Requires the cross-platform psutil (>=v0.3) library
(https://github.com/giampaolo/psutil)
"""
import psutil
# This is needed to avoid a deprecation warning error with
# newer psutil versions
try:
pe... | [
"def",
"psutil_phymem_usage",
"(",
")",
":",
"import",
"psutil",
"# This is needed to avoid a deprecation warning error with\r",
"# newer psutil versions\r",
"try",
":",
"percent",
"=",
"psutil",
".",
"virtual_memory",
"(",
")",
".",
"percent",
"except",
":",
"percent",
... | Return physical memory usage (float)
Requires the cross-platform psutil (>=v0.3) library
(https://github.com/giampaolo/psutil) | [
"Return",
"physical",
"memory",
"usage",
"(",
"float",
")",
"Requires",
"the",
"cross",
"-",
"platform",
"psutil",
"(",
">",
"=",
"v0",
".",
"3",
")",
"library",
"(",
"https",
":",
"//",
"github",
".",
"com",
"/",
"giampaolo",
"/",
"psutil",
")"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/system.py#L45-L58 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | drift_color | def drift_color(base_color, factor=110):
"""
Return color that is lighter or darker than the base color.
If base_color.lightness is higher than 128, the returned color is darker
otherwise is is lighter.
:param base_color: The base color to drift from
;:param factor: drift factor (%)
:retur... | python | def drift_color(base_color, factor=110):
"""
Return color that is lighter or darker than the base color.
If base_color.lightness is higher than 128, the returned color is darker
otherwise is is lighter.
:param base_color: The base color to drift from
;:param factor: drift factor (%)
:retur... | [
"def",
"drift_color",
"(",
"base_color",
",",
"factor",
"=",
"110",
")",
":",
"base_color",
"=",
"QColor",
"(",
"base_color",
")",
"if",
"base_color",
".",
"lightness",
"(",
")",
">",
"128",
":",
"return",
"base_color",
".",
"darker",
"(",
"factor",
")",... | Return color that is lighter or darker than the base color.
If base_color.lightness is higher than 128, the returned color is darker
otherwise is is lighter.
:param base_color: The base color to drift from
;:param factor: drift factor (%)
:return A lighter or darker color. | [
"Return",
"color",
"that",
"is",
"lighter",
"or",
"darker",
"than",
"the",
"base",
"color",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L33-L51 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | get_block_symbol_data | def get_block_symbol_data(editor, block):
"""
Gets the list of ParenthesisInfo for specific text block.
:param editor: Code editor instance
:param block: block to parse
"""
def list_symbols(editor, block, character):
"""
Retuns a list of symbols found in the block text
... | python | def get_block_symbol_data(editor, block):
"""
Gets the list of ParenthesisInfo for specific text block.
:param editor: Code editor instance
:param block: block to parse
"""
def list_symbols(editor, block, character):
"""
Retuns a list of symbols found in the block text
... | [
"def",
"get_block_symbol_data",
"(",
"editor",
",",
"block",
")",
":",
"def",
"list_symbols",
"(",
"editor",
",",
"block",
",",
"character",
")",
":",
"\"\"\"\n Retuns a list of symbols found in the block text\n\n :param editor: code editor instance\n :param... | Gets the list of ParenthesisInfo for specific text block.
:param editor: Code editor instance
:param block: block to parse | [
"Gets",
"the",
"list",
"of",
"ParenthesisInfo",
"for",
"specific",
"text",
"block",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L1035-L1076 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | keep_tc_pos | def keep_tc_pos(func):
"""
Cache text cursor position and restore it when the wrapped
function exits.
This decorator can only be used on modes or panels.
:param func: wrapped function
"""
@functools.wraps(func)
def wrapper(editor, *args, **kwds):
""" Decorator """
sb = ... | python | def keep_tc_pos(func):
"""
Cache text cursor position and restore it when the wrapped
function exits.
This decorator can only be used on modes or panels.
:param func: wrapped function
"""
@functools.wraps(func)
def wrapper(editor, *args, **kwds):
""" Decorator """
sb = ... | [
"def",
"keep_tc_pos",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"editor",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"\"\"\" Decorator \"\"\"",
"sb",
"=",
"editor",
".",
"verticalScrollBar",
... | Cache text cursor position and restore it when the wrapped
function exits.
This decorator can only be used on modes or panels.
:param func: wrapped function | [
"Cache",
"text",
"cursor",
"position",
"and",
"restore",
"it",
"when",
"the",
"wrapped",
"function",
"exits",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L1079-L1100 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | with_wait_cursor | def with_wait_cursor(func):
"""
Show a wait cursor while the wrapped function is running. The cursor is
restored as soon as the function exits.
:param func: wrapped function
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
QApplication.setOverrideCursor(
QCursor(... | python | def with_wait_cursor(func):
"""
Show a wait cursor while the wrapped function is running. The cursor is
restored as soon as the function exits.
:param func: wrapped function
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
QApplication.setOverrideCursor(
QCursor(... | [
"def",
"with_wait_cursor",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"QApplication",
".",
"setOverrideCursor",
"(",
"QCursor",
"(",
"Qt",
".",
"WaitCu... | Show a wait cursor while the wrapped function is running. The cursor is
restored as soon as the function exits.
:param func: wrapped function | [
"Show",
"a",
"wait",
"cursor",
"while",
"the",
"wrapped",
"function",
"is",
"running",
".",
"The",
"cursor",
"is",
"restored",
"as",
"soon",
"as",
"the",
"function",
"exits",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L1103-L1119 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | BlockUserData.is_empty | def is_empty(self):
"""Return whether the block of user data is empty."""
return (not self.breakpoint and not self.code_analysis
and not self.todo and not self.bookmarks) | python | def is_empty(self):
"""Return whether the block of user data is empty."""
return (not self.breakpoint and not self.code_analysis
and not self.todo and not self.bookmarks) | [
"def",
"is_empty",
"(",
"self",
")",
":",
"return",
"(",
"not",
"self",
".",
"breakpoint",
"and",
"not",
"self",
".",
"code_analysis",
"and",
"not",
"self",
".",
"todo",
"and",
"not",
"self",
".",
"bookmarks",
")"
] | Return whether the block of user data is empty. | [
"Return",
"whether",
"the",
"block",
"of",
"user",
"data",
"is",
"empty",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L67-L70 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | DelayJobRunner.request_job | def request_job(self, job, *args, **kwargs):
"""
Request a job execution.
The job will be executed after the delay specified in the
DelayJobRunner contructor elapsed if no other job is requested until
then.
:param job: job.
:type job: callable
:param arg... | python | def request_job(self, job, *args, **kwargs):
"""
Request a job execution.
The job will be executed after the delay specified in the
DelayJobRunner contructor elapsed if no other job is requested until
then.
:param job: job.
:type job: callable
:param arg... | [
"def",
"request_job",
"(",
"self",
",",
"job",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"cancel_requests",
"(",
")",
"self",
".",
"_job",
"=",
"job",
"self",
".",
"_args",
"=",
"args",
"self",
".",
"_kwargs",
"=",
"kwargs",... | Request a job execution.
The job will be executed after the delay specified in the
DelayJobRunner contructor elapsed if no other job is requested until
then.
:param job: job.
:type job: callable
:param args: job's position arguments
:param kwargs: job's keyworde... | [
"Request",
"a",
"job",
"execution",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L100-L117 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | DelayJobRunner.cancel_requests | def cancel_requests(self):
"""Cancels pending requests."""
self._timer.stop()
self._job = None
self._args = None
self._kwargs = None | python | def cancel_requests(self):
"""Cancels pending requests."""
self._timer.stop()
self._job = None
self._args = None
self._kwargs = None | [
"def",
"cancel_requests",
"(",
"self",
")",
":",
"self",
".",
"_timer",
".",
"stop",
"(",
")",
"self",
".",
"_job",
"=",
"None",
"self",
".",
"_args",
"=",
"None",
"self",
".",
"_kwargs",
"=",
"None"
] | Cancels pending requests. | [
"Cancels",
"pending",
"requests",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L119-L124 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | DelayJobRunner._exec_requested_job | def _exec_requested_job(self):
"""Execute the requested job after the timer has timeout."""
self._timer.stop()
self._job(*self._args, **self._kwargs) | python | def _exec_requested_job(self):
"""Execute the requested job after the timer has timeout."""
self._timer.stop()
self._job(*self._args, **self._kwargs) | [
"def",
"_exec_requested_job",
"(",
"self",
")",
":",
"self",
".",
"_timer",
".",
"stop",
"(",
")",
"self",
".",
"_job",
"(",
"*",
"self",
".",
"_args",
",",
"*",
"*",
"self",
".",
"_kwargs",
")"
] | Execute the requested job after the timer has timeout. | [
"Execute",
"the",
"requested",
"job",
"after",
"the",
"timer",
"has",
"timeout",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L126-L129 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.goto_line | def goto_line(self, line, column=0, end_column=0, move=True, word=''):
"""
Moves the text cursor to the specified position.
:param line: Number of the line to go to (0 based)
:param column: Optional column number. Default is 0 (start of line).
:param move: True to move the curso... | python | def goto_line(self, line, column=0, end_column=0, move=True, word=''):
"""
Moves the text cursor to the specified position.
:param line: Number of the line to go to (0 based)
:param column: Optional column number. Default is 0 (start of line).
:param move: True to move the curso... | [
"def",
"goto_line",
"(",
"self",
",",
"line",
",",
"column",
"=",
"0",
",",
"end_column",
"=",
"0",
",",
"move",
"=",
"True",
",",
"word",
"=",
"''",
")",
":",
"line",
"=",
"min",
"(",
"line",
",",
"self",
".",
"line_count",
"(",
")",
")",
"tex... | Moves the text cursor to the specified position.
:param line: Number of the line to go to (0 based)
:param column: Optional column number. Default is 0 (start of line).
:param move: True to move the cursor. False will return the cursor
without setting it on the editor.
... | [
"Moves",
"the",
"text",
"cursor",
"to",
"the",
"specified",
"position",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L154-L186 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.unfold_if_colapsed | def unfold_if_colapsed(self, block):
"""Unfold parent fold trigger if the block is collapsed.
:param block: Block to unfold.
"""
try:
folding_panel = self._editor.panels.get('FoldingPanel')
except KeyError:
pass
else:
from spyder.plugi... | python | def unfold_if_colapsed(self, block):
"""Unfold parent fold trigger if the block is collapsed.
:param block: Block to unfold.
"""
try:
folding_panel = self._editor.panels.get('FoldingPanel')
except KeyError:
pass
else:
from spyder.plugi... | [
"def",
"unfold_if_colapsed",
"(",
"self",
",",
"block",
")",
":",
"try",
":",
"folding_panel",
"=",
"self",
".",
"_editor",
".",
"panels",
".",
"get",
"(",
"'FoldingPanel'",
")",
"except",
"KeyError",
":",
"pass",
"else",
":",
"from",
"spyder",
".",
"plu... | Unfold parent fold trigger if the block is collapsed.
:param block: Block to unfold. | [
"Unfold",
"parent",
"fold",
"trigger",
"if",
"the",
"block",
"is",
"collapsed",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L188-L202 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.word_under_cursor | def word_under_cursor(self, select_whole_word=False, text_cursor=None):
"""
Gets the word under cursor using the separators defined by
:attr:`spyder.plugins.editor.widgets.codeeditor.CodeEditor.word_separators`.
FIXME: This is not working because CodeEditor have no attribute
wor... | python | def word_under_cursor(self, select_whole_word=False, text_cursor=None):
"""
Gets the word under cursor using the separators defined by
:attr:`spyder.plugins.editor.widgets.codeeditor.CodeEditor.word_separators`.
FIXME: This is not working because CodeEditor have no attribute
wor... | [
"def",
"word_under_cursor",
"(",
"self",
",",
"select_whole_word",
"=",
"False",
",",
"text_cursor",
"=",
"None",
")",
":",
"editor",
"=",
"self",
".",
"_editor",
"if",
"not",
"text_cursor",
":",
"text_cursor",
"=",
"editor",
".",
"textCursor",
"(",
")",
"... | Gets the word under cursor using the separators defined by
:attr:`spyder.plugins.editor.widgets.codeeditor.CodeEditor.word_separators`.
FIXME: This is not working because CodeEditor have no attribute
word_separators
.. note: Instead of returning the word string, this function returns
... | [
"Gets",
"the",
"word",
"under",
"cursor",
"using",
"the",
"separators",
"defined",
"by",
":",
"attr",
":",
"spyder",
".",
"plugins",
".",
"editor",
".",
"widgets",
".",
"codeeditor",
".",
"CodeEditor",
".",
"word_separators",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L208-L265 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.word_under_mouse_cursor | def word_under_mouse_cursor(self):
"""
Selects the word under the **mouse** cursor.
:return: A QTextCursor with the word under mouse cursor selected.
"""
editor = self._editor
text_cursor = editor.cursorForPosition(editor._last_mouse_pos)
text_cursor = self.word_... | python | def word_under_mouse_cursor(self):
"""
Selects the word under the **mouse** cursor.
:return: A QTextCursor with the word under mouse cursor selected.
"""
editor = self._editor
text_cursor = editor.cursorForPosition(editor._last_mouse_pos)
text_cursor = self.word_... | [
"def",
"word_under_mouse_cursor",
"(",
"self",
")",
":",
"editor",
"=",
"self",
".",
"_editor",
"text_cursor",
"=",
"editor",
".",
"cursorForPosition",
"(",
"editor",
".",
"_last_mouse_pos",
")",
"text_cursor",
"=",
"self",
".",
"word_under_cursor",
"(",
"True",... | Selects the word under the **mouse** cursor.
:return: A QTextCursor with the word under mouse cursor selected. | [
"Selects",
"the",
"word",
"under",
"the",
"**",
"mouse",
"**",
"cursor",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L267-L276 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.cursor_position | def cursor_position(self):
"""
Returns the QTextCursor position. The position is a tuple made up of
the line number (0 based) and the column number (0 based).
:return: tuple(line, column)
"""
return (self._editor.textCursor().blockNumber(),
self._editor.t... | python | def cursor_position(self):
"""
Returns the QTextCursor position. The position is a tuple made up of
the line number (0 based) and the column number (0 based).
:return: tuple(line, column)
"""
return (self._editor.textCursor().blockNumber(),
self._editor.t... | [
"def",
"cursor_position",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_editor",
".",
"textCursor",
"(",
")",
".",
"blockNumber",
"(",
")",
",",
"self",
".",
"_editor",
".",
"textCursor",
"(",
")",
".",
"columnNumber",
"(",
")",
")"
] | Returns the QTextCursor position. The position is a tuple made up of
the line number (0 based) and the column number (0 based).
:return: tuple(line, column) | [
"Returns",
"the",
"QTextCursor",
"position",
".",
"The",
"position",
"is",
"a",
"tuple",
"made",
"up",
"of",
"the",
"line",
"number",
"(",
"0",
"based",
")",
"and",
"the",
"column",
"number",
"(",
"0",
"based",
")",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L278-L286 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.line_text | def line_text(self, line_nbr):
"""
Gets the text of the specified line.
:param line_nbr: The line number of the text to get
:return: Entire line's text
:rtype: str
"""
doc = self._editor.document()
block = doc.findBlockByNumber(line_nbr)
return b... | python | def line_text(self, line_nbr):
"""
Gets the text of the specified line.
:param line_nbr: The line number of the text to get
:return: Entire line's text
:rtype: str
"""
doc = self._editor.document()
block = doc.findBlockByNumber(line_nbr)
return b... | [
"def",
"line_text",
"(",
"self",
",",
"line_nbr",
")",
":",
"doc",
"=",
"self",
".",
"_editor",
".",
"document",
"(",
")",
"block",
"=",
"doc",
".",
"findBlockByNumber",
"(",
"line_nbr",
")",
"return",
"block",
".",
"text",
"(",
")"
] | Gets the text of the specified line.
:param line_nbr: The line number of the text to get
:return: Entire line's text
:rtype: str | [
"Gets",
"the",
"text",
"of",
"the",
"specified",
"line",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L312-L323 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.set_line_text | def set_line_text(self, line_nbr, new_text):
"""
Replace an entire line with ``new_text``.
:param line_nbr: line number of the line to change.
:param new_text: The replacement text.
"""
editor = self._editor
text_cursor = self._move_cursor_to(line_nbr)
t... | python | def set_line_text(self, line_nbr, new_text):
"""
Replace an entire line with ``new_text``.
:param line_nbr: line number of the line to change.
:param new_text: The replacement text.
"""
editor = self._editor
text_cursor = self._move_cursor_to(line_nbr)
t... | [
"def",
"set_line_text",
"(",
"self",
",",
"line_nbr",
",",
"new_text",
")",
":",
"editor",
"=",
"self",
".",
"_editor",
"text_cursor",
"=",
"self",
".",
"_move_cursor_to",
"(",
"line_nbr",
")",
"text_cursor",
".",
"select",
"(",
"text_cursor",
".",
"LineUnde... | Replace an entire line with ``new_text``.
:param line_nbr: line number of the line to change.
:param new_text: The replacement text. | [
"Replace",
"an",
"entire",
"line",
"with",
"new_text",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L342-L354 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.remove_last_line | def remove_last_line(self):
"""Removes the last line of the document."""
editor = self._editor
text_cursor = editor.textCursor()
text_cursor.movePosition(text_cursor.End, text_cursor.MoveAnchor)
text_cursor.select(text_cursor.LineUnderCursor)
text_cursor.removeSelectedTex... | python | def remove_last_line(self):
"""Removes the last line of the document."""
editor = self._editor
text_cursor = editor.textCursor()
text_cursor.movePosition(text_cursor.End, text_cursor.MoveAnchor)
text_cursor.select(text_cursor.LineUnderCursor)
text_cursor.removeSelectedTex... | [
"def",
"remove_last_line",
"(",
"self",
")",
":",
"editor",
"=",
"self",
".",
"_editor",
"text_cursor",
"=",
"editor",
".",
"textCursor",
"(",
")",
"text_cursor",
".",
"movePosition",
"(",
"text_cursor",
".",
"End",
",",
"text_cursor",
".",
"MoveAnchor",
")"... | Removes the last line of the document. | [
"Removes",
"the",
"last",
"line",
"of",
"the",
"document",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L356-L364 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.clean_document | def clean_document(self):
"""
Removes trailing whitespaces and ensure one single blank line at the
end of the QTextDocument.
FIXME: It was deprecated in pyqode, maybe It should be deleted
"""
editor = self._editor
value = editor.verticalScrollBar().value()
... | python | def clean_document(self):
"""
Removes trailing whitespaces and ensure one single blank line at the
end of the QTextDocument.
FIXME: It was deprecated in pyqode, maybe It should be deleted
"""
editor = self._editor
value = editor.verticalScrollBar().value()
... | [
"def",
"clean_document",
"(",
"self",
")",
":",
"editor",
"=",
"self",
".",
"_editor",
"value",
"=",
"editor",
".",
"verticalScrollBar",
"(",
")",
".",
"value",
"(",
")",
"pos",
"=",
"self",
".",
"cursor_position",
"(",
")",
"editor",
".",
"textCursor",
... | Removes trailing whitespaces and ensure one single blank line at the
end of the QTextDocument.
FIXME: It was deprecated in pyqode, maybe It should be deleted | [
"Removes",
"trailing",
"whitespaces",
"and",
"ensure",
"one",
"single",
"blank",
"line",
"at",
"the",
"end",
"of",
"the",
"QTextDocument",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L366-L427 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.select_whole_line | def select_whole_line(self, line=None, apply_selection=True):
"""
Selects an entire line.
:param line: Line to select. If None, the current line will be selected
:param apply_selection: True to apply selection on the text editor
widget, False to just return the text cursor w... | python | def select_whole_line(self, line=None, apply_selection=True):
"""
Selects an entire line.
:param line: Line to select. If None, the current line will be selected
:param apply_selection: True to apply selection on the text editor
widget, False to just return the text cursor w... | [
"def",
"select_whole_line",
"(",
"self",
",",
"line",
"=",
"None",
",",
"apply_selection",
"=",
"True",
")",
":",
"if",
"line",
"is",
"None",
":",
"line",
"=",
"self",
".",
"current_line_nbr",
"(",
")",
"return",
"self",
".",
"select_lines",
"(",
"line",... | Selects an entire line.
:param line: Line to select. If None, the current line will be selected
:param apply_selection: True to apply selection on the text editor
widget, False to just return the text cursor without setting it
on the editor.
:return: QTextCursor | [
"Selects",
"an",
"entire",
"line",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L429-L441 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.selection_range | def selection_range(self):
"""
Returns the selected lines boundaries (start line, end line)
:return: tuple(int, int)
"""
editor = self._editor
doc = editor.document()
start = doc.findBlock(
editor.textCursor().selectionStart()).blockNumber()
e... | python | def selection_range(self):
"""
Returns the selected lines boundaries (start line, end line)
:return: tuple(int, int)
"""
editor = self._editor
doc = editor.document()
start = doc.findBlock(
editor.textCursor().selectionStart()).blockNumber()
e... | [
"def",
"selection_range",
"(",
"self",
")",
":",
"editor",
"=",
"self",
".",
"_editor",
"doc",
"=",
"editor",
".",
"document",
"(",
")",
"start",
"=",
"doc",
".",
"findBlock",
"(",
"editor",
".",
"textCursor",
"(",
")",
".",
"selectionStart",
"(",
")",... | Returns the selected lines boundaries (start line, end line)
:return: tuple(int, int) | [
"Returns",
"the",
"selected",
"lines",
"boundaries",
"(",
"start",
"line",
"end",
"line",
")"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L492-L508 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.line_pos_from_number | def line_pos_from_number(self, line_number):
"""
Computes line position on Y-Axis (at the center of the line) from line
number.
:param line_number: The line number for which we want to know the
position in pixels.
:return: The center position of the l... | python | def line_pos_from_number(self, line_number):
"""
Computes line position on Y-Axis (at the center of the line) from line
number.
:param line_number: The line number for which we want to know the
position in pixels.
:return: The center position of the l... | [
"def",
"line_pos_from_number",
"(",
"self",
",",
"line_number",
")",
":",
"editor",
"=",
"self",
".",
"_editor",
"block",
"=",
"editor",
".",
"document",
"(",
")",
".",
"findBlockByNumber",
"(",
"line_number",
")",
"if",
"block",
".",
"isValid",
"(",
")",
... | Computes line position on Y-Axis (at the center of the line) from line
number.
:param line_number: The line number for which we want to know the
position in pixels.
:return: The center position of the line. | [
"Computes",
"line",
"position",
"on",
"Y",
"-",
"Axis",
"(",
"at",
"the",
"center",
"of",
"the",
"line",
")",
"from",
"line",
"number",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L510-L528 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.line_nbr_from_position | def line_nbr_from_position(self, y_pos):
"""
Returns the line number from the y_pos.
:param y_pos: Y pos in the editor
:return: Line number (0 based), -1 if out of range
"""
editor = self._editor
height = editor.fontMetrics().height()
for top, line, block... | python | def line_nbr_from_position(self, y_pos):
"""
Returns the line number from the y_pos.
:param y_pos: Y pos in the editor
:return: Line number (0 based), -1 if out of range
"""
editor = self._editor
height = editor.fontMetrics().height()
for top, line, block... | [
"def",
"line_nbr_from_position",
"(",
"self",
",",
"y_pos",
")",
":",
"editor",
"=",
"self",
".",
"_editor",
"height",
"=",
"editor",
".",
"fontMetrics",
"(",
")",
".",
"height",
"(",
")",
"for",
"top",
",",
"line",
",",
"block",
"in",
"editor",
".",
... | Returns the line number from the y_pos.
:param y_pos: Y pos in the editor
:return: Line number (0 based), -1 if out of range | [
"Returns",
"the",
"line",
"number",
"from",
"the",
"y_pos",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L530-L542 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.mark_whole_doc_dirty | def mark_whole_doc_dirty(self):
"""
Marks the whole document as dirty to force a full refresh. **SLOW**
"""
text_cursor = self._editor.textCursor()
text_cursor.select(text_cursor.Document)
self._editor.document().markContentsDirty(text_cursor.selectionStart(),
... | python | def mark_whole_doc_dirty(self):
"""
Marks the whole document as dirty to force a full refresh. **SLOW**
"""
text_cursor = self._editor.textCursor()
text_cursor.select(text_cursor.Document)
self._editor.document().markContentsDirty(text_cursor.selectionStart(),
... | [
"def",
"mark_whole_doc_dirty",
"(",
"self",
")",
":",
"text_cursor",
"=",
"self",
".",
"_editor",
".",
"textCursor",
"(",
")",
"text_cursor",
".",
"select",
"(",
"text_cursor",
".",
"Document",
")",
"self",
".",
"_editor",
".",
"document",
"(",
")",
".",
... | Marks the whole document as dirty to force a full refresh. **SLOW** | [
"Marks",
"the",
"whole",
"document",
"as",
"dirty",
"to",
"force",
"a",
"full",
"refresh",
".",
"**",
"SLOW",
"**"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L544-L551 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.get_right_character | def get_right_character(self, cursor=None):
"""
Gets the character that is on the right of the text cursor.
:param cursor: QTextCursor that defines the position where the search
will start.
"""
next_char = self.get_right_word(cursor=cursor)
if len(next_char):... | python | def get_right_character(self, cursor=None):
"""
Gets the character that is on the right of the text cursor.
:param cursor: QTextCursor that defines the position where the search
will start.
"""
next_char = self.get_right_word(cursor=cursor)
if len(next_char):... | [
"def",
"get_right_character",
"(",
"self",
",",
"cursor",
"=",
"None",
")",
":",
"next_char",
"=",
"self",
".",
"get_right_word",
"(",
"cursor",
"=",
"cursor",
")",
"if",
"len",
"(",
"next_char",
")",
":",
"next_char",
"=",
"next_char",
"[",
"0",
"]",
... | Gets the character that is on the right of the text cursor.
:param cursor: QTextCursor that defines the position where the search
will start. | [
"Gets",
"the",
"character",
"that",
"is",
"on",
"the",
"right",
"of",
"the",
"text",
"cursor",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L585-L597 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.insert_text | def insert_text(self, text, keep_position=True):
"""
Inserts text at the cursor position.
:param text: text to insert
:param keep_position: Flag that specifies if the cursor position must
be kept. Pass False for a regular insert (the cursor will be at
the end of ... | python | def insert_text(self, text, keep_position=True):
"""
Inserts text at the cursor position.
:param text: text to insert
:param keep_position: Flag that specifies if the cursor position must
be kept. Pass False for a regular insert (the cursor will be at
the end of ... | [
"def",
"insert_text",
"(",
"self",
",",
"text",
",",
"keep_position",
"=",
"True",
")",
":",
"text_cursor",
"=",
"self",
".",
"_editor",
".",
"textCursor",
"(",
")",
"if",
"keep_position",
":",
"s",
"=",
"text_cursor",
".",
"selectionStart",
"(",
")",
"e... | Inserts text at the cursor position.
:param text: text to insert
:param keep_position: Flag that specifies if the cursor position must
be kept. Pass False for a regular insert (the cursor will be at
the end of the inserted text). | [
"Inserts",
"text",
"at",
"the",
"cursor",
"position",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L599-L616 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.clear_selection | def clear_selection(self):
"""Clears text cursor selection."""
text_cursor = self._editor.textCursor()
text_cursor.clearSelection()
self._editor.setTextCursor(text_cursor) | python | def clear_selection(self):
"""Clears text cursor selection."""
text_cursor = self._editor.textCursor()
text_cursor.clearSelection()
self._editor.setTextCursor(text_cursor) | [
"def",
"clear_selection",
"(",
"self",
")",
":",
"text_cursor",
"=",
"self",
".",
"_editor",
".",
"textCursor",
"(",
")",
"text_cursor",
".",
"clearSelection",
"(",
")",
"self",
".",
"_editor",
".",
"setTextCursor",
"(",
"text_cursor",
")"
] | Clears text cursor selection. | [
"Clears",
"text",
"cursor",
"selection",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L618-L622 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.move_right | def move_right(self, keep_anchor=False, nb_chars=1):
"""
Moves the cursor on the right.
:param keep_anchor: True to keep anchor (to select text) or False to
move the anchor (no selection)
:param nb_chars: Number of characters to move.
"""
text_cursor = self._... | python | def move_right(self, keep_anchor=False, nb_chars=1):
"""
Moves the cursor on the right.
:param keep_anchor: True to keep anchor (to select text) or False to
move the anchor (no selection)
:param nb_chars: Number of characters to move.
"""
text_cursor = self._... | [
"def",
"move_right",
"(",
"self",
",",
"keep_anchor",
"=",
"False",
",",
"nb_chars",
"=",
"1",
")",
":",
"text_cursor",
"=",
"self",
".",
"_editor",
".",
"textCursor",
"(",
")",
"text_cursor",
".",
"movePosition",
"(",
"text_cursor",
".",
"Right",
",",
"... | Moves the cursor on the right.
:param keep_anchor: True to keep anchor (to select text) or False to
move the anchor (no selection)
:param nb_chars: Number of characters to move. | [
"Moves",
"the",
"cursor",
"on",
"the",
"right",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L624-L636 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextHelper.select_extended_word | def select_extended_word(self, continuation_chars=('.',)):
"""
Performs extended word selection. Extended selection consists in
selecting the word under cursor and any other words that are linked
by a ``continuation_chars``.
:param continuation_chars: the list of characters that... | python | def select_extended_word(self, continuation_chars=('.',)):
"""
Performs extended word selection. Extended selection consists in
selecting the word under cursor and any other words that are linked
by a ``continuation_chars``.
:param continuation_chars: the list of characters that... | [
"def",
"select_extended_word",
"(",
"self",
",",
"continuation_chars",
"=",
"(",
"'.'",
",",
")",
")",
":",
"cursor",
"=",
"self",
".",
"_editor",
".",
"textCursor",
"(",
")",
"original_pos",
"=",
"cursor",
".",
"position",
"(",
")",
"start_pos",
"=",
"N... | Performs extended word selection. Extended selection consists in
selecting the word under cursor and any other words that are linked
by a ``continuation_chars``.
:param continuation_chars: the list of characters that may extend a
word. | [
"Performs",
"extended",
"word",
"selection",
".",
"Extended",
"selection",
"consists",
"in",
"selecting",
"the",
"word",
"under",
"cursor",
"and",
"any",
"other",
"words",
"that",
"are",
"linked",
"by",
"a",
"continuation_chars",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L720-L765 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextBlockHelper.set_state | def set_state(block, state):
"""
Sets the user state, generally used for syntax highlighting.
:param block: block to modify
:param state: new state value.
:return:
"""
if block is None:
return
user_state = block.userState()
if user_sta... | python | def set_state(block, state):
"""
Sets the user state, generally used for syntax highlighting.
:param block: block to modify
:param state: new state value.
:return:
"""
if block is None:
return
user_state = block.userState()
if user_sta... | [
"def",
"set_state",
"(",
"block",
",",
"state",
")",
":",
"if",
"block",
"is",
"None",
":",
"return",
"user_state",
"=",
"block",
".",
"userState",
"(",
")",
"if",
"user_state",
"==",
"-",
"1",
":",
"user_state",
"=",
"0",
"higher_part",
"=",
"user_sta... | Sets the user state, generally used for syntax highlighting.
:param block: block to modify
:param state: new state value.
:return: | [
"Sets",
"the",
"user",
"state",
"generally",
"used",
"for",
"syntax",
"highlighting",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L905-L921 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextBlockHelper.set_fold_lvl | def set_fold_lvl(block, val):
"""
Sets the block fold level.
:param block: block to modify
:param val: The new fold level [0-7]
"""
if block is None:
return
state = block.userState()
if state == -1:
state = 0
if val >= 0x3F... | python | def set_fold_lvl(block, val):
"""
Sets the block fold level.
:param block: block to modify
:param val: The new fold level [0-7]
"""
if block is None:
return
state = block.userState()
if state == -1:
state = 0
if val >= 0x3F... | [
"def",
"set_fold_lvl",
"(",
"block",
",",
"val",
")",
":",
"if",
"block",
"is",
"None",
":",
"return",
"state",
"=",
"block",
".",
"userState",
"(",
")",
"if",
"state",
"==",
"-",
"1",
":",
"state",
"=",
"0",
"if",
"val",
">=",
"0x3FF",
":",
"val... | Sets the block fold level.
:param block: block to modify
:param val: The new fold level [0-7] | [
"Sets",
"the",
"block",
"fold",
"level",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L939-L955 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextBlockHelper.is_fold_trigger | def is_fold_trigger(block):
"""
Checks if the block is a fold trigger.
:param block: block to check
:return: True if the block is a fold trigger (represented as a node in
the fold panel)
"""
if block is None:
return False
state = block.use... | python | def is_fold_trigger(block):
"""
Checks if the block is a fold trigger.
:param block: block to check
:return: True if the block is a fold trigger (represented as a node in
the fold panel)
"""
if block is None:
return False
state = block.use... | [
"def",
"is_fold_trigger",
"(",
"block",
")",
":",
"if",
"block",
"is",
"None",
":",
"return",
"False",
"state",
"=",
"block",
".",
"userState",
"(",
")",
"if",
"state",
"==",
"-",
"1",
":",
"state",
"=",
"0",
"return",
"bool",
"(",
"state",
"&",
"0... | Checks if the block is a fold trigger.
:param block: block to check
:return: True if the block is a fold trigger (represented as a node in
the fold panel) | [
"Checks",
"if",
"the",
"block",
"is",
"a",
"fold",
"trigger",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L958-L971 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextBlockHelper.set_fold_trigger | def set_fold_trigger(block, val):
"""
Set the block fold trigger flag (True means the block is a fold
trigger).
:param block: block to set
:param val: value to set
"""
if block is None:
return
state = block.userState()
if state == -1:
... | python | def set_fold_trigger(block, val):
"""
Set the block fold trigger flag (True means the block is a fold
trigger).
:param block: block to set
:param val: value to set
"""
if block is None:
return
state = block.userState()
if state == -1:
... | [
"def",
"set_fold_trigger",
"(",
"block",
",",
"val",
")",
":",
"if",
"block",
"is",
"None",
":",
"return",
"state",
"=",
"block",
".",
"userState",
"(",
")",
"if",
"state",
"==",
"-",
"1",
":",
"state",
"=",
"0",
"state",
"&=",
"0x7BFFFFFF",
"state",... | Set the block fold trigger flag (True means the block is a fold
trigger).
:param block: block to set
:param val: value to set | [
"Set",
"the",
"block",
"fold",
"trigger",
"flag",
"(",
"True",
"means",
"the",
"block",
"is",
"a",
"fold",
"trigger",
")",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L974-L989 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextBlockHelper.is_collapsed | def is_collapsed(block):
"""
Checks if the block is expanded or collased.
:param block: QTextBlock
:return: False for an open trigger, True for for closed trigger
"""
if block is None:
return False
state = block.userState()
if state == -1:
... | python | def is_collapsed(block):
"""
Checks if the block is expanded or collased.
:param block: QTextBlock
:return: False for an open trigger, True for for closed trigger
"""
if block is None:
return False
state = block.userState()
if state == -1:
... | [
"def",
"is_collapsed",
"(",
"block",
")",
":",
"if",
"block",
"is",
"None",
":",
"return",
"False",
"state",
"=",
"block",
".",
"userState",
"(",
")",
"if",
"state",
"==",
"-",
"1",
":",
"state",
"=",
"0",
"return",
"bool",
"(",
"state",
"&",
"0x08... | Checks if the block is expanded or collased.
:param block: QTextBlock
:return: False for an open trigger, True for for closed trigger | [
"Checks",
"if",
"the",
"block",
"is",
"expanded",
"or",
"collased",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L992-L1004 | train |
spyder-ide/spyder | spyder/plugins/editor/utils/editor.py | TextBlockHelper.set_collapsed | def set_collapsed(block, val):
"""
Sets the fold trigger state (collapsed or expanded).
:param block: The block to modify
:param val: The new trigger state (True=collapsed, False=expanded)
"""
if block is None:
return
state = block.userState()
... | python | def set_collapsed(block, val):
"""
Sets the fold trigger state (collapsed or expanded).
:param block: The block to modify
:param val: The new trigger state (True=collapsed, False=expanded)
"""
if block is None:
return
state = block.userState()
... | [
"def",
"set_collapsed",
"(",
"block",
",",
"val",
")",
":",
"if",
"block",
"is",
"None",
":",
"return",
"state",
"=",
"block",
".",
"userState",
"(",
")",
"if",
"state",
"==",
"-",
"1",
":",
"state",
"=",
"0",
"state",
"&=",
"0x77FFFFFF",
"state",
... | Sets the fold trigger state (collapsed or expanded).
:param block: The block to modify
:param val: The new trigger state (True=collapsed, False=expanded) | [
"Sets",
"the",
"fold",
"trigger",
"state",
"(",
"collapsed",
"or",
"expanded",
")",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/utils/editor.py#L1007-L1021 | train |
spyder-ide/spyder | spyder/utils/external/binaryornot/helpers.py | get_starting_chunk | def get_starting_chunk(filename, length=1024):
"""
:param filename: File to open and get the first little chunk of.
:param length: Number of bytes to read, default 1024.
:returns: Starting chunk of bytes.
"""
# Ensure we open the file in binary mode
with open(filename, 'rb') as f:
ch... | python | def get_starting_chunk(filename, length=1024):
"""
:param filename: File to open and get the first little chunk of.
:param length: Number of bytes to read, default 1024.
:returns: Starting chunk of bytes.
"""
# Ensure we open the file in binary mode
with open(filename, 'rb') as f:
ch... | [
"def",
"get_starting_chunk",
"(",
"filename",
",",
"length",
"=",
"1024",
")",
":",
"# Ensure we open the file in binary mode",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"chunk",
"=",
"f",
".",
"read",
"(",
"length",
")",
"return",
... | :param filename: File to open and get the first little chunk of.
:param length: Number of bytes to read, default 1024.
:returns: Starting chunk of bytes. | [
":",
"param",
"filename",
":",
"File",
"to",
"open",
"and",
"get",
"the",
"first",
"little",
"chunk",
"of",
".",
":",
"param",
"length",
":",
"Number",
"of",
"bytes",
"to",
"read",
"default",
"1024",
".",
":",
"returns",
":",
"Starting",
"chunk",
"of",... | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/external/binaryornot/helpers.py#L34-L43 | train |
spyder-ide/spyder | spyder/utils/external/binaryornot/helpers.py | is_binary_string | def is_binary_string(bytes_to_check):
"""
Uses a simplified version of the Perl detection algorithm,
based roughly on Eli Bendersky's translation to Python:
https://eli.thegreenplace.net/2011/10/19/perls-guess-if-file-is-text-or-binary-implemented-in-python/
This is biased slightly more in favour o... | python | def is_binary_string(bytes_to_check):
"""
Uses a simplified version of the Perl detection algorithm,
based roughly on Eli Bendersky's translation to Python:
https://eli.thegreenplace.net/2011/10/19/perls-guess-if-file-is-text-or-binary-implemented-in-python/
This is biased slightly more in favour o... | [
"def",
"is_binary_string",
"(",
"bytes_to_check",
")",
":",
"# Empty files are considered text files",
"if",
"not",
"bytes_to_check",
":",
"return",
"False",
"# Now check for a high percentage of ASCII control characters",
"# Binary if control chars are > 30% of the string",
"low_chars... | Uses a simplified version of the Perl detection algorithm,
based roughly on Eli Bendersky's translation to Python:
https://eli.thegreenplace.net/2011/10/19/perls-guess-if-file-is-text-or-binary-implemented-in-python/
This is biased slightly more in favour of deeming files as text
files than the Perl al... | [
"Uses",
"a",
"simplified",
"version",
"of",
"the",
"Perl",
"detection",
"algorithm",
"based",
"roughly",
"on",
"Eli",
"Bendersky",
"s",
"translation",
"to",
"Python",
":",
"https",
":",
"//",
"eli",
".",
"thegreenplace",
".",
"net",
"/",
"2011",
"/",
"10",... | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/external/binaryornot/helpers.py#L57-L138 | train |
spyder-ide/spyder | spyder/widgets/status.py | StatusBarWidget.set_value | def set_value(self, value):
"""Set formatted text value."""
self.value = value
if self.isVisible():
self.label_value.setText(value) | python | def set_value(self, value):
"""Set formatted text value."""
self.value = value
if self.isVisible():
self.label_value.setText(value) | [
"def",
"set_value",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"value",
"=",
"value",
"if",
"self",
".",
"isVisible",
"(",
")",
":",
"self",
".",
"label_value",
".",
"setText",
"(",
"value",
")"
] | Set formatted text value. | [
"Set",
"formatted",
"text",
"value",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/status.py#L74-L78 | train |
spyder-ide/spyder | spyder/widgets/status.py | BaseTimerStatus.setVisible | def setVisible(self, value):
"""Override Qt method to stops timers if widget is not visible."""
if self.timer is not None:
if value:
self.timer.start(self._interval)
else:
self.timer.stop()
super(BaseTimerStatus, self).setVisible(value) | python | def setVisible(self, value):
"""Override Qt method to stops timers if widget is not visible."""
if self.timer is not None:
if value:
self.timer.start(self._interval)
else:
self.timer.stop()
super(BaseTimerStatus, self).setVisible(value) | [
"def",
"setVisible",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"timer",
"is",
"not",
"None",
":",
"if",
"value",
":",
"self",
".",
"timer",
".",
"start",
"(",
"self",
".",
"_interval",
")",
"else",
":",
"self",
".",
"timer",
".",
"s... | Override Qt method to stops timers if widget is not visible. | [
"Override",
"Qt",
"method",
"to",
"stops",
"timers",
"if",
"widget",
"is",
"not",
"visible",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/status.py#L102-L109 | train |
spyder-ide/spyder | spyder/widgets/status.py | BaseTimerStatus.set_interval | def set_interval(self, interval):
"""Set timer interval (ms)."""
self._interval = interval
if self.timer is not None:
self.timer.setInterval(interval) | python | def set_interval(self, interval):
"""Set timer interval (ms)."""
self._interval = interval
if self.timer is not None:
self.timer.setInterval(interval) | [
"def",
"set_interval",
"(",
"self",
",",
"interval",
")",
":",
"self",
".",
"_interval",
"=",
"interval",
"if",
"self",
".",
"timer",
"is",
"not",
"None",
":",
"self",
".",
"timer",
".",
"setInterval",
"(",
"interval",
")"
] | Set timer interval (ms). | [
"Set",
"timer",
"interval",
"(",
"ms",
")",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/status.py#L111-L115 | train |
spyder-ide/spyder | spyder/widgets/status.py | MemoryStatus.get_value | def get_value(self):
"""Return memory usage."""
from spyder.utils.system import memory_usage
text = '%d%%' % memory_usage()
return 'Mem ' + text.rjust(3) | python | def get_value(self):
"""Return memory usage."""
from spyder.utils.system import memory_usage
text = '%d%%' % memory_usage()
return 'Mem ' + text.rjust(3) | [
"def",
"get_value",
"(",
"self",
")",
":",
"from",
"spyder",
".",
"utils",
".",
"system",
"import",
"memory_usage",
"text",
"=",
"'%d%%'",
"%",
"memory_usage",
"(",
")",
"return",
"'Mem '",
"+",
"text",
".",
"rjust",
"(",
"3",
")"
] | Return memory usage. | [
"Return",
"memory",
"usage",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/status.py#L150-L154 | train |
spyder-ide/spyder | spyder/plugins/help/utils/sphinxify.py | warning | def warning(message, css_path=CSS_PATH):
"""Print a warning message on the rich text view"""
env = Environment()
env.loader = FileSystemLoader(osp.join(CONFDIR_PATH, 'templates'))
warning = env.get_template("warning.html")
return warning.render(css_path=css_path, text=message) | python | def warning(message, css_path=CSS_PATH):
"""Print a warning message on the rich text view"""
env = Environment()
env.loader = FileSystemLoader(osp.join(CONFDIR_PATH, 'templates'))
warning = env.get_template("warning.html")
return warning.render(css_path=css_path, text=message) | [
"def",
"warning",
"(",
"message",
",",
"css_path",
"=",
"CSS_PATH",
")",
":",
"env",
"=",
"Environment",
"(",
")",
"env",
".",
"loader",
"=",
"FileSystemLoader",
"(",
"osp",
".",
"join",
"(",
"CONFDIR_PATH",
",",
"'templates'",
")",
")",
"warning",
"=",
... | Print a warning message on the rich text view | [
"Print",
"a",
"warning",
"message",
"on",
"the",
"rich",
"text",
"view"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/utils/sphinxify.py#L77-L82 | train |
spyder-ide/spyder | spyder/plugins/help/utils/sphinxify.py | usage | def usage(title, message, tutorial_message, tutorial, css_path=CSS_PATH):
"""Print a usage message on the rich text view"""
env = Environment()
env.loader = FileSystemLoader(osp.join(CONFDIR_PATH, 'templates'))
usage = env.get_template("usage.html")
return usage.render(css_path=css_path, title=title... | python | def usage(title, message, tutorial_message, tutorial, css_path=CSS_PATH):
"""Print a usage message on the rich text view"""
env = Environment()
env.loader = FileSystemLoader(osp.join(CONFDIR_PATH, 'templates'))
usage = env.get_template("usage.html")
return usage.render(css_path=css_path, title=title... | [
"def",
"usage",
"(",
"title",
",",
"message",
",",
"tutorial_message",
",",
"tutorial",
",",
"css_path",
"=",
"CSS_PATH",
")",
":",
"env",
"=",
"Environment",
"(",
")",
"env",
".",
"loader",
"=",
"FileSystemLoader",
"(",
"osp",
".",
"join",
"(",
"CONFDIR... | Print a usage message on the rich text view | [
"Print",
"a",
"usage",
"message",
"on",
"the",
"rich",
"text",
"view"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/utils/sphinxify.py#L85-L91 | train |
spyder-ide/spyder | spyder/plugins/help/utils/sphinxify.py | generate_context | def generate_context(name='', argspec='', note='', math=False, collapse=False,
img_path='', css_path=CSS_PATH):
"""
Generate the html_context dictionary for our Sphinx conf file.
This is a set of variables to be passed to the Jinja template engine and
that are used to control h... | python | def generate_context(name='', argspec='', note='', math=False, collapse=False,
img_path='', css_path=CSS_PATH):
"""
Generate the html_context dictionary for our Sphinx conf file.
This is a set of variables to be passed to the Jinja template engine and
that are used to control h... | [
"def",
"generate_context",
"(",
"name",
"=",
"''",
",",
"argspec",
"=",
"''",
",",
"note",
"=",
"''",
",",
"math",
"=",
"False",
",",
"collapse",
"=",
"False",
",",
"img_path",
"=",
"''",
",",
"css_path",
"=",
"CSS_PATH",
")",
":",
"if",
"img_path",
... | Generate the html_context dictionary for our Sphinx conf file.
This is a set of variables to be passed to the Jinja template engine and
that are used to control how the webpage is rendered in connection with
Sphinx
Parameters
----------
name : str
Object's name.
note : str
... | [
"Generate",
"the",
"html_context",
"dictionary",
"for",
"our",
"Sphinx",
"conf",
"file",
".",
"This",
"is",
"a",
"set",
"of",
"variables",
"to",
"be",
"passed",
"to",
"the",
"Jinja",
"template",
"engine",
"and",
"that",
"are",
"used",
"to",
"control",
"how... | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/utils/sphinxify.py#L94-L146 | train |
spyder-ide/spyder | spyder/plugins/help/utils/sphinxify.py | sphinxify | def sphinxify(docstring, context, buildername='html'):
"""
Runs Sphinx on a docstring and outputs the processed documentation.
Parameters
----------
docstring : str
a ReST-formatted docstring
context : dict
Variables to be passed to the layout template to control how its
... | python | def sphinxify(docstring, context, buildername='html'):
"""
Runs Sphinx on a docstring and outputs the processed documentation.
Parameters
----------
docstring : str
a ReST-formatted docstring
context : dict
Variables to be passed to the layout template to control how its
... | [
"def",
"sphinxify",
"(",
"docstring",
",",
"context",
",",
"buildername",
"=",
"'html'",
")",
":",
"srcdir",
"=",
"mkdtemp",
"(",
")",
"srcdir",
"=",
"encoding",
".",
"to_unicode_from_fs",
"(",
"srcdir",
")",
"destdir",
"=",
"osp",
".",
"join",
"(",
"src... | Runs Sphinx on a docstring and outputs the processed documentation.
Parameters
----------
docstring : str
a ReST-formatted docstring
context : dict
Variables to be passed to the layout template to control how its
rendered (through the Sphinx variable *html_context*).
build... | [
"Runs",
"Sphinx",
"on",
"a",
"docstring",
"and",
"outputs",
"the",
"processed",
"documentation",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/utils/sphinxify.py#L149-L239 | train |
spyder-ide/spyder | spyder/plugins/help/utils/sphinxify.py | generate_configuration | def generate_configuration(directory):
"""
Generates a Sphinx configuration in `directory`.
Parameters
----------
directory : str
Base directory to use
"""
# conf.py file for Sphinx
conf = osp.join(get_module_source_path('spyder.plugins.help.utils'),
'co... | python | def generate_configuration(directory):
"""
Generates a Sphinx configuration in `directory`.
Parameters
----------
directory : str
Base directory to use
"""
# conf.py file for Sphinx
conf = osp.join(get_module_source_path('spyder.plugins.help.utils'),
'co... | [
"def",
"generate_configuration",
"(",
"directory",
")",
":",
"# conf.py file for Sphinx",
"conf",
"=",
"osp",
".",
"join",
"(",
"get_module_source_path",
"(",
"'spyder.plugins.help.utils'",
")",
",",
"'conf.py'",
")",
"# Docstring layout page (in Jinja):",
"layout",
"=",
... | Generates a Sphinx configuration in `directory`.
Parameters
----------
directory : str
Base directory to use | [
"Generates",
"a",
"Sphinx",
"configuration",
"in",
"directory",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/utils/sphinxify.py#L242-L264 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/status.py | EOLStatus.update_eol | def update_eol(self, os_name):
"""Update end of line status."""
os_name = to_text_string(os_name)
value = {"nt": "CRLF", "posix": "LF"}.get(os_name, "CR")
self.set_value(value) | python | def update_eol(self, os_name):
"""Update end of line status."""
os_name = to_text_string(os_name)
value = {"nt": "CRLF", "posix": "LF"}.get(os_name, "CR")
self.set_value(value) | [
"def",
"update_eol",
"(",
"self",
",",
"os_name",
")",
":",
"os_name",
"=",
"to_text_string",
"(",
"os_name",
")",
"value",
"=",
"{",
"\"nt\"",
":",
"\"CRLF\"",
",",
"\"posix\"",
":",
"\"LF\"",
"}",
".",
"get",
"(",
"os_name",
",",
"\"CR\"",
")",
"self... | Update end of line status. | [
"Update",
"end",
"of",
"line",
"status",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/status.py#L34-L38 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/status.py | EncodingStatus.update_encoding | def update_encoding(self, encoding):
"""Update encoding of current file."""
value = str(encoding).upper()
self.set_value(value) | python | def update_encoding(self, encoding):
"""Update encoding of current file."""
value = str(encoding).upper()
self.set_value(value) | [
"def",
"update_encoding",
"(",
"self",
",",
"encoding",
")",
":",
"value",
"=",
"str",
"(",
"encoding",
")",
".",
"upper",
"(",
")",
"self",
".",
"set_value",
"(",
"value",
")"
] | Update encoding of current file. | [
"Update",
"encoding",
"of",
"current",
"file",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/status.py#L45-L48 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/status.py | CursorPositionStatus.update_cursor_position | def update_cursor_position(self, line, index):
"""Update cursor position."""
value = 'Line {}, Col {}'.format(line + 1, index + 1)
self.set_value(value) | python | def update_cursor_position(self, line, index):
"""Update cursor position."""
value = 'Line {}, Col {}'.format(line + 1, index + 1)
self.set_value(value) | [
"def",
"update_cursor_position",
"(",
"self",
",",
"line",
",",
"index",
")",
":",
"value",
"=",
"'Line {}, Col {}'",
".",
"format",
"(",
"line",
"+",
"1",
",",
"index",
"+",
"1",
")",
"self",
".",
"set_value",
"(",
"value",
")"
] | Update cursor position. | [
"Update",
"cursor",
"position",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/status.py#L55-L58 | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/status.py | VCSStatus.update_vcs | def update_vcs(self, fname, index):
"""Update vcs status."""
fpath = os.path.dirname(fname)
branches, branch, files_modified = get_git_refs(fpath)
text = branch if branch else ''
if len(files_modified):
text = text + ' [{}]'.format(len(files_modified))
self.... | python | def update_vcs(self, fname, index):
"""Update vcs status."""
fpath = os.path.dirname(fname)
branches, branch, files_modified = get_git_refs(fpath)
text = branch if branch else ''
if len(files_modified):
text = text + ' [{}]'.format(len(files_modified))
self.... | [
"def",
"update_vcs",
"(",
"self",
",",
"fname",
",",
"index",
")",
":",
"fpath",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"fname",
")",
"branches",
",",
"branch",
",",
"files_modified",
"=",
"get_git_refs",
"(",
"fpath",
")",
"text",
"=",
"branch",... | Update vcs status. | [
"Update",
"vcs",
"status",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/status.py#L73-L83 | train |
spyder-ide/spyder | spyder/plugins/variableexplorer/plugin.py | VariableExplorer.get_settings | def get_settings(self):
"""
Retrieve all Variable Explorer configuration settings.
Specifically, return the settings in CONF_SECTION with keys in
REMOTE_SETTINGS, and the setting 'dataframe_format'.
Returns:
dict: settings
"""
... | python | def get_settings(self):
"""
Retrieve all Variable Explorer configuration settings.
Specifically, return the settings in CONF_SECTION with keys in
REMOTE_SETTINGS, and the setting 'dataframe_format'.
Returns:
dict: settings
"""
... | [
"def",
"get_settings",
"(",
"self",
")",
":",
"settings",
"=",
"{",
"}",
"for",
"name",
"in",
"REMOTE_SETTINGS",
":",
"settings",
"[",
"name",
"]",
"=",
"self",
".",
"get_option",
"(",
"name",
")",
"# dataframe_format is stored without percent sign in config\r",
... | Retrieve all Variable Explorer configuration settings.
Specifically, return the settings in CONF_SECTION with keys in
REMOTE_SETTINGS, and the setting 'dataframe_format'.
Returns:
dict: settings | [
"Retrieve",
"all",
"Variable",
"Explorer",
"configuration",
"settings",
".",
"Specifically",
"return",
"the",
"settings",
"in",
"CONF_SECTION",
"with",
"keys",
"in",
"REMOTE_SETTINGS",
"and",
"the",
"setting",
"dataframe_format",
".",
"Returns",
":",
"dict",
":",
... | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/plugin.py#L59-L77 | train |
spyder-ide/spyder | spyder/plugins/variableexplorer/plugin.py | VariableExplorer.change_option | def change_option(self, option_name, new_value):
"""
Change a config option.
This function is called if sig_option_changed is received. If the
option changed is the dataframe format, then the leading '%' character
is stripped (because it can't be stored in the user config)... | python | def change_option(self, option_name, new_value):
"""
Change a config option.
This function is called if sig_option_changed is received. If the
option changed is the dataframe format, then the leading '%' character
is stripped (because it can't be stored in the user config)... | [
"def",
"change_option",
"(",
"self",
",",
"option_name",
",",
"new_value",
")",
":",
"if",
"option_name",
"==",
"'dataframe_format'",
":",
"assert",
"new_value",
".",
"startswith",
"(",
"'%'",
")",
"new_value",
"=",
"new_value",
"[",
"1",
":",
"]",
"self",
... | Change a config option.
This function is called if sig_option_changed is received. If the
option changed is the dataframe format, then the leading '%' character
is stripped (because it can't be stored in the user config). Then,
the signal is emitted again, so that the new value is ... | [
"Change",
"a",
"config",
"option",
".",
"This",
"function",
"is",
"called",
"if",
"sig_option_changed",
"is",
"received",
".",
"If",
"the",
"option",
"changed",
"is",
"the",
"dataframe",
"format",
"then",
"the",
"leading",
"%",
"character",
"is",
"stripped",
... | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/plugin.py#L80-L93 | train |
spyder-ide/spyder | spyder/plugins/variableexplorer/plugin.py | VariableExplorer.free_memory | def free_memory(self):
"""Free memory signal."""
self.main.free_memory()
QTimer.singleShot(self.INITIAL_FREE_MEMORY_TIME_TRIGGER,
lambda: self.main.free_memory())
QTimer.singleShot(self.SECONDARY_FREE_MEMORY_TIME_TRIGGER,
lambda: ... | python | def free_memory(self):
"""Free memory signal."""
self.main.free_memory()
QTimer.singleShot(self.INITIAL_FREE_MEMORY_TIME_TRIGGER,
lambda: self.main.free_memory())
QTimer.singleShot(self.SECONDARY_FREE_MEMORY_TIME_TRIGGER,
lambda: ... | [
"def",
"free_memory",
"(",
"self",
")",
":",
"self",
".",
"main",
".",
"free_memory",
"(",
")",
"QTimer",
".",
"singleShot",
"(",
"self",
".",
"INITIAL_FREE_MEMORY_TIME_TRIGGER",
",",
"lambda",
":",
"self",
".",
"main",
".",
"free_memory",
"(",
")",
")",
... | Free memory signal. | [
"Free",
"memory",
"signal",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/plugin.py#L96-L102 | train |
spyder-ide/spyder | spyder/plugins/variableexplorer/plugin.py | VariableExplorer.add_shellwidget | def add_shellwidget(self, shellwidget):
"""
Register shell with variable explorer.
This function opens a new NamespaceBrowser for browsing the variables
in the shell.
"""
shellwidget_id = id(shellwidget)
if shellwidget_id not in self.shellwidgets:
... | python | def add_shellwidget(self, shellwidget):
"""
Register shell with variable explorer.
This function opens a new NamespaceBrowser for browsing the variables
in the shell.
"""
shellwidget_id = id(shellwidget)
if shellwidget_id not in self.shellwidgets:
... | [
"def",
"add_shellwidget",
"(",
"self",
",",
"shellwidget",
")",
":",
"shellwidget_id",
"=",
"id",
"(",
"shellwidget",
")",
"if",
"shellwidget_id",
"not",
"in",
"self",
".",
"shellwidgets",
":",
"self",
".",
"options_button",
".",
"setVisible",
"(",
"True",
"... | Register shell with variable explorer.
This function opens a new NamespaceBrowser for browsing the variables
in the shell. | [
"Register",
"shell",
"with",
"variable",
"explorer",
".",
"This",
"function",
"opens",
"a",
"new",
"NamespaceBrowser",
"for",
"browsing",
"the",
"variables",
"in",
"the",
"shell",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/plugin.py#L125-L143 | train |
spyder-ide/spyder | spyder/plugins/variableexplorer/plugin.py | VariableExplorer.import_data | def import_data(self, fname):
"""Import data in current namespace"""
if self.count():
nsb = self.current_widget()
nsb.refresh_table()
nsb.import_data(filenames=fname)
if self.dockwidget and not self.ismaximized:
self.dockwidget.setVi... | python | def import_data(self, fname):
"""Import data in current namespace"""
if self.count():
nsb = self.current_widget()
nsb.refresh_table()
nsb.import_data(filenames=fname)
if self.dockwidget and not self.ismaximized:
self.dockwidget.setVi... | [
"def",
"import_data",
"(",
"self",
",",
"fname",
")",
":",
"if",
"self",
".",
"count",
"(",
")",
":",
"nsb",
"=",
"self",
".",
"current_widget",
"(",
")",
"nsb",
".",
"refresh_table",
"(",
")",
"nsb",
".",
"import_data",
"(",
"filenames",
"=",
"fname... | Import data in current namespace | [
"Import",
"data",
"in",
"current",
"namespace"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/plugin.py#L158-L166 | train |
spyder-ide/spyder | spyder/plugins/help/widgets.py | ObjectComboBox.is_valid | def is_valid(self, qstr=None):
"""Return True if string is valid"""
if not self.help.source_is_console():
return True
if qstr is None:
qstr = self.currentText()
if not re.search(r'^[a-zA-Z0-9_\.]*$', str(qstr), 0):
return False
objtxt = to_text... | python | def is_valid(self, qstr=None):
"""Return True if string is valid"""
if not self.help.source_is_console():
return True
if qstr is None:
qstr = self.currentText()
if not re.search(r'^[a-zA-Z0-9_\.]*$', str(qstr), 0):
return False
objtxt = to_text... | [
"def",
"is_valid",
"(",
"self",
",",
"qstr",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"help",
".",
"source_is_console",
"(",
")",
":",
"return",
"True",
"if",
"qstr",
"is",
"None",
":",
"qstr",
"=",
"self",
".",
"currentText",
"(",
")",
"if... | Return True if string is valid | [
"Return",
"True",
"if",
"string",
"is",
"valid"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/widgets.py#L47-L73 | train |
spyder-ide/spyder | spyder/plugins/help/widgets.py | ObjectComboBox.validate | def validate(self, qstr, editing=True):
"""Reimplemented to avoid formatting actions"""
valid = self.is_valid(qstr)
if self.hasFocus() and valid is not None:
if editing and not valid:
# Combo box text is being modified: invalidate the entry
self.show_t... | python | def validate(self, qstr, editing=True):
"""Reimplemented to avoid formatting actions"""
valid = self.is_valid(qstr)
if self.hasFocus() and valid is not None:
if editing and not valid:
# Combo box text is being modified: invalidate the entry
self.show_t... | [
"def",
"validate",
"(",
"self",
",",
"qstr",
",",
"editing",
"=",
"True",
")",
":",
"valid",
"=",
"self",
".",
"is_valid",
"(",
"qstr",
")",
"if",
"self",
".",
"hasFocus",
"(",
")",
"and",
"valid",
"is",
"not",
"None",
":",
"if",
"editing",
"and",
... | Reimplemented to avoid formatting actions | [
"Reimplemented",
"to",
"avoid",
"formatting",
"actions"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/widgets.py#L78-L91 | train |
spyder-ide/spyder | spyder/plugins/help/widgets.py | RichText.set_font | def set_font(self, font, fixed_font=None):
"""Set font"""
self.webview.set_font(font, fixed_font=fixed_font) | python | def set_font(self, font, fixed_font=None):
"""Set font"""
self.webview.set_font(font, fixed_font=fixed_font) | [
"def",
"set_font",
"(",
"self",
",",
"font",
",",
"fixed_font",
"=",
"None",
")",
":",
"self",
".",
"webview",
".",
"set_font",
"(",
"font",
",",
"fixed_font",
"=",
"fixed_font",
")"
] | Set font | [
"Set",
"font"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/widgets.py#L118-L120 | train |
spyder-ide/spyder | spyder/plugins/help/widgets.py | PlainText.set_font | def set_font(self, font, color_scheme=None):
"""Set font"""
self.editor.set_font(font, color_scheme=color_scheme) | python | def set_font(self, font, color_scheme=None):
"""Set font"""
self.editor.set_font(font, color_scheme=color_scheme) | [
"def",
"set_font",
"(",
"self",
",",
"font",
",",
"color_scheme",
"=",
"None",
")",
":",
"self",
".",
"editor",
".",
"set_font",
"(",
"font",
",",
"color_scheme",
"=",
"color_scheme",
")"
] | Set font | [
"Set",
"font"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/help/widgets.py#L159-L161 | train |
spyder-ide/spyder | spyder/utils/codeanalysis.py | find_tasks | def find_tasks(source_code):
"""Find tasks in source code (TODO, FIXME, XXX, ...)"""
results = []
for line, text in enumerate(source_code.splitlines()):
for todo in re.findall(TASKS_PATTERN, text):
todo_text = (todo[-1].strip(' :').capitalize() if todo[-1]
... | python | def find_tasks(source_code):
"""Find tasks in source code (TODO, FIXME, XXX, ...)"""
results = []
for line, text in enumerate(source_code.splitlines()):
for todo in re.findall(TASKS_PATTERN, text):
todo_text = (todo[-1].strip(' :').capitalize() if todo[-1]
... | [
"def",
"find_tasks",
"(",
"source_code",
")",
":",
"results",
"=",
"[",
"]",
"for",
"line",
",",
"text",
"in",
"enumerate",
"(",
"source_code",
".",
"splitlines",
"(",
")",
")",
":",
"for",
"todo",
"in",
"re",
".",
"findall",
"(",
"TASKS_PATTERN",
",",... | Find tasks in source code (TODO, FIXME, XXX, ...) | [
"Find",
"tasks",
"in",
"source",
"code",
"(",
"TODO",
"FIXME",
"XXX",
"...",
")"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/codeanalysis.py#L30-L38 | train |
spyder-ide/spyder | spyder/utils/codeanalysis.py | check_with_pyflakes | def check_with_pyflakes(source_code, filename=None):
"""Check source code with pyflakes
Returns an empty list if pyflakes is not installed"""
try:
if filename is None:
filename = '<string>'
try:
source_code += '\n'
except TypeError:
# Pyth... | python | def check_with_pyflakes(source_code, filename=None):
"""Check source code with pyflakes
Returns an empty list if pyflakes is not installed"""
try:
if filename is None:
filename = '<string>'
try:
source_code += '\n'
except TypeError:
# Pyth... | [
"def",
"check_with_pyflakes",
"(",
"source_code",
",",
"filename",
"=",
"None",
")",
":",
"try",
":",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"'<string>'",
"try",
":",
"source_code",
"+=",
"'\\n'",
"except",
"TypeError",
":",
"# Python 3\r",
"s... | Check source code with pyflakes
Returns an empty list if pyflakes is not installed | [
"Check",
"source",
"code",
"with",
"pyflakes",
"Returns",
"an",
"empty",
"list",
"if",
"pyflakes",
"is",
"not",
"installed"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/codeanalysis.py#L41-L88 | train |
spyder-ide/spyder | spyder/utils/codeanalysis.py | get_checker_executable | def get_checker_executable(name):
"""Return checker executable in the form of a list of arguments
for subprocess.Popen"""
if programs.is_program_installed(name):
# Checker is properly installed
return [name]
else:
path1 = programs.python_script_exists(package=None,
... | python | def get_checker_executable(name):
"""Return checker executable in the form of a list of arguments
for subprocess.Popen"""
if programs.is_program_installed(name):
# Checker is properly installed
return [name]
else:
path1 = programs.python_script_exists(package=None,
... | [
"def",
"get_checker_executable",
"(",
"name",
")",
":",
"if",
"programs",
".",
"is_program_installed",
"(",
"name",
")",
":",
"# Checker is properly installed\r",
"return",
"[",
"name",
"]",
"else",
":",
"path1",
"=",
"programs",
".",
"python_script_exists",
"(",
... | Return checker executable in the form of a list of arguments
for subprocess.Popen | [
"Return",
"checker",
"executable",
"in",
"the",
"form",
"of",
"a",
"list",
"of",
"arguments",
"for",
"subprocess",
".",
"Popen"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/codeanalysis.py#L96-L113 | train |
spyder-ide/spyder | spyder/utils/codeanalysis.py | check | def check(args, source_code, filename=None, options=None):
"""Check source code with checker defined with *args* (list)
Returns an empty list if checker is not installed"""
if args is None:
return []
if options is not None:
args += options
if any(['pyflakes' in arg for arg in ... | python | def check(args, source_code, filename=None, options=None):
"""Check source code with checker defined with *args* (list)
Returns an empty list if checker is not installed"""
if args is None:
return []
if options is not None:
args += options
if any(['pyflakes' in arg for arg in ... | [
"def",
"check",
"(",
"args",
",",
"source_code",
",",
"filename",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"return",
"[",
"]",
"if",
"options",
"is",
"not",
"None",
":",
"args",
"+=",
"options",
"if",
"an... | Check source code with checker defined with *args* (list)
Returns an empty list if checker is not installed | [
"Check",
"source",
"code",
"with",
"checker",
"defined",
"with",
"*",
"args",
"*",
"(",
"list",
")",
"Returns",
"an",
"empty",
"list",
"if",
"checker",
"is",
"not",
"installed"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/codeanalysis.py#L116-L161 | train |
spyder-ide/spyder | spyder/utils/codeanalysis.py | check_with_pep8 | def check_with_pep8(source_code, filename=None):
"""Check source code with pycodestyle"""
try:
args = get_checker_executable('pycodestyle')
results = check(args, source_code, filename=filename, options=['-r'])
except Exception:
# Never return None to avoid lock in spyder/widget... | python | def check_with_pep8(source_code, filename=None):
"""Check source code with pycodestyle"""
try:
args = get_checker_executable('pycodestyle')
results = check(args, source_code, filename=filename, options=['-r'])
except Exception:
# Never return None to avoid lock in spyder/widget... | [
"def",
"check_with_pep8",
"(",
"source_code",
",",
"filename",
"=",
"None",
")",
":",
"try",
":",
"args",
"=",
"get_checker_executable",
"(",
"'pycodestyle'",
")",
"results",
"=",
"check",
"(",
"args",
",",
"source_code",
",",
"filename",
"=",
"filename",
",... | Check source code with pycodestyle | [
"Check",
"source",
"code",
"with",
"pycodestyle"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/codeanalysis.py#L164-L175 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | get_image_label | def get_image_label(name, default="not_found.png"):
"""Return image inside a QLabel object"""
label = QLabel()
label.setPixmap(QPixmap(get_image_path(name, default)))
return label | python | def get_image_label(name, default="not_found.png"):
"""Return image inside a QLabel object"""
label = QLabel()
label.setPixmap(QPixmap(get_image_path(name, default)))
return label | [
"def",
"get_image_label",
"(",
"name",
",",
"default",
"=",
"\"not_found.png\"",
")",
":",
"label",
"=",
"QLabel",
"(",
")",
"label",
".",
"setPixmap",
"(",
"QPixmap",
"(",
"get_image_path",
"(",
"name",
",",
"default",
")",
")",
")",
"return",
"label"
] | Return image inside a QLabel object | [
"Return",
"image",
"inside",
"a",
"QLabel",
"object"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L44-L48 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | qapplication | def qapplication(translate=True, test_time=3):
"""
Return QApplication instance
Creates it if it doesn't already exist
test_time: Time to maintain open the application when testing. It's given
in seconds
"""
if running_in_mac_app():
SpyderApplication = MacApplication
... | python | def qapplication(translate=True, test_time=3):
"""
Return QApplication instance
Creates it if it doesn't already exist
test_time: Time to maintain open the application when testing. It's given
in seconds
"""
if running_in_mac_app():
SpyderApplication = MacApplication
... | [
"def",
"qapplication",
"(",
"translate",
"=",
"True",
",",
"test_time",
"=",
"3",
")",
":",
"if",
"running_in_mac_app",
"(",
")",
":",
"SpyderApplication",
"=",
"MacApplication",
"else",
":",
"SpyderApplication",
"=",
"QApplication",
"app",
"=",
"SpyderApplicati... | Return QApplication instance
Creates it if it doesn't already exist
test_time: Time to maintain open the application when testing. It's given
in seconds | [
"Return",
"QApplication",
"instance",
"Creates",
"it",
"if",
"it",
"doesn",
"t",
"already",
"exist",
"test_time",
":",
"Time",
"to",
"maintain",
"open",
"the",
"application",
"when",
"testing",
".",
"It",
"s",
"given",
"in",
"seconds"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L65-L94 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | file_uri | def file_uri(fname):
"""Select the right file uri scheme according to the operating system"""
if os.name == 'nt':
# Local file
if re.search(r'^[a-zA-Z]:', fname):
return 'file:///' + fname
# UNC based path
else:
return 'file://' + fname
else:
... | python | def file_uri(fname):
"""Select the right file uri scheme according to the operating system"""
if os.name == 'nt':
# Local file
if re.search(r'^[a-zA-Z]:', fname):
return 'file:///' + fname
# UNC based path
else:
return 'file://' + fname
else:
... | [
"def",
"file_uri",
"(",
"fname",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"# Local file\r",
"if",
"re",
".",
"search",
"(",
"r'^[a-zA-Z]:'",
",",
"fname",
")",
":",
"return",
"'file:///'",
"+",
"fname",
"# UNC based path\r",
"else",
":",
"re... | Select the right file uri scheme according to the operating system | [
"Select",
"the",
"right",
"file",
"uri",
"scheme",
"according",
"to",
"the",
"operating",
"system"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L97-L107 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | install_translator | def install_translator(qapp):
"""Install Qt translator to the QApplication instance"""
global QT_TRANSLATOR
if QT_TRANSLATOR is None:
qt_translator = QTranslator()
if qt_translator.load("qt_"+QLocale.system().name(),
QLibraryInfo.location(QLibraryInfo.Translations... | python | def install_translator(qapp):
"""Install Qt translator to the QApplication instance"""
global QT_TRANSLATOR
if QT_TRANSLATOR is None:
qt_translator = QTranslator()
if qt_translator.load("qt_"+QLocale.system().name(),
QLibraryInfo.location(QLibraryInfo.Translations... | [
"def",
"install_translator",
"(",
"qapp",
")",
":",
"global",
"QT_TRANSLATOR",
"if",
"QT_TRANSLATOR",
"is",
"None",
":",
"qt_translator",
"=",
"QTranslator",
"(",
")",
"if",
"qt_translator",
".",
"load",
"(",
"\"qt_\"",
"+",
"QLocale",
".",
"system",
"(",
")... | Install Qt translator to the QApplication instance | [
"Install",
"Qt",
"translator",
"to",
"the",
"QApplication",
"instance"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L111-L120 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | keybinding | def keybinding(attr):
"""Return keybinding"""
ks = getattr(QKeySequence, attr)
return from_qvariant(QKeySequence.keyBindings(ks)[0], str) | python | def keybinding(attr):
"""Return keybinding"""
ks = getattr(QKeySequence, attr)
return from_qvariant(QKeySequence.keyBindings(ks)[0], str) | [
"def",
"keybinding",
"(",
"attr",
")",
":",
"ks",
"=",
"getattr",
"(",
"QKeySequence",
",",
"attr",
")",
"return",
"from_qvariant",
"(",
"QKeySequence",
".",
"keyBindings",
"(",
"ks",
")",
"[",
"0",
"]",
",",
"str",
")"
] | Return keybinding | [
"Return",
"keybinding"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L123-L126 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | mimedata2url | def mimedata2url(source, extlist=None):
"""
Extract url list from MIME data
extlist: for example ('.py', '.pyw')
"""
pathlist = []
if source.hasUrls():
for url in source.urls():
path = _process_mime_path(to_text_string(url.toString()), extlist)
if path is... | python | def mimedata2url(source, extlist=None):
"""
Extract url list from MIME data
extlist: for example ('.py', '.pyw')
"""
pathlist = []
if source.hasUrls():
for url in source.urls():
path = _process_mime_path(to_text_string(url.toString()), extlist)
if path is... | [
"def",
"mimedata2url",
"(",
"source",
",",
"extlist",
"=",
"None",
")",
":",
"pathlist",
"=",
"[",
"]",
"if",
"source",
".",
"hasUrls",
"(",
")",
":",
"for",
"url",
"in",
"source",
".",
"urls",
"(",
")",
":",
"path",
"=",
"_process_mime_path",
"(",
... | Extract url list from MIME data
extlist: for example ('.py', '.pyw') | [
"Extract",
"url",
"list",
"from",
"MIME",
"data",
"extlist",
":",
"for",
"example",
"(",
".",
"py",
".",
"pyw",
")"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L146-L163 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | keyevent2tuple | def keyevent2tuple(event):
"""Convert QKeyEvent instance into a tuple"""
return (event.type(), event.key(), event.modifiers(), event.text(),
event.isAutoRepeat(), event.count()) | python | def keyevent2tuple(event):
"""Convert QKeyEvent instance into a tuple"""
return (event.type(), event.key(), event.modifiers(), event.text(),
event.isAutoRepeat(), event.count()) | [
"def",
"keyevent2tuple",
"(",
"event",
")",
":",
"return",
"(",
"event",
".",
"type",
"(",
")",
",",
"event",
".",
"key",
"(",
")",
",",
"event",
".",
"modifiers",
"(",
")",
",",
"event",
".",
"text",
"(",
")",
",",
"event",
".",
"isAutoRepeat",
... | Convert QKeyEvent instance into a tuple | [
"Convert",
"QKeyEvent",
"instance",
"into",
"a",
"tuple"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L166-L169 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | create_toolbutton | def create_toolbutton(parent, text=None, shortcut=None, icon=None, tip=None,
toggled=None, triggered=None,
autoraise=True, text_beside_icon=False):
"""Create a QToolButton"""
button = QToolButton(parent)
if text is not None:
button.setText(text)
... | python | def create_toolbutton(parent, text=None, shortcut=None, icon=None, tip=None,
toggled=None, triggered=None,
autoraise=True, text_beside_icon=False):
"""Create a QToolButton"""
button = QToolButton(parent)
if text is not None:
button.setText(text)
... | [
"def",
"create_toolbutton",
"(",
"parent",
",",
"text",
"=",
"None",
",",
"shortcut",
"=",
"None",
",",
"icon",
"=",
"None",
",",
"tip",
"=",
"None",
",",
"toggled",
"=",
"None",
",",
"triggered",
"=",
"None",
",",
"autoraise",
"=",
"True",
",",
"tex... | Create a QToolButton | [
"Create",
"a",
"QToolButton"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L190-L213 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | action2button | def action2button(action, autoraise=True, text_beside_icon=False, parent=None):
"""Create a QToolButton directly from a QAction object"""
if parent is None:
parent = action.parent()
button = QToolButton(parent)
button.setDefaultAction(action)
button.setAutoRaise(autoraise)
if text... | python | def action2button(action, autoraise=True, text_beside_icon=False, parent=None):
"""Create a QToolButton directly from a QAction object"""
if parent is None:
parent = action.parent()
button = QToolButton(parent)
button.setDefaultAction(action)
button.setAutoRaise(autoraise)
if text... | [
"def",
"action2button",
"(",
"action",
",",
"autoraise",
"=",
"True",
",",
"text_beside_icon",
"=",
"False",
",",
"parent",
"=",
"None",
")",
":",
"if",
"parent",
"is",
"None",
":",
"parent",
"=",
"action",
".",
"parent",
"(",
")",
"button",
"=",
"QToo... | Create a QToolButton directly from a QAction object | [
"Create",
"a",
"QToolButton",
"directly",
"from",
"a",
"QAction",
"object"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L216-L225 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | toggle_actions | def toggle_actions(actions, enable):
"""Enable/disable actions"""
if actions is not None:
for action in actions:
if action is not None:
action.setEnabled(enable) | python | def toggle_actions(actions, enable):
"""Enable/disable actions"""
if actions is not None:
for action in actions:
if action is not None:
action.setEnabled(enable) | [
"def",
"toggle_actions",
"(",
"actions",
",",
"enable",
")",
":",
"if",
"actions",
"is",
"not",
"None",
":",
"for",
"action",
"in",
"actions",
":",
"if",
"action",
"is",
"not",
"None",
":",
"action",
".",
"setEnabled",
"(",
"enable",
")"
] | Enable/disable actions | [
"Enable",
"/",
"disable",
"actions"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L228-L233 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | create_action | def create_action(parent, text, shortcut=None, icon=None, tip=None,
toggled=None, triggered=None, data=None, menurole=None,
context=Qt.WindowShortcut):
"""Create a QAction"""
action = SpyderAction(text, parent)
if triggered is not None:
action.triggered.conn... | python | def create_action(parent, text, shortcut=None, icon=None, tip=None,
toggled=None, triggered=None, data=None, menurole=None,
context=Qt.WindowShortcut):
"""Create a QAction"""
action = SpyderAction(text, parent)
if triggered is not None:
action.triggered.conn... | [
"def",
"create_action",
"(",
"parent",
",",
"text",
",",
"shortcut",
"=",
"None",
",",
"icon",
"=",
"None",
",",
"tip",
"=",
"None",
",",
"toggled",
"=",
"None",
",",
"triggered",
"=",
"None",
",",
"data",
"=",
"None",
",",
"menurole",
"=",
"None",
... | Create a QAction | [
"Create",
"a",
"QAction"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L236-L278 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | add_shortcut_to_tooltip | def add_shortcut_to_tooltip(action, context, name):
"""Add the shortcut associated with a given action to its tooltip"""
action.setToolTip(action.toolTip() + ' (%s)' %
get_shortcut(context=context, name=name)) | python | def add_shortcut_to_tooltip(action, context, name):
"""Add the shortcut associated with a given action to its tooltip"""
action.setToolTip(action.toolTip() + ' (%s)' %
get_shortcut(context=context, name=name)) | [
"def",
"add_shortcut_to_tooltip",
"(",
"action",
",",
"context",
",",
"name",
")",
":",
"action",
".",
"setToolTip",
"(",
"action",
".",
"toolTip",
"(",
")",
"+",
"' (%s)'",
"%",
"get_shortcut",
"(",
"context",
"=",
"context",
",",
"name",
"=",
"name",
"... | Add the shortcut associated with a given action to its tooltip | [
"Add",
"the",
"shortcut",
"associated",
"with",
"a",
"given",
"action",
"to",
"its",
"tooltip"
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L281-L284 | train |
spyder-ide/spyder | spyder/utils/qthelpers.py | add_actions | def add_actions(target, actions, insert_before=None):
"""Add actions to a QMenu or a QToolBar."""
previous_action = None
target_actions = list(target.actions())
if target_actions:
previous_action = target_actions[-1]
if previous_action.isSeparator():
previous_action = ... | python | def add_actions(target, actions, insert_before=None):
"""Add actions to a QMenu or a QToolBar."""
previous_action = None
target_actions = list(target.actions())
if target_actions:
previous_action = target_actions[-1]
if previous_action.isSeparator():
previous_action = ... | [
"def",
"add_actions",
"(",
"target",
",",
"actions",
",",
"insert_before",
"=",
"None",
")",
":",
"previous_action",
"=",
"None",
"target_actions",
"=",
"list",
"(",
"target",
".",
"actions",
"(",
")",
")",
"if",
"target_actions",
":",
"previous_action",
"="... | Add actions to a QMenu or a QToolBar. | [
"Add",
"actions",
"to",
"a",
"QMenu",
"or",
"a",
"QToolBar",
"."
] | f76836ce1b924bcc4efd3f74f2960d26a4e528e0 | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/utils/qthelpers.py#L287-L322 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.