repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
sosreport/sos | sos/plugins/__init__.py | Plugin.collect | def collect(self):
"""Collect the data for a plugin."""
start = time()
self._collect_copy_specs()
self._collect_cmd_output()
self._collect_strings()
fields = (self.name(), time() - start)
self._log_debug("collected plugin '%s' in %s" % fields) | python | def collect(self):
"""Collect the data for a plugin."""
start = time()
self._collect_copy_specs()
self._collect_cmd_output()
self._collect_strings()
fields = (self.name(), time() - start)
self._log_debug("collected plugin '%s' in %s" % fields) | [
"def",
"collect",
"(",
"self",
")",
":",
"start",
"=",
"time",
"(",
")",
"self",
".",
"_collect_copy_specs",
"(",
")",
"self",
".",
"_collect_cmd_output",
"(",
")",
"self",
".",
"_collect_strings",
"(",
")",
"fields",
"=",
"(",
"self",
".",
"name",
"("... | Collect the data for a plugin. | [
"Collect",
"the",
"data",
"for",
"a",
"plugin",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1202-L1209 | train |
sosreport/sos | sos/plugins/__init__.py | Plugin.get_description | def get_description(self):
""" This function will return the description for the plugin"""
try:
if hasattr(self, '__doc__') and self.__doc__:
return self.__doc__.strip()
return super(self.__class__, self).__doc__.strip()
except Exception:
retur... | python | def get_description(self):
""" This function will return the description for the plugin"""
try:
if hasattr(self, '__doc__') and self.__doc__:
return self.__doc__.strip()
return super(self.__class__, self).__doc__.strip()
except Exception:
retur... | [
"def",
"get_description",
"(",
"self",
")",
":",
"try",
":",
"if",
"hasattr",
"(",
"self",
",",
"'__doc__'",
")",
"and",
"self",
".",
"__doc__",
":",
"return",
"self",
".",
"__doc__",
".",
"strip",
"(",
")",
"return",
"super",
"(",
"self",
".",
"__cl... | This function will return the description for the plugin | [
"This",
"function",
"will",
"return",
"the",
"description",
"for",
"the",
"plugin"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1211-L1218 | train |
sosreport/sos | sos/plugins/__init__.py | Plugin.check_enabled | def check_enabled(self):
"""This method will be used to verify that a plugin should execute
given the condition of the underlying environment.
The default implementation will return True if none of class.files,
class.packages, nor class.commands is specified. If any of these is
... | python | def check_enabled(self):
"""This method will be used to verify that a plugin should execute
given the condition of the underlying environment.
The default implementation will return True if none of class.files,
class.packages, nor class.commands is specified. If any of these is
... | [
"def",
"check_enabled",
"(",
"self",
")",
":",
"# some files or packages have been specified for this package",
"if",
"any",
"(",
"[",
"self",
".",
"files",
",",
"self",
".",
"packages",
",",
"self",
".",
"commands",
",",
"self",
".",
"kernel_mods",
",",
"self",... | This method will be used to verify that a plugin should execute
given the condition of the underlying environment.
The default implementation will return True if none of class.files,
class.packages, nor class.commands is specified. If any of these is
specified the plugin will check for ... | [
"This",
"method",
"will",
"be",
"used",
"to",
"verify",
"that",
"a",
"plugin",
"should",
"execute",
"given",
"the",
"condition",
"of",
"the",
"underlying",
"environment",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1220-L1279 | train |
sosreport/sos | sos/plugins/__init__.py | Plugin.report | def report(self):
""" Present all information that was gathered in an html file that
allows browsing the results.
"""
# make this prettier
html = u'<hr/><a name="%s"></a>\n' % self.name()
# Intro
html = html + "<h2> Plugin <em>" + self.name() + "</em></h2>\n"
... | python | def report(self):
""" Present all information that was gathered in an html file that
allows browsing the results.
"""
# make this prettier
html = u'<hr/><a name="%s"></a>\n' % self.name()
# Intro
html = html + "<h2> Plugin <em>" + self.name() + "</em></h2>\n"
... | [
"def",
"report",
"(",
"self",
")",
":",
"# make this prettier",
"html",
"=",
"u'<hr/><a name=\"%s\"></a>\\n'",
"%",
"self",
".",
"name",
"(",
")",
"# Intro",
"html",
"=",
"html",
"+",
"\"<h2> Plugin <em>\"",
"+",
"self",
".",
"name",
"(",
")",
"+",
"\"</em><... | Present all information that was gathered in an html file that
allows browsing the results. | [
"Present",
"all",
"information",
"that",
"was",
"gathered",
"in",
"an",
"html",
"file",
"that",
"allows",
"browsing",
"the",
"results",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1323-L1374 | train |
sosreport/sos | sos/plugins/__init__.py | Plugin.get_process_pids | def get_process_pids(self, process):
"""Returns PIDs of all processes with process name.
If the process doesn't exist, returns an empty list"""
pids = []
cmd_line_glob = "/proc/[0-9]*/cmdline"
cmd_line_paths = glob.glob(cmd_line_glob)
for path in cmd_line_paths:
... | python | def get_process_pids(self, process):
"""Returns PIDs of all processes with process name.
If the process doesn't exist, returns an empty list"""
pids = []
cmd_line_glob = "/proc/[0-9]*/cmdline"
cmd_line_paths = glob.glob(cmd_line_glob)
for path in cmd_line_paths:
... | [
"def",
"get_process_pids",
"(",
"self",
",",
"process",
")",
":",
"pids",
"=",
"[",
"]",
"cmd_line_glob",
"=",
"\"/proc/[0-9]*/cmdline\"",
"cmd_line_paths",
"=",
"glob",
".",
"glob",
"(",
"cmd_line_glob",
")",
"for",
"path",
"in",
"cmd_line_paths",
":",
"try",... | Returns PIDs of all processes with process name.
If the process doesn't exist, returns an empty list | [
"Returns",
"PIDs",
"of",
"all",
"processes",
"with",
"process",
"name",
".",
"If",
"the",
"process",
"doesn",
"t",
"exist",
"returns",
"an",
"empty",
"list"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1392-L1406 | train |
sosreport/sos | sos/plugins/__init__.py | SCLPlugin.convert_cmd_scl | def convert_cmd_scl(self, scl, cmd):
"""wrapping command in "scl enable" call and adds proper PATH
"""
# load default SCL prefix to PATH
prefix = self.policy.get_default_scl_prefix()
# read prefix from /etc/scl/prefixes/${scl} and strip trailing '\n'
try:
pref... | python | def convert_cmd_scl(self, scl, cmd):
"""wrapping command in "scl enable" call and adds proper PATH
"""
# load default SCL prefix to PATH
prefix = self.policy.get_default_scl_prefix()
# read prefix from /etc/scl/prefixes/${scl} and strip trailing '\n'
try:
pref... | [
"def",
"convert_cmd_scl",
"(",
"self",
",",
"scl",
",",
"cmd",
")",
":",
"# load default SCL prefix to PATH",
"prefix",
"=",
"self",
".",
"policy",
".",
"get_default_scl_prefix",
"(",
")",
"# read prefix from /etc/scl/prefixes/${scl} and strip trailing '\\n'",
"try",
":",... | wrapping command in "scl enable" call and adds proper PATH | [
"wrapping",
"command",
"in",
"scl",
"enable",
"call",
"and",
"adds",
"proper",
"PATH"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1448-L1467 | train |
sosreport/sos | sos/plugins/__init__.py | SCLPlugin.add_cmd_output_scl | def add_cmd_output_scl(self, scl, cmds, **kwargs):
"""Same as add_cmd_output, except that it wraps command in
"scl enable" call and sets proper PATH.
"""
if isinstance(cmds, six.string_types):
cmds = [cmds]
scl_cmds = []
for cmd in cmds:
scl_cmds.a... | python | def add_cmd_output_scl(self, scl, cmds, **kwargs):
"""Same as add_cmd_output, except that it wraps command in
"scl enable" call and sets proper PATH.
"""
if isinstance(cmds, six.string_types):
cmds = [cmds]
scl_cmds = []
for cmd in cmds:
scl_cmds.a... | [
"def",
"add_cmd_output_scl",
"(",
"self",
",",
"scl",
",",
"cmds",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"cmds",
",",
"six",
".",
"string_types",
")",
":",
"cmds",
"=",
"[",
"cmds",
"]",
"scl_cmds",
"=",
"[",
"]",
"for",
"cmd"... | Same as add_cmd_output, except that it wraps command in
"scl enable" call and sets proper PATH. | [
"Same",
"as",
"add_cmd_output",
"except",
"that",
"it",
"wraps",
"command",
"in",
"scl",
"enable",
"call",
"and",
"sets",
"proper",
"PATH",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1469-L1478 | train |
sosreport/sos | sos/plugins/__init__.py | SCLPlugin.add_copy_spec_scl | def add_copy_spec_scl(self, scl, copyspecs):
"""Same as add_copy_spec, except that it prepends path to SCL root
to "copyspecs".
"""
if isinstance(copyspecs, six.string_types):
copyspecs = [copyspecs]
scl_copyspecs = []
for copyspec in copyspecs:
sc... | python | def add_copy_spec_scl(self, scl, copyspecs):
"""Same as add_copy_spec, except that it prepends path to SCL root
to "copyspecs".
"""
if isinstance(copyspecs, six.string_types):
copyspecs = [copyspecs]
scl_copyspecs = []
for copyspec in copyspecs:
sc... | [
"def",
"add_copy_spec_scl",
"(",
"self",
",",
"scl",
",",
"copyspecs",
")",
":",
"if",
"isinstance",
"(",
"copyspecs",
",",
"six",
".",
"string_types",
")",
":",
"copyspecs",
"=",
"[",
"copyspecs",
"]",
"scl_copyspecs",
"=",
"[",
"]",
"for",
"copyspec",
... | Same as add_copy_spec, except that it prepends path to SCL root
to "copyspecs". | [
"Same",
"as",
"add_copy_spec",
"except",
"that",
"it",
"prepends",
"path",
"to",
"SCL",
"root",
"to",
"copyspecs",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1492-L1501 | train |
sosreport/sos | sos/plugins/__init__.py | SCLPlugin.add_copy_spec_limit_scl | def add_copy_spec_limit_scl(self, scl, copyspec, **kwargs):
"""Same as add_copy_spec_limit, except that it prepends path to SCL
root to "copyspec".
"""
self.add_copy_spec_limit(
self.convert_copyspec_scl(scl, copyspec),
**kwargs
) | python | def add_copy_spec_limit_scl(self, scl, copyspec, **kwargs):
"""Same as add_copy_spec_limit, except that it prepends path to SCL
root to "copyspec".
"""
self.add_copy_spec_limit(
self.convert_copyspec_scl(scl, copyspec),
**kwargs
) | [
"def",
"add_copy_spec_limit_scl",
"(",
"self",
",",
"scl",
",",
"copyspec",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"add_copy_spec_limit",
"(",
"self",
".",
"convert_copyspec_scl",
"(",
"scl",
",",
"copyspec",
")",
",",
"*",
"*",
"kwargs",
")"
] | Same as add_copy_spec_limit, except that it prepends path to SCL
root to "copyspec". | [
"Same",
"as",
"add_copy_spec_limit",
"except",
"that",
"it",
"prepends",
"path",
"to",
"SCL",
"root",
"to",
"copyspec",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1503-L1510 | train |
sosreport/sos | sos/plugins/veritas.py | Veritas.setup | def setup(self):
""" interface with vrtsexplorer to capture veritas related data """
r = self.call_ext_prog(self.get_option("script"))
if r['status'] == 0:
tarfile = ""
for line in r['output']:
line = line.strip()
tarfile = self.do_regex_fi... | python | def setup(self):
""" interface with vrtsexplorer to capture veritas related data """
r = self.call_ext_prog(self.get_option("script"))
if r['status'] == 0:
tarfile = ""
for line in r['output']:
line = line.strip()
tarfile = self.do_regex_fi... | [
"def",
"setup",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"call_ext_prog",
"(",
"self",
".",
"get_option",
"(",
"\"script\"",
")",
")",
"if",
"r",
"[",
"'status'",
"]",
"==",
"0",
":",
"tarfile",
"=",
"\"\"",
"for",
"line",
"in",
"r",
"[",
"'... | interface with vrtsexplorer to capture veritas related data | [
"interface",
"with",
"vrtsexplorer",
"to",
"capture",
"veritas",
"related",
"data"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/veritas.py#L28-L37 | train |
sosreport/sos | sos/plugins/openstack_ansible.py | OpenStackAnsible.postproc | def postproc(self):
"""Remove sensitive keys and passwords from YAML files."""
secrets_files = [
"/etc/openstack_deploy/user_secrets.yml",
"/etc/rpc_deploy/user_secrets.yml"
]
regexp = r"(?m)^\s*#*([\w_]*:\s*).*"
for secrets_file in secrets_files:
... | python | def postproc(self):
"""Remove sensitive keys and passwords from YAML files."""
secrets_files = [
"/etc/openstack_deploy/user_secrets.yml",
"/etc/rpc_deploy/user_secrets.yml"
]
regexp = r"(?m)^\s*#*([\w_]*:\s*).*"
for secrets_file in secrets_files:
... | [
"def",
"postproc",
"(",
"self",
")",
":",
"secrets_files",
"=",
"[",
"\"/etc/openstack_deploy/user_secrets.yml\"",
",",
"\"/etc/rpc_deploy/user_secrets.yml\"",
"]",
"regexp",
"=",
"r\"(?m)^\\s*#*([\\w_]*:\\s*).*\"",
"for",
"secrets_file",
"in",
"secrets_files",
":",
"self",... | Remove sensitive keys and passwords from YAML files. | [
"Remove",
"sensitive",
"keys",
"and",
"passwords",
"from",
"YAML",
"files",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/openstack_ansible.py#L30-L41 | train |
timothycrosley/isort | isort/main.py | ISortCommand.finalize_options | def finalize_options(self) -> None:
"Get options from config files."
self.arguments = {} # type: Dict[str, Any]
computed_settings = from_path(os.getcwd())
for key, value in computed_settings.items():
self.arguments[key] = value | python | def finalize_options(self) -> None:
"Get options from config files."
self.arguments = {} # type: Dict[str, Any]
computed_settings = from_path(os.getcwd())
for key, value in computed_settings.items():
self.arguments[key] = value | [
"def",
"finalize_options",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"arguments",
"=",
"{",
"}",
"# type: Dict[str, Any]",
"computed_settings",
"=",
"from_path",
"(",
"os",
".",
"getcwd",
"(",
")",
")",
"for",
"key",
",",
"value",
"in",
"computed_s... | Get options from config files. | [
"Get",
"options",
"from",
"config",
"files",
"."
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/main.py#L131-L136 | train |
timothycrosley/isort | isort/main.py | ISortCommand.distribution_files | def distribution_files(self) -> Iterator[str]:
"""Find distribution packages."""
# This is verbatim from flake8
if self.distribution.packages:
package_dirs = self.distribution.package_dir or {}
for package in self.distribution.packages:
pkg_dir = package
... | python | def distribution_files(self) -> Iterator[str]:
"""Find distribution packages."""
# This is verbatim from flake8
if self.distribution.packages:
package_dirs = self.distribution.package_dir or {}
for package in self.distribution.packages:
pkg_dir = package
... | [
"def",
"distribution_files",
"(",
"self",
")",
"->",
"Iterator",
"[",
"str",
"]",
":",
"# This is verbatim from flake8",
"if",
"self",
".",
"distribution",
".",
"packages",
":",
"package_dirs",
"=",
"self",
".",
"distribution",
".",
"package_dir",
"or",
"{",
"... | Find distribution packages. | [
"Find",
"distribution",
"packages",
"."
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/main.py#L138-L155 | train |
timothycrosley/isort | isort/utils.py | chdir | def chdir(path: str) -> Iterator[None]:
"""Context manager for changing dir and restoring previous workdir after exit.
"""
curdir = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(curdir) | python | def chdir(path: str) -> Iterator[None]:
"""Context manager for changing dir and restoring previous workdir after exit.
"""
curdir = os.getcwd()
os.chdir(path)
try:
yield
finally:
os.chdir(curdir) | [
"def",
"chdir",
"(",
"path",
":",
"str",
")",
"->",
"Iterator",
"[",
"None",
"]",
":",
"curdir",
"=",
"os",
".",
"getcwd",
"(",
")",
"os",
".",
"chdir",
"(",
"path",
")",
"try",
":",
"yield",
"finally",
":",
"os",
".",
"chdir",
"(",
"curdir",
"... | Context manager for changing dir and restoring previous workdir after exit. | [
"Context",
"manager",
"for",
"changing",
"dir",
"and",
"restoring",
"previous",
"workdir",
"after",
"exit",
"."
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/utils.py#L23-L31 | train |
timothycrosley/isort | isort/utils.py | union | def union(a: Iterable[Any], b: Iterable[Any]) -> List[Any]:
""" Return a list of items that are in `a` or `b`
"""
u = [] # type: List[Any]
for item in a:
if item not in u:
u.append(item)
for item in b:
if item not in u:
u.append(item)
return u | python | def union(a: Iterable[Any], b: Iterable[Any]) -> List[Any]:
""" Return a list of items that are in `a` or `b`
"""
u = [] # type: List[Any]
for item in a:
if item not in u:
u.append(item)
for item in b:
if item not in u:
u.append(item)
return u | [
"def",
"union",
"(",
"a",
":",
"Iterable",
"[",
"Any",
"]",
",",
"b",
":",
"Iterable",
"[",
"Any",
"]",
")",
"->",
"List",
"[",
"Any",
"]",
":",
"u",
"=",
"[",
"]",
"# type: List[Any]",
"for",
"item",
"in",
"a",
":",
"if",
"item",
"not",
"in",
... | Return a list of items that are in `a` or `b` | [
"Return",
"a",
"list",
"of",
"items",
"that",
"are",
"in",
"a",
"or",
"b"
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/utils.py#L34-L44 | train |
timothycrosley/isort | isort/utils.py | difference | def difference(a: Iterable[Any], b: Container[Any]) -> List[Any]:
""" Return a list of items from `a` that are not in `b`.
"""
d = []
for item in a:
if item not in b:
d.append(item)
return d | python | def difference(a: Iterable[Any], b: Container[Any]) -> List[Any]:
""" Return a list of items from `a` that are not in `b`.
"""
d = []
for item in a:
if item not in b:
d.append(item)
return d | [
"def",
"difference",
"(",
"a",
":",
"Iterable",
"[",
"Any",
"]",
",",
"b",
":",
"Container",
"[",
"Any",
"]",
")",
"->",
"List",
"[",
"Any",
"]",
":",
"d",
"=",
"[",
"]",
"for",
"item",
"in",
"a",
":",
"if",
"item",
"not",
"in",
"b",
":",
"... | Return a list of items from `a` that are not in `b`. | [
"Return",
"a",
"list",
"of",
"items",
"from",
"a",
"that",
"are",
"not",
"in",
"b",
"."
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/utils.py#L47-L54 | train |
timothycrosley/isort | kate_plugin/isort_plugin.py | sort_kate_imports | def sort_kate_imports(add_imports=(), remove_imports=()):
"""Sorts imports within Kate while maintaining cursor position and selection, even if length of file changes."""
document = kate.activeDocument()
view = document.activeView()
position = view.cursorPosition()
selection = view.selectionRange()
... | python | def sort_kate_imports(add_imports=(), remove_imports=()):
"""Sorts imports within Kate while maintaining cursor position and selection, even if length of file changes."""
document = kate.activeDocument()
view = document.activeView()
position = view.cursorPosition()
selection = view.selectionRange()
... | [
"def",
"sort_kate_imports",
"(",
"add_imports",
"=",
"(",
")",
",",
"remove_imports",
"=",
"(",
")",
")",
":",
"document",
"=",
"kate",
".",
"activeDocument",
"(",
")",
"view",
"=",
"document",
".",
"activeView",
"(",
")",
"position",
"=",
"view",
".",
... | Sorts imports within Kate while maintaining cursor position and selection, even if length of file changes. | [
"Sorts",
"imports",
"within",
"Kate",
"while",
"maintaining",
"cursor",
"position",
"and",
"selection",
"even",
"if",
"length",
"of",
"file",
"changes",
"."
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/kate_plugin/isort_plugin.py#L37-L54 | train |
timothycrosley/isort | isort/isort.py | _SortImports._get_line | def _get_line(self) -> str:
"""Returns the current line from the file while incrementing the index."""
line = self.in_lines[self.index]
self.index += 1
return line | python | def _get_line(self) -> str:
"""Returns the current line from the file while incrementing the index."""
line = self.in_lines[self.index]
self.index += 1
return line | [
"def",
"_get_line",
"(",
"self",
")",
"->",
"str",
":",
"line",
"=",
"self",
".",
"in_lines",
"[",
"self",
".",
"index",
"]",
"self",
".",
"index",
"+=",
"1",
"return",
"line"
] | Returns the current line from the file while incrementing the index. | [
"Returns",
"the",
"current",
"line",
"from",
"the",
"file",
"while",
"incrementing",
"the",
"index",
"."
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/isort.py#L139-L143 | train |
timothycrosley/isort | isort/isort.py | _SortImports._add_comments | def _add_comments(
self,
comments: Optional[Sequence[str]],
original_string: str = ""
) -> str:
"""
Returns a string with comments added if ignore_comments is not set.
"""
if self.config['ignore_comments']:
return self._strip_comments(original_... | python | def _add_comments(
self,
comments: Optional[Sequence[str]],
original_string: str = ""
) -> str:
"""
Returns a string with comments added if ignore_comments is not set.
"""
if self.config['ignore_comments']:
return self._strip_comments(original_... | [
"def",
"_add_comments",
"(",
"self",
",",
"comments",
":",
"Optional",
"[",
"Sequence",
"[",
"str",
"]",
"]",
",",
"original_string",
":",
"str",
"=",
"\"\"",
")",
"->",
"str",
":",
"if",
"self",
".",
"config",
"[",
"'ignore_comments'",
"]",
":",
"retu... | Returns a string with comments added if ignore_comments is not set. | [
"Returns",
"a",
"string",
"with",
"comments",
"added",
"if",
"ignore_comments",
"is",
"not",
"set",
"."
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/isort.py#L194-L210 | train |
timothycrosley/isort | isort/isort.py | _SortImports._wrap | def _wrap(self, line: str) -> str:
"""
Returns an import wrapped to the specified line-length, if possible.
"""
wrap_mode = self.config['multi_line_output']
if len(line) > self.config['line_length'] and wrap_mode != WrapModes.NOQA:
line_without_comment = line
... | python | def _wrap(self, line: str) -> str:
"""
Returns an import wrapped to the specified line-length, if possible.
"""
wrap_mode = self.config['multi_line_output']
if len(line) > self.config['line_length'] and wrap_mode != WrapModes.NOQA:
line_without_comment = line
... | [
"def",
"_wrap",
"(",
"self",
",",
"line",
":",
"str",
")",
"->",
"str",
":",
"wrap_mode",
"=",
"self",
".",
"config",
"[",
"'multi_line_output'",
"]",
"if",
"len",
"(",
"line",
")",
">",
"self",
".",
"config",
"[",
"'line_length'",
"]",
"and",
"wrap_... | Returns an import wrapped to the specified line-length, if possible. | [
"Returns",
"an",
"import",
"wrapped",
"to",
"the",
"specified",
"line",
"-",
"length",
"if",
"possible",
"."
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/isort.py#L212-L253 | train |
timothycrosley/isort | isort/finders.py | KnownPatternFinder._parse_known_pattern | def _parse_known_pattern(self, pattern: str) -> List[str]:
"""
Expand pattern if identified as a directory and return found sub packages
"""
if pattern.endswith(os.path.sep):
patterns = [
filename
for filename in os.listdir(pattern)
... | python | def _parse_known_pattern(self, pattern: str) -> List[str]:
"""
Expand pattern if identified as a directory and return found sub packages
"""
if pattern.endswith(os.path.sep):
patterns = [
filename
for filename in os.listdir(pattern)
... | [
"def",
"_parse_known_pattern",
"(",
"self",
",",
"pattern",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"if",
"pattern",
".",
"endswith",
"(",
"os",
".",
"path",
".",
"sep",
")",
":",
"patterns",
"=",
"[",
"filename",
"for",
"filename",
"in"... | Expand pattern if identified as a directory and return found sub packages | [
"Expand",
"pattern",
"if",
"identified",
"as",
"a",
"directory",
"and",
"return",
"found",
"sub",
"packages"
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/finders.py#L86-L99 | train |
timothycrosley/isort | isort/finders.py | ReqsBaseFinder._load_mapping | def _load_mapping() -> Optional[Dict[str, str]]:
"""Return list of mappings `package_name -> module_name`
Example:
django-haystack -> haystack
"""
if not pipreqs:
return None
path = os.path.dirname(inspect.getfile(pipreqs))
path = os.path.join(pat... | python | def _load_mapping() -> Optional[Dict[str, str]]:
"""Return list of mappings `package_name -> module_name`
Example:
django-haystack -> haystack
"""
if not pipreqs:
return None
path = os.path.dirname(inspect.getfile(pipreqs))
path = os.path.join(pat... | [
"def",
"_load_mapping",
"(",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
"]",
":",
"if",
"not",
"pipreqs",
":",
"return",
"None",
"path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"inspect",
".",
"getfile",
"(",
"pipreqs",
"... | Return list of mappings `package_name -> module_name`
Example:
django-haystack -> haystack | [
"Return",
"list",
"of",
"mappings",
"package_name",
"-",
">",
"module_name"
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/finders.py#L200-L216 | train |
timothycrosley/isort | isort/finders.py | ReqsBaseFinder._load_names | def _load_names(self) -> List[str]:
"""Return list of thirdparty modules from requirements
"""
names = []
for path in self._get_files():
for name in self._get_names(path):
names.append(self._normalize_name(name))
return names | python | def _load_names(self) -> List[str]:
"""Return list of thirdparty modules from requirements
"""
names = []
for path in self._get_files():
for name in self._get_names(path):
names.append(self._normalize_name(name))
return names | [
"def",
"_load_names",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"names",
"=",
"[",
"]",
"for",
"path",
"in",
"self",
".",
"_get_files",
"(",
")",
":",
"for",
"name",
"in",
"self",
".",
"_get_names",
"(",
"path",
")",
":",
"names",
"."... | Return list of thirdparty modules from requirements | [
"Return",
"list",
"of",
"thirdparty",
"modules",
"from",
"requirements"
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/finders.py#L219-L226 | train |
timothycrosley/isort | isort/finders.py | ReqsBaseFinder._get_files | def _get_files(self) -> Iterator[str]:
"""Return paths to all requirements files
"""
path = os.path.abspath(self.path)
if os.path.isfile(path):
path = os.path.dirname(path)
for path in self._get_parents(path):
for file_path in self._get_files_from_dir(pat... | python | def _get_files(self) -> Iterator[str]:
"""Return paths to all requirements files
"""
path = os.path.abspath(self.path)
if os.path.isfile(path):
path = os.path.dirname(path)
for path in self._get_parents(path):
for file_path in self._get_files_from_dir(pat... | [
"def",
"_get_files",
"(",
"self",
")",
"->",
"Iterator",
"[",
"str",
"]",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"self",
".",
"path",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"path",
"=",
"os",
".",... | Return paths to all requirements files | [
"Return",
"paths",
"to",
"all",
"requirements",
"files"
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/finders.py#L236-L245 | train |
timothycrosley/isort | isort/finders.py | ReqsBaseFinder._normalize_name | def _normalize_name(self, name: str) -> str:
"""Convert package name to module name
Examples:
Django -> django
django-haystack -> django_haystack
Flask-RESTFul -> flask_restful
"""
if self.mapping:
name = self.mapping.get(name, name)
... | python | def _normalize_name(self, name: str) -> str:
"""Convert package name to module name
Examples:
Django -> django
django-haystack -> django_haystack
Flask-RESTFul -> flask_restful
"""
if self.mapping:
name = self.mapping.get(name, name)
... | [
"def",
"_normalize_name",
"(",
"self",
",",
"name",
":",
"str",
")",
"->",
"str",
":",
"if",
"self",
".",
"mapping",
":",
"name",
"=",
"self",
".",
"mapping",
".",
"get",
"(",
"name",
",",
"name",
")",
"return",
"name",
".",
"lower",
"(",
")",
".... | Convert package name to module name
Examples:
Django -> django
django-haystack -> django_haystack
Flask-RESTFul -> flask_restful | [
"Convert",
"package",
"name",
"to",
"module",
"name"
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/finders.py#L247-L257 | train |
timothycrosley/isort | isort/finders.py | RequirementsFinder._get_names | def _get_names(self, path: str) -> Iterator[str]:
"""Load required packages from path to requirements file
"""
for i in RequirementsFinder._get_names_cached(path):
yield i | python | def _get_names(self, path: str) -> Iterator[str]:
"""Load required packages from path to requirements file
"""
for i in RequirementsFinder._get_names_cached(path):
yield i | [
"def",
"_get_names",
"(",
"self",
",",
"path",
":",
"str",
")",
"->",
"Iterator",
"[",
"str",
"]",
":",
"for",
"i",
"in",
"RequirementsFinder",
".",
"_get_names_cached",
"(",
"path",
")",
":",
"yield",
"i"
] | Load required packages from path to requirements file | [
"Load",
"required",
"packages",
"from",
"path",
"to",
"requirements",
"file"
] | 493c02a1a000fe782cec56f1f43262bacb316381 | https://github.com/timothycrosley/isort/blob/493c02a1a000fe782cec56f1f43262bacb316381/isort/finders.py#L310-L314 | train |
graphql-python/graphql-ws | graphql_ws/django_channels.py | GraphQLSubscriptionConsumer.receive | def receive(self, content, **kwargs):
"""
Called when a message is received with either text or bytes
filled out.
"""
self.connection_context = DjangoChannelConnectionContext(self.message)
self.subscription_server = DjangoChannelSubscriptionServer(graphene_settings.SCHEMA... | python | def receive(self, content, **kwargs):
"""
Called when a message is received with either text or bytes
filled out.
"""
self.connection_context = DjangoChannelConnectionContext(self.message)
self.subscription_server = DjangoChannelSubscriptionServer(graphene_settings.SCHEMA... | [
"def",
"receive",
"(",
"self",
",",
"content",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"connection_context",
"=",
"DjangoChannelConnectionContext",
"(",
"self",
".",
"message",
")",
"self",
".",
"subscription_server",
"=",
"DjangoChannelSubscriptionServer"... | Called when a message is received with either text or bytes
filled out. | [
"Called",
"when",
"a",
"message",
"is",
"received",
"with",
"either",
"text",
"or",
"bytes",
"filled",
"out",
"."
] | 523dd1516d8709149a475602042d6a3c5eab5a3d | https://github.com/graphql-python/graphql-ws/blob/523dd1516d8709149a475602042d6a3c5eab5a3d/graphql_ws/django_channels.py#L106-L114 | train |
autokey/autokey | lib/autokey/qtui/settings/general.py | GeneralSettings.save | def save(self):
"""Called by the parent settings dialog when the user clicks on the Save button.
Stores the current settings in the ConfigManager."""
logger.debug("User requested to save settings. New settings: " + self._settings_str())
cm.ConfigManager.SETTINGS[cm.PROMPT_TO_SAVE] = not ... | python | def save(self):
"""Called by the parent settings dialog when the user clicks on the Save button.
Stores the current settings in the ConfigManager."""
logger.debug("User requested to save settings. New settings: " + self._settings_str())
cm.ConfigManager.SETTINGS[cm.PROMPT_TO_SAVE] = not ... | [
"def",
"save",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"User requested to save settings. New settings: \"",
"+",
"self",
".",
"_settings_str",
"(",
")",
")",
"cm",
".",
"ConfigManager",
".",
"SETTINGS",
"[",
"cm",
".",
"PROMPT_TO_SAVE",
"]",
"=",... | Called by the parent settings dialog when the user clicks on the Save button.
Stores the current settings in the ConfigManager. | [
"Called",
"by",
"the",
"parent",
"settings",
"dialog",
"when",
"the",
"user",
"clicks",
"on",
"the",
"Save",
"button",
".",
"Stores",
"the",
"current",
"settings",
"in",
"the",
"ConfigManager",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/settings/general.py#L59-L70 | train |
autokey/autokey | lib/autokey/qtui/settings/general.py | GeneralSettings._settings_str | def _settings_str(self):
"""Returns a human readable settings representation for logging purposes."""
settings = "Automatically save changes: {}, " \
"Show tray icon: {}, " \
"Allow keyboard navigation: {}, " \
"Sort by usage count: {}, " \
"Enable undo us... | python | def _settings_str(self):
"""Returns a human readable settings representation for logging purposes."""
settings = "Automatically save changes: {}, " \
"Show tray icon: {}, " \
"Allow keyboard navigation: {}, " \
"Sort by usage count: {}, " \
"Enable undo us... | [
"def",
"_settings_str",
"(",
"self",
")",
":",
"settings",
"=",
"\"Automatically save changes: {}, \"",
"\"Show tray icon: {}, \"",
"\"Allow keyboard navigation: {}, \"",
"\"Sort by usage count: {}, \"",
"\"Enable undo using backspace: {}, \"",
"\"Tray icon theme: {}\"",
".",
"format",... | Returns a human readable settings representation for logging purposes. | [
"Returns",
"a",
"human",
"readable",
"settings",
"representation",
"for",
"logging",
"purposes",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/settings/general.py#L72-L87 | train |
autokey/autokey | lib/autokey/model.py | AbstractAbbreviation._should_trigger_abbreviation | def _should_trigger_abbreviation(self, buffer):
"""
Checks whether, based on the settings for the abbreviation and the given input,
the abbreviation should trigger.
@param buffer Input buffer to be checked (as string)
"""
return any(self.__checkInput(buffer, abbr) for ab... | python | def _should_trigger_abbreviation(self, buffer):
"""
Checks whether, based on the settings for the abbreviation and the given input,
the abbreviation should trigger.
@param buffer Input buffer to be checked (as string)
"""
return any(self.__checkInput(buffer, abbr) for ab... | [
"def",
"_should_trigger_abbreviation",
"(",
"self",
",",
"buffer",
")",
":",
"return",
"any",
"(",
"self",
".",
"__checkInput",
"(",
"buffer",
",",
"abbr",
")",
"for",
"abbr",
"in",
"self",
".",
"abbreviations",
")"
] | Checks whether, based on the settings for the abbreviation and the given input,
the abbreviation should trigger.
@param buffer Input buffer to be checked (as string) | [
"Checks",
"whether",
"based",
"on",
"the",
"settings",
"for",
"the",
"abbreviation",
"and",
"the",
"given",
"input",
"the",
"abbreviation",
"should",
"trigger",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/model.py#L175-L182 | train |
autokey/autokey | lib/autokey/model.py | AbstractWindowFilter.get_filter_regex | def get_filter_regex(self):
"""
Used by the GUI to obtain human-readable version of the filter
"""
if self.windowInfoRegex is not None:
if self.isRecursive:
return self.windowInfoRegex.pattern
else:
return self.windowInfoRegex.patte... | python | def get_filter_regex(self):
"""
Used by the GUI to obtain human-readable version of the filter
"""
if self.windowInfoRegex is not None:
if self.isRecursive:
return self.windowInfoRegex.pattern
else:
return self.windowInfoRegex.patte... | [
"def",
"get_filter_regex",
"(",
"self",
")",
":",
"if",
"self",
".",
"windowInfoRegex",
"is",
"not",
"None",
":",
"if",
"self",
".",
"isRecursive",
":",
"return",
"self",
".",
"windowInfoRegex",
".",
"pattern",
"else",
":",
"return",
"self",
".",
"windowIn... | Used by the GUI to obtain human-readable version of the filter | [
"Used",
"by",
"the",
"GUI",
"to",
"obtain",
"human",
"-",
"readable",
"version",
"of",
"the",
"filter"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/model.py#L313-L325 | train |
autokey/autokey | lib/autokey/model.py | Folder.add_item | def add_item(self, item):
"""
Add a new script or phrase to the folder.
"""
item.parent = self
#self.phrases[phrase.description] = phrase
self.items.append(item) | python | def add_item(self, item):
"""
Add a new script or phrase to the folder.
"""
item.parent = self
#self.phrases[phrase.description] = phrase
self.items.append(item) | [
"def",
"add_item",
"(",
"self",
",",
"item",
")",
":",
"item",
".",
"parent",
"=",
"self",
"#self.phrases[phrase.description] = phrase",
"self",
".",
"items",
".",
"append",
"(",
"item",
")"
] | Add a new script or phrase to the folder. | [
"Add",
"a",
"new",
"script",
"or",
"phrase",
"to",
"the",
"folder",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/model.py#L546-L552 | train |
autokey/autokey | lib/autokey/model.py | Folder.get_backspace_count | def get_backspace_count(self, buffer):
"""
Given the input buffer, calculate how many backspaces are needed to erase the text
that triggered this folder.
"""
if TriggerMode.ABBREVIATION in self.modes and self.backspace:
if self._should_trigger_abbreviation(buffer):
... | python | def get_backspace_count(self, buffer):
"""
Given the input buffer, calculate how many backspaces are needed to erase the text
that triggered this folder.
"""
if TriggerMode.ABBREVIATION in self.modes and self.backspace:
if self._should_trigger_abbreviation(buffer):
... | [
"def",
"get_backspace_count",
"(",
"self",
",",
"buffer",
")",
":",
"if",
"TriggerMode",
".",
"ABBREVIATION",
"in",
"self",
".",
"modes",
"and",
"self",
".",
"backspace",
":",
"if",
"self",
".",
"_should_trigger_abbreviation",
"(",
"buffer",
")",
":",
"abbr"... | Given the input buffer, calculate how many backspaces are needed to erase the text
that triggered this folder. | [
"Given",
"the",
"input",
"buffer",
"calculate",
"how",
"many",
"backspaces",
"are",
"needed",
"to",
"erase",
"the",
"text",
"that",
"triggered",
"this",
"folder",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/model.py#L572-L586 | train |
autokey/autokey | lib/autokey/model.py | Phrase.calculate_input | def calculate_input(self, buffer):
"""
Calculate how many keystrokes were used in triggering this phrase.
"""
# TODO: This function is unused?
if TriggerMode.ABBREVIATION in self.modes:
if self._should_trigger_abbreviation(buffer):
if self.immediate:
... | python | def calculate_input(self, buffer):
"""
Calculate how many keystrokes were used in triggering this phrase.
"""
# TODO: This function is unused?
if TriggerMode.ABBREVIATION in self.modes:
if self._should_trigger_abbreviation(buffer):
if self.immediate:
... | [
"def",
"calculate_input",
"(",
"self",
",",
"buffer",
")",
":",
"# TODO: This function is unused?",
"if",
"TriggerMode",
".",
"ABBREVIATION",
"in",
"self",
".",
"modes",
":",
"if",
"self",
".",
"_should_trigger_abbreviation",
"(",
"buffer",
")",
":",
"if",
"self... | Calculate how many keystrokes were used in triggering this phrase. | [
"Calculate",
"how",
"many",
"keystrokes",
"were",
"used",
"in",
"triggering",
"this",
"phrase",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/model.py#L797-L818 | train |
autokey/autokey | lib/autokey/model.py | Script._persist_metadata | def _persist_metadata(self):
"""
Write all script meta-data, including the persistent script Store.
The Store instance might contain arbitrary user data, like function objects, OpenCL contexts, or whatever other
non-serializable objects, both as keys or values.
Try to serialize t... | python | def _persist_metadata(self):
"""
Write all script meta-data, including the persistent script Store.
The Store instance might contain arbitrary user data, like function objects, OpenCL contexts, or whatever other
non-serializable objects, both as keys or values.
Try to serialize t... | [
"def",
"_persist_metadata",
"(",
"self",
")",
":",
"serializable_data",
"=",
"self",
".",
"get_serializable",
"(",
")",
"try",
":",
"self",
".",
"_try_persist_metadata",
"(",
"serializable_data",
")",
"except",
"TypeError",
":",
"# The user added non-serializable data... | Write all script meta-data, including the persistent script Store.
The Store instance might contain arbitrary user data, like function objects, OpenCL contexts, or whatever other
non-serializable objects, both as keys or values.
Try to serialize the data, and if it fails, fall back to checking t... | [
"Write",
"all",
"script",
"meta",
"-",
"data",
"including",
"the",
"persistent",
"script",
"Store",
".",
"The",
"Store",
"instance",
"might",
"contain",
"arbitrary",
"user",
"data",
"like",
"function",
"objects",
"OpenCL",
"contexts",
"or",
"whatever",
"other",
... | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/model.py#L949-L963 | train |
autokey/autokey | lib/autokey/model.py | Script._remove_non_serializable_store_entries | def _remove_non_serializable_store_entries(store: Store) -> dict:
"""
Copy all serializable data into a new dict, and skip the rest.
This makes sure to keep the items during runtime, even if the user edits and saves the script.
"""
cleaned_store_data = {}
for key, value i... | python | def _remove_non_serializable_store_entries(store: Store) -> dict:
"""
Copy all serializable data into a new dict, and skip the rest.
This makes sure to keep the items during runtime, even if the user edits and saves the script.
"""
cleaned_store_data = {}
for key, value i... | [
"def",
"_remove_non_serializable_store_entries",
"(",
"store",
":",
"Store",
")",
"->",
"dict",
":",
"cleaned_store_data",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"store",
".",
"items",
"(",
")",
":",
"if",
"Script",
".",
"_is_serializable",
"(",
... | Copy all serializable data into a new dict, and skip the rest.
This makes sure to keep the items during runtime, even if the user edits and saves the script. | [
"Copy",
"all",
"serializable",
"data",
"into",
"a",
"new",
"dict",
"and",
"skip",
"the",
"rest",
".",
"This",
"makes",
"sure",
"to",
"keep",
"the",
"items",
"during",
"runtime",
"even",
"if",
"the",
"user",
"edits",
"and",
"saves",
"the",
"script",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/model.py#L970-L984 | train |
autokey/autokey | lib/autokey/qtapp.py | Application._configure_root_logger | def _configure_root_logger(self):
"""Initialise logging system"""
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
if self.args.verbose:
handler = logging.StreamHandler(sys.stdout)
else:
handler = logging.handlers.RotatingFileHandler(
... | python | def _configure_root_logger(self):
"""Initialise logging system"""
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
if self.args.verbose:
handler = logging.StreamHandler(sys.stdout)
else:
handler = logging.handlers.RotatingFileHandler(
... | [
"def",
"_configure_root_logger",
"(",
"self",
")",
":",
"root_logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"root_logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"if",
"self",
".",
"args",
".",
"verbose",
":",
"handler",
"=",
"logging",... | Initialise logging system | [
"Initialise",
"logging",
"system"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtapp.py#L165-L179 | train |
autokey/autokey | lib/autokey/qtapp.py | Application._create_storage_directories | def _create_storage_directories():
"""Create various storage directories, if those do not exist."""
# Create configuration directory
if not os.path.exists(common.CONFIG_DIR):
os.makedirs(common.CONFIG_DIR)
# Create data directory (for log file)
if not os.path.exists(c... | python | def _create_storage_directories():
"""Create various storage directories, if those do not exist."""
# Create configuration directory
if not os.path.exists(common.CONFIG_DIR):
os.makedirs(common.CONFIG_DIR)
# Create data directory (for log file)
if not os.path.exists(c... | [
"def",
"_create_storage_directories",
"(",
")",
":",
"# Create configuration directory",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"common",
".",
"CONFIG_DIR",
")",
":",
"os",
".",
"makedirs",
"(",
"common",
".",
"CONFIG_DIR",
")",
"# Create data direc... | Create various storage directories, if those do not exist. | [
"Create",
"various",
"storage",
"directories",
"if",
"those",
"do",
"not",
"exist",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtapp.py#L182-L192 | train |
autokey/autokey | lib/autokey/qtapp.py | Application.toggle_service | def toggle_service(self):
"""
Convenience method for toggling the expansion service on or off. This is called by the global hotkey.
"""
self.monitoring_disabled.emit(not self.service.is_running())
if self.service.is_running():
self.pause_service()
else:
... | python | def toggle_service(self):
"""
Convenience method for toggling the expansion service on or off. This is called by the global hotkey.
"""
self.monitoring_disabled.emit(not self.service.is_running())
if self.service.is_running():
self.pause_service()
else:
... | [
"def",
"toggle_service",
"(",
"self",
")",
":",
"self",
".",
"monitoring_disabled",
".",
"emit",
"(",
"not",
"self",
".",
"service",
".",
"is_running",
"(",
")",
")",
"if",
"self",
".",
"service",
".",
"is_running",
"(",
")",
":",
"self",
".",
"pause_s... | Convenience method for toggling the expansion service on or off. This is called by the global hotkey. | [
"Convenience",
"method",
"for",
"toggling",
"the",
"expansion",
"service",
"on",
"or",
"off",
".",
"This",
"is",
"called",
"by",
"the",
"global",
"hotkey",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtapp.py#L271-L279 | train |
autokey/autokey | lib/autokey/qtui/notifier.py | Notifier.create_assign_context_menu | def create_assign_context_menu(self):
"""
Create a context menu, then set the created QMenu as the context menu.
This builds the menu with all required actions and signal-slot connections.
"""
menu = QMenu("AutoKey")
self._build_menu(menu)
self.setContextMenu(menu... | python | def create_assign_context_menu(self):
"""
Create a context menu, then set the created QMenu as the context menu.
This builds the menu with all required actions and signal-slot connections.
"""
menu = QMenu("AutoKey")
self._build_menu(menu)
self.setContextMenu(menu... | [
"def",
"create_assign_context_menu",
"(",
"self",
")",
":",
"menu",
"=",
"QMenu",
"(",
"\"AutoKey\"",
")",
"self",
".",
"_build_menu",
"(",
"menu",
")",
"self",
".",
"setContextMenu",
"(",
"menu",
")"
] | Create a context menu, then set the created QMenu as the context menu.
This builds the menu with all required actions and signal-slot connections. | [
"Create",
"a",
"context",
"menu",
"then",
"set",
"the",
"created",
"QMenu",
"as",
"the",
"context",
"menu",
".",
"This",
"builds",
"the",
"menu",
"with",
"all",
"required",
"actions",
"and",
"signal",
"-",
"slot",
"connections",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/notifier.py#L62-L69 | train |
autokey/autokey | lib/autokey/qtui/notifier.py | Notifier.update_tool_tip | def update_tool_tip(self, service_running: bool):
"""Slot function that updates the tooltip when the user activates or deactivates the expansion service."""
if service_running:
self.setToolTip(TOOLTIP_RUNNING)
else:
self.setToolTip(TOOLTIP_PAUSED) | python | def update_tool_tip(self, service_running: bool):
"""Slot function that updates the tooltip when the user activates or deactivates the expansion service."""
if service_running:
self.setToolTip(TOOLTIP_RUNNING)
else:
self.setToolTip(TOOLTIP_PAUSED) | [
"def",
"update_tool_tip",
"(",
"self",
",",
"service_running",
":",
"bool",
")",
":",
"if",
"service_running",
":",
"self",
".",
"setToolTip",
"(",
"TOOLTIP_RUNNING",
")",
"else",
":",
"self",
".",
"setToolTip",
"(",
"TOOLTIP_PAUSED",
")"
] | Slot function that updates the tooltip when the user activates or deactivates the expansion service. | [
"Slot",
"function",
"that",
"updates",
"the",
"tooltip",
"when",
"the",
"user",
"activates",
"or",
"deactivates",
"the",
"expansion",
"service",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/notifier.py#L71-L76 | train |
autokey/autokey | lib/autokey/qtui/notifier.py | Notifier._create_action | def _create_action(
self,
icon_name: Optional[str],
title: str,
slot_function: Callable[[None], None],
tool_tip: Optional[str]=None)-> QAction:
"""
QAction factory. All items created belong to the calling instance, i.e. created QAction parent i... | python | def _create_action(
self,
icon_name: Optional[str],
title: str,
slot_function: Callable[[None], None],
tool_tip: Optional[str]=None)-> QAction:
"""
QAction factory. All items created belong to the calling instance, i.e. created QAction parent i... | [
"def",
"_create_action",
"(",
"self",
",",
"icon_name",
":",
"Optional",
"[",
"str",
"]",
",",
"title",
":",
"str",
",",
"slot_function",
":",
"Callable",
"[",
"[",
"None",
"]",
",",
"None",
"]",
",",
"tool_tip",
":",
"Optional",
"[",
"str",
"]",
"="... | QAction factory. All items created belong to the calling instance, i.e. created QAction parent is self. | [
"QAction",
"factory",
".",
"All",
"items",
"created",
"belong",
"to",
"the",
"calling",
"instance",
"i",
".",
"e",
".",
"created",
"QAction",
"parent",
"is",
"self",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/notifier.py#L92-L107 | train |
autokey/autokey | lib/autokey/qtui/notifier.py | Notifier._create_static_actions | def _create_static_actions(self):
"""
Create all static menu actions. The created actions will be placed in the tray icon context menu.
"""
logger.info("Creating static context menu actions.")
self.action_view_script_error = self._create_action(
None, "&View script er... | python | def _create_static_actions(self):
"""
Create all static menu actions. The created actions will be placed in the tray icon context menu.
"""
logger.info("Creating static context menu actions.")
self.action_view_script_error = self._create_action(
None, "&View script er... | [
"def",
"_create_static_actions",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Creating static context menu actions.\"",
")",
"self",
".",
"action_view_script_error",
"=",
"self",
".",
"_create_action",
"(",
"None",
",",
"\"&View script error\"",
",",
"self",
... | Create all static menu actions. The created actions will be placed in the tray icon context menu. | [
"Create",
"all",
"static",
"menu",
"actions",
".",
"The",
"created",
"actions",
"will",
"be",
"placed",
"in",
"the",
"tray",
"icon",
"context",
"menu",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/notifier.py#L109-L142 | train |
autokey/autokey | lib/autokey/qtui/notifier.py | Notifier._fill_context_menu_with_model_item_actions | def _fill_context_menu_with_model_item_actions(self, context_menu: QMenu):
"""
Find all model items that should be available in the context menu and create QActions for each, by
using the available logic in popupmenu.PopupMenu.
"""
# Get phrase folders to add to main menu
... | python | def _fill_context_menu_with_model_item_actions(self, context_menu: QMenu):
"""
Find all model items that should be available in the context menu and create QActions for each, by
using the available logic in popupmenu.PopupMenu.
"""
# Get phrase folders to add to main menu
... | [
"def",
"_fill_context_menu_with_model_item_actions",
"(",
"self",
",",
"context_menu",
":",
"QMenu",
")",
":",
"# Get phrase folders to add to main menu",
"logger",
".",
"info",
"(",
"\"Rebuilding model item actions, adding all items marked for access through the tray icon.\"",
")",
... | Find all model items that should be available in the context menu and create QActions for each, by
using the available logic in popupmenu.PopupMenu. | [
"Find",
"all",
"model",
"items",
"that",
"should",
"be",
"available",
"in",
"the",
"context",
"menu",
"and",
"create",
"QActions",
"for",
"each",
"by",
"using",
"the",
"available",
"logic",
"in",
"popupmenu",
".",
"PopupMenu",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/notifier.py#L144-L165 | train |
autokey/autokey | lib/autokey/qtui/notifier.py | Notifier._build_menu | def _build_menu(self, context_menu: QMenu):
"""Build the context menu."""
logger.debug("Show tray icon enabled in settings: {}".format(cm.ConfigManager.SETTINGS[cm.SHOW_TRAY_ICON]))
# Items selected for display are shown on top
self._fill_context_menu_with_model_item_actions(context_menu... | python | def _build_menu(self, context_menu: QMenu):
"""Build the context menu."""
logger.debug("Show tray icon enabled in settings: {}".format(cm.ConfigManager.SETTINGS[cm.SHOW_TRAY_ICON]))
# Items selected for display are shown on top
self._fill_context_menu_with_model_item_actions(context_menu... | [
"def",
"_build_menu",
"(",
"self",
",",
"context_menu",
":",
"QMenu",
")",
":",
"logger",
".",
"debug",
"(",
"\"Show tray icon enabled in settings: {}\"",
".",
"format",
"(",
"cm",
".",
"ConfigManager",
".",
"SETTINGS",
"[",
"cm",
".",
"SHOW_TRAY_ICON",
"]",
"... | Build the context menu. | [
"Build",
"the",
"context",
"menu",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/notifier.py#L167-L177 | train |
autokey/autokey | lib/autokey/configmanager.py | _persist_settings | def _persist_settings(config_manager):
"""
Write the settings, including the persistent global script Store.
The Store instance might contain arbitrary user data, like function objects, OpenCL contexts, or whatever other
non-serializable objects, both as keys or values.
Try to serialize the data, an... | python | def _persist_settings(config_manager):
"""
Write the settings, including the persistent global script Store.
The Store instance might contain arbitrary user data, like function objects, OpenCL contexts, or whatever other
non-serializable objects, both as keys or values.
Try to serialize the data, an... | [
"def",
"_persist_settings",
"(",
"config_manager",
")",
":",
"serializable_data",
"=",
"config_manager",
".",
"get_serializable",
"(",
")",
"try",
":",
"_try_persist_settings",
"(",
"serializable_data",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
... | Write the settings, including the persistent global script Store.
The Store instance might contain arbitrary user data, like function objects, OpenCL contexts, or whatever other
non-serializable objects, both as keys or values.
Try to serialize the data, and if it fails, fall back to checking the store and ... | [
"Write",
"the",
"settings",
"including",
"the",
"persistent",
"global",
"script",
"Store",
".",
"The",
"Store",
"instance",
"might",
"contain",
"arbitrary",
"user",
"data",
"like",
"function",
"objects",
"OpenCL",
"contexts",
"or",
"whatever",
"other",
"non",
"-... | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/configmanager.py#L118-L132 | train |
autokey/autokey | lib/autokey/configmanager.py | _remove_non_serializable_store_entries | def _remove_non_serializable_store_entries(store: dict):
"""
This function is called if there are non-serializable items in the global script storage.
This function removes all such items.
"""
removed_key_list = []
for key, value in store.items():
if not (_is_serializable(key) and _is_se... | python | def _remove_non_serializable_store_entries(store: dict):
"""
This function is called if there are non-serializable items in the global script storage.
This function removes all such items.
"""
removed_key_list = []
for key, value in store.items():
if not (_is_serializable(key) and _is_se... | [
"def",
"_remove_non_serializable_store_entries",
"(",
"store",
":",
"dict",
")",
":",
"removed_key_list",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"store",
".",
"items",
"(",
")",
":",
"if",
"not",
"(",
"_is_serializable",
"(",
"key",
")",
"and",
... | This function is called if there are non-serializable items in the global script storage.
This function removes all such items. | [
"This",
"function",
"is",
"called",
"if",
"there",
"are",
"non",
"-",
"serializable",
"items",
"in",
"the",
"global",
"script",
"storage",
".",
"This",
"function",
"removes",
"all",
"such",
"items",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/configmanager.py#L145-L157 | train |
autokey/autokey | lib/autokey/configmanager.py | get_autostart | def get_autostart() -> AutostartSettings:
"""Returns the autostart settings as read from the system."""
autostart_file = Path(common.AUTOSTART_DIR) / "autokey.desktop"
if not autostart_file.exists():
return AutostartSettings(None, False)
else:
return _extract_data_from_desktop_file(autos... | python | def get_autostart() -> AutostartSettings:
"""Returns the autostart settings as read from the system."""
autostart_file = Path(common.AUTOSTART_DIR) / "autokey.desktop"
if not autostart_file.exists():
return AutostartSettings(None, False)
else:
return _extract_data_from_desktop_file(autos... | [
"def",
"get_autostart",
"(",
")",
"->",
"AutostartSettings",
":",
"autostart_file",
"=",
"Path",
"(",
"common",
".",
"AUTOSTART_DIR",
")",
"/",
"\"autokey.desktop\"",
"if",
"not",
"autostart_file",
".",
"exists",
"(",
")",
":",
"return",
"AutostartSettings",
"("... | Returns the autostart settings as read from the system. | [
"Returns",
"the",
"autostart",
"settings",
"as",
"read",
"from",
"the",
"system",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/configmanager.py#L172-L178 | train |
autokey/autokey | lib/autokey/configmanager.py | _create_autostart_entry | def _create_autostart_entry(autostart_data: AutostartSettings, autostart_file: Path):
"""Create an autostart .desktop file in the autostart directory, if possible."""
try:
source_desktop_file = get_source_desktop_file(autostart_data.desktop_file_name)
except FileNotFoundError:
_logger.except... | python | def _create_autostart_entry(autostart_data: AutostartSettings, autostart_file: Path):
"""Create an autostart .desktop file in the autostart directory, if possible."""
try:
source_desktop_file = get_source_desktop_file(autostart_data.desktop_file_name)
except FileNotFoundError:
_logger.except... | [
"def",
"_create_autostart_entry",
"(",
"autostart_data",
":",
"AutostartSettings",
",",
"autostart_file",
":",
"Path",
")",
":",
"try",
":",
"source_desktop_file",
"=",
"get_source_desktop_file",
"(",
"autostart_data",
".",
"desktop_file_name",
")",
"except",
"FileNotFo... | Create an autostart .desktop file in the autostart directory, if possible. | [
"Create",
"an",
"autostart",
".",
"desktop",
"file",
"in",
"the",
"autostart",
"directory",
"if",
"possible",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/configmanager.py#L205-L222 | train |
autokey/autokey | lib/autokey/configmanager.py | delete_autostart_entry | def delete_autostart_entry():
"""Remove a present autostart entry. If none is found, nothing happens."""
autostart_file = Path(common.AUTOSTART_DIR) / "autokey.desktop"
if autostart_file.exists():
autostart_file.unlink()
_logger.info("Deleted old autostart entry: {}".format(autostart_file)) | python | def delete_autostart_entry():
"""Remove a present autostart entry. If none is found, nothing happens."""
autostart_file = Path(common.AUTOSTART_DIR) / "autokey.desktop"
if autostart_file.exists():
autostart_file.unlink()
_logger.info("Deleted old autostart entry: {}".format(autostart_file)) | [
"def",
"delete_autostart_entry",
"(",
")",
":",
"autostart_file",
"=",
"Path",
"(",
"common",
".",
"AUTOSTART_DIR",
")",
"/",
"\"autokey.desktop\"",
"if",
"autostart_file",
".",
"exists",
"(",
")",
":",
"autostart_file",
".",
"unlink",
"(",
")",
"_logger",
"."... | Remove a present autostart entry. If none is found, nothing happens. | [
"Remove",
"a",
"present",
"autostart",
"entry",
".",
"If",
"none",
"is",
"found",
"nothing",
"happens",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/configmanager.py#L225-L230 | train |
autokey/autokey | lib/autokey/configmanager.py | apply_settings | def apply_settings(settings):
"""
Allows new settings to be added without users having to lose all their configuration
"""
for key, value in settings.items():
ConfigManager.SETTINGS[key] = value | python | def apply_settings(settings):
"""
Allows new settings to be added without users having to lose all their configuration
"""
for key, value in settings.items():
ConfigManager.SETTINGS[key] = value | [
"def",
"apply_settings",
"(",
"settings",
")",
":",
"for",
"key",
",",
"value",
"in",
"settings",
".",
"items",
"(",
")",
":",
"ConfigManager",
".",
"SETTINGS",
"[",
"key",
"]",
"=",
"value"
] | Allows new settings to be added without users having to lose all their configuration | [
"Allows",
"new",
"settings",
"to",
"be",
"added",
"without",
"users",
"having",
"to",
"lose",
"all",
"their",
"configuration"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/configmanager.py#L278-L283 | train |
autokey/autokey | lib/autokey/configmanager.py | ConfigManager.check_abbreviation_unique | def check_abbreviation_unique(self, abbreviation, newFilterPattern, targetItem):
"""
Checks that the given abbreviation is not already in use.
@param abbreviation: the abbreviation to check
@param newFilterPattern:
@param targetItem: the phrase for which the abbreviation... | python | def check_abbreviation_unique(self, abbreviation, newFilterPattern, targetItem):
"""
Checks that the given abbreviation is not already in use.
@param abbreviation: the abbreviation to check
@param newFilterPattern:
@param targetItem: the phrase for which the abbreviation... | [
"def",
"check_abbreviation_unique",
"(",
"self",
",",
"abbreviation",
",",
"newFilterPattern",
",",
"targetItem",
")",
":",
"for",
"item",
"in",
"self",
".",
"allFolders",
":",
"if",
"model",
".",
"TriggerMode",
".",
"ABBREVIATION",
"in",
"item",
".",
"modes",... | Checks that the given abbreviation is not already in use.
@param abbreviation: the abbreviation to check
@param newFilterPattern:
@param targetItem: the phrase for which the abbreviation to be used | [
"Checks",
"that",
"the",
"given",
"abbreviation",
"is",
"not",
"already",
"in",
"use",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/configmanager.py#L837-L855 | train |
autokey/autokey | lib/autokey/configmanager.py | ConfigManager.check_hotkey_unique | def check_hotkey_unique(self, modifiers, hotKey, newFilterPattern, targetItem):
"""
Checks that the given hotkey is not already in use. Also checks the
special hotkeys configured from the advanced settings dialog.
@param modifiers: modifiers for the hotkey
@param hotKey... | python | def check_hotkey_unique(self, modifiers, hotKey, newFilterPattern, targetItem):
"""
Checks that the given hotkey is not already in use. Also checks the
special hotkeys configured from the advanced settings dialog.
@param modifiers: modifiers for the hotkey
@param hotKey... | [
"def",
"check_hotkey_unique",
"(",
"self",
",",
"modifiers",
",",
"hotKey",
",",
"newFilterPattern",
",",
"targetItem",
")",
":",
"for",
"item",
"in",
"self",
".",
"allFolders",
":",
"if",
"model",
".",
"TriggerMode",
".",
"HOTKEY",
"in",
"item",
".",
"mod... | Checks that the given hotkey is not already in use. Also checks the
special hotkeys configured from the advanced settings dialog.
@param modifiers: modifiers for the hotkey
@param hotKey: the hotkey to check
@param newFilterPattern:
@param targetItem: the phrase for whi... | [
"Checks",
"that",
"the",
"given",
"hotkey",
"is",
"not",
"already",
"in",
"use",
".",
"Also",
"checks",
"the",
"special",
"hotkeys",
"configured",
"from",
"the",
"advanced",
"settings",
"dialog",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/configmanager.py#L888-L913 | train |
autokey/autokey | lib/autokey/qtui/dialogs/hotkeysettings.py | HotkeySettingsDialog.on_setButton_pressed | def on_setButton_pressed(self):
"""
Start recording a key combination when the user clicks on the setButton.
The button itself is automatically disabled during the recording process.
"""
self.keyLabel.setText("Press a key or combination...") # TODO: i18n
logger.debug("Us... | python | def on_setButton_pressed(self):
"""
Start recording a key combination when the user clicks on the setButton.
The button itself is automatically disabled during the recording process.
"""
self.keyLabel.setText("Press a key or combination...") # TODO: i18n
logger.debug("Us... | [
"def",
"on_setButton_pressed",
"(",
"self",
")",
":",
"self",
".",
"keyLabel",
".",
"setText",
"(",
"\"Press a key or combination...\"",
")",
"# TODO: i18n",
"logger",
".",
"debug",
"(",
"\"User starts to record a key combination.\"",
")",
"self",
".",
"grabber",
"=",... | Start recording a key combination when the user clicks on the setButton.
The button itself is automatically disabled during the recording process. | [
"Start",
"recording",
"a",
"key",
"combination",
"when",
"the",
"user",
"clicks",
"on",
"the",
"setButton",
".",
"The",
"button",
"itself",
"is",
"automatically",
"disabled",
"during",
"the",
"recording",
"process",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/dialogs/hotkeysettings.py#L68-L76 | train |
autokey/autokey | lib/autokey/qtui/dialogs/hotkeysettings.py | HotkeySettingsDialog.set_key | def set_key(self, key, modifiers: typing.List[Key]=None):
"""This is called when the user successfully finishes recording a key combination."""
if modifiers is None:
modifiers = [] # type: typing.List[Key]
if key in self.KEY_MAP:
key = self.KEY_MAP[key]
self._set... | python | def set_key(self, key, modifiers: typing.List[Key]=None):
"""This is called when the user successfully finishes recording a key combination."""
if modifiers is None:
modifiers = [] # type: typing.List[Key]
if key in self.KEY_MAP:
key = self.KEY_MAP[key]
self._set... | [
"def",
"set_key",
"(",
"self",
",",
"key",
",",
"modifiers",
":",
"typing",
".",
"List",
"[",
"Key",
"]",
"=",
"None",
")",
":",
"if",
"modifiers",
"is",
"None",
":",
"modifiers",
"=",
"[",
"]",
"# type: typing.List[Key]",
"if",
"key",
"in",
"self",
... | This is called when the user successfully finishes recording a key combination. | [
"This",
"is",
"called",
"when",
"the",
"user",
"successfully",
"finishes",
"recording",
"a",
"key",
"combination",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/dialogs/hotkeysettings.py#L127-L141 | train |
autokey/autokey | lib/autokey/qtui/dialogs/hotkeysettings.py | HotkeySettingsDialog.cancel_grab | def cancel_grab(self):
"""
This is called when the user cancels a recording.
Canceling is done by clicking with the left mouse button.
"""
logger.debug("User canceled hotkey recording.")
self.recording_finished.emit(True)
self._setKeyLabel(self.key if self.key is ... | python | def cancel_grab(self):
"""
This is called when the user cancels a recording.
Canceling is done by clicking with the left mouse button.
"""
logger.debug("User canceled hotkey recording.")
self.recording_finished.emit(True)
self._setKeyLabel(self.key if self.key is ... | [
"def",
"cancel_grab",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"User canceled hotkey recording.\"",
")",
"self",
".",
"recording_finished",
".",
"emit",
"(",
"True",
")",
"self",
".",
"_setKeyLabel",
"(",
"self",
".",
"key",
"if",
"self",
".",
... | This is called when the user cancels a recording.
Canceling is done by clicking with the left mouse button. | [
"This",
"is",
"called",
"when",
"the",
"user",
"cancels",
"a",
"recording",
".",
"Canceling",
"is",
"done",
"by",
"clicking",
"with",
"the",
"left",
"mouse",
"button",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/dialogs/hotkeysettings.py#L143-L150 | train |
autokey/autokey | lib/autokey/iomediator/_iomediator.py | IoMediator.handle_modifier_down | def handle_modifier_down(self, modifier):
"""
Updates the state of the given modifier key to 'pressed'
"""
_logger.debug("%s pressed", modifier)
if modifier in (Key.CAPSLOCK, Key.NUMLOCK):
if self.modifiers[modifier]:
self.modifiers[modifier] = False
... | python | def handle_modifier_down(self, modifier):
"""
Updates the state of the given modifier key to 'pressed'
"""
_logger.debug("%s pressed", modifier)
if modifier in (Key.CAPSLOCK, Key.NUMLOCK):
if self.modifiers[modifier]:
self.modifiers[modifier] = False
... | [
"def",
"handle_modifier_down",
"(",
"self",
",",
"modifier",
")",
":",
"_logger",
".",
"debug",
"(",
"\"%s pressed\"",
",",
"modifier",
")",
"if",
"modifier",
"in",
"(",
"Key",
".",
"CAPSLOCK",
",",
"Key",
".",
"NUMLOCK",
")",
":",
"if",
"self",
".",
"... | Updates the state of the given modifier key to 'pressed' | [
"Updates",
"the",
"state",
"of",
"the",
"given",
"modifier",
"key",
"to",
"pressed"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/iomediator/_iomediator.py#L72-L83 | train |
autokey/autokey | lib/autokey/iomediator/_iomediator.py | IoMediator.handle_modifier_up | def handle_modifier_up(self, modifier):
"""
Updates the state of the given modifier key to 'released'.
"""
_logger.debug("%s released", modifier)
# Caps and num lock are handled on key down only
if modifier not in (Key.CAPSLOCK, Key.NUMLOCK):
self.modifiers[mo... | python | def handle_modifier_up(self, modifier):
"""
Updates the state of the given modifier key to 'released'.
"""
_logger.debug("%s released", modifier)
# Caps and num lock are handled on key down only
if modifier not in (Key.CAPSLOCK, Key.NUMLOCK):
self.modifiers[mo... | [
"def",
"handle_modifier_up",
"(",
"self",
",",
"modifier",
")",
":",
"_logger",
".",
"debug",
"(",
"\"%s released\"",
",",
"modifier",
")",
"# Caps and num lock are handled on key down only",
"if",
"modifier",
"not",
"in",
"(",
"Key",
".",
"CAPSLOCK",
",",
"Key",
... | Updates the state of the given modifier key to 'released'. | [
"Updates",
"the",
"state",
"of",
"the",
"given",
"modifier",
"key",
"to",
"released",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/iomediator/_iomediator.py#L85-L92 | train |
autokey/autokey | lib/autokey/iomediator/_iomediator.py | IoMediator.send_string | def send_string(self, string: str):
"""
Sends the given string for output.
"""
if not string:
return
string = string.replace('\n', "<enter>")
string = string.replace('\t', "<tab>")
_logger.debug("Send via event interface")
self.__clea... | python | def send_string(self, string: str):
"""
Sends the given string for output.
"""
if not string:
return
string = string.replace('\n', "<enter>")
string = string.replace('\t', "<tab>")
_logger.debug("Send via event interface")
self.__clea... | [
"def",
"send_string",
"(",
"self",
",",
"string",
":",
"str",
")",
":",
"if",
"not",
"string",
":",
"return",
"string",
"=",
"string",
".",
"replace",
"(",
"'\\n'",
",",
"\"<enter>\"",
")",
"string",
"=",
"string",
".",
"replace",
"(",
"'\\t'",
",",
... | Sends the given string for output. | [
"Sends",
"the",
"given",
"string",
"for",
"output",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/iomediator/_iomediator.py#L124-L161 | train |
autokey/autokey | lib/autokey/iomediator/_iomediator.py | IoMediator.send_left | def send_left(self, count):
"""
Sends the given number of left key presses.
"""
for i in range(count):
self.interface.send_key(Key.LEFT) | python | def send_left(self, count):
"""
Sends the given number of left key presses.
"""
for i in range(count):
self.interface.send_key(Key.LEFT) | [
"def",
"send_left",
"(",
"self",
",",
"count",
")",
":",
"for",
"i",
"in",
"range",
"(",
"count",
")",
":",
"self",
".",
"interface",
".",
"send_key",
"(",
"Key",
".",
"LEFT",
")"
] | Sends the given number of left key presses. | [
"Sends",
"the",
"given",
"number",
"of",
"left",
"key",
"presses",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/iomediator/_iomediator.py#L200-L205 | train |
autokey/autokey | lib/autokey/iomediator/_iomediator.py | IoMediator.send_up | def send_up(self, count):
"""
Sends the given number of up key presses.
"""
for i in range(count):
self.interface.send_key(Key.UP) | python | def send_up(self, count):
"""
Sends the given number of up key presses.
"""
for i in range(count):
self.interface.send_key(Key.UP) | [
"def",
"send_up",
"(",
"self",
",",
"count",
")",
":",
"for",
"i",
"in",
"range",
"(",
"count",
")",
":",
"self",
".",
"interface",
".",
"send_key",
"(",
"Key",
".",
"UP",
")"
] | Sends the given number of up key presses. | [
"Sends",
"the",
"given",
"number",
"of",
"up",
"key",
"presses",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/iomediator/_iomediator.py#L211-L216 | train |
autokey/autokey | lib/autokey/iomediator/_iomediator.py | IoMediator.send_backspace | def send_backspace(self, count):
"""
Sends the given number of backspace key presses.
"""
for i in range(count):
self.interface.send_key(Key.BACKSPACE) | python | def send_backspace(self, count):
"""
Sends the given number of backspace key presses.
"""
for i in range(count):
self.interface.send_key(Key.BACKSPACE) | [
"def",
"send_backspace",
"(",
"self",
",",
"count",
")",
":",
"for",
"i",
"in",
"range",
"(",
"count",
")",
":",
"self",
".",
"interface",
".",
"send_key",
"(",
"Key",
".",
"BACKSPACE",
")"
] | Sends the given number of backspace key presses. | [
"Sends",
"the",
"given",
"number",
"of",
"backspace",
"key",
"presses",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/iomediator/_iomediator.py#L218-L223 | train |
autokey/autokey | lib/autokey/scripting.py | Keyboard.fake_keypress | def fake_keypress(self, key, repeat=1):
"""
Fake a keypress
Usage: C{keyboard.fake_keypress(key, repeat=1)}
Uses XTest to 'fake' a keypress. This is useful to send keypresses to some
applications which won't respond to keyboard.send_key()
@param key: they key to be sen... | python | def fake_keypress(self, key, repeat=1):
"""
Fake a keypress
Usage: C{keyboard.fake_keypress(key, repeat=1)}
Uses XTest to 'fake' a keypress. This is useful to send keypresses to some
applications which won't respond to keyboard.send_key()
@param key: they key to be sen... | [
"def",
"fake_keypress",
"(",
"self",
",",
"key",
",",
"repeat",
"=",
"1",
")",
":",
"for",
"_",
"in",
"range",
"(",
"repeat",
")",
":",
"self",
".",
"mediator",
".",
"fake_keypress",
"(",
"key",
")"
] | Fake a keypress
Usage: C{keyboard.fake_keypress(key, repeat=1)}
Uses XTest to 'fake' a keypress. This is useful to send keypresses to some
applications which won't respond to keyboard.send_key()
@param key: they key to be sent (e.g. "s" or "<enter>")
@param repeat: number of t... | [
"Fake",
"a",
"keypress"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/scripting.py#L148-L161 | train |
autokey/autokey | lib/autokey/scripting.py | QtDialog.info_dialog | def info_dialog(self, title="Information", message="", **kwargs):
"""
Show an information dialog
Usage: C{dialog.info_dialog(title="Information", message="", **kwargs)}
@param title: window title for the dialog
@param message: message displayed in the dialog
@return: a ... | python | def info_dialog(self, title="Information", message="", **kwargs):
"""
Show an information dialog
Usage: C{dialog.info_dialog(title="Information", message="", **kwargs)}
@param title: window title for the dialog
@param message: message displayed in the dialog
@return: a ... | [
"def",
"info_dialog",
"(",
"self",
",",
"title",
"=",
"\"Information\"",
",",
"message",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_run_kdialog",
"(",
"title",
",",
"[",
"\"--msgbox\"",
",",
"message",
"]",
",",
"kwargs",
... | Show an information dialog
Usage: C{dialog.info_dialog(title="Information", message="", **kwargs)}
@param title: window title for the dialog
@param message: message displayed in the dialog
@return: a tuple containing the exit code and user input
@rtype: C{DialogData(int, str)} | [
"Show",
"an",
"information",
"dialog"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/scripting.py#L265-L276 | train |
autokey/autokey | lib/autokey/scripting.py | QtDialog.calendar | def calendar(self, title="Choose a date", format_str="%Y-%m-%d", date="today", **kwargs):
"""
Show a calendar dialog
Usage: C{dialog.calendar_dialog(title="Choose a date", format="%Y-%m-%d", date="YYYY-MM-DD", **kwargs)}
Note: the format and date parameters are not currently used
... | python | def calendar(self, title="Choose a date", format_str="%Y-%m-%d", date="today", **kwargs):
"""
Show a calendar dialog
Usage: C{dialog.calendar_dialog(title="Choose a date", format="%Y-%m-%d", date="YYYY-MM-DD", **kwargs)}
Note: the format and date parameters are not currently used
... | [
"def",
"calendar",
"(",
"self",
",",
"title",
"=",
"\"Choose a date\"",
",",
"format_str",
"=",
"\"%Y-%m-%d\"",
",",
"date",
"=",
"\"today\"",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_run_kdialog",
"(",
"title",
",",
"[",
"\"--calendar\"... | Show a calendar dialog
Usage: C{dialog.calendar_dialog(title="Choose a date", format="%Y-%m-%d", date="YYYY-MM-DD", **kwargs)}
Note: the format and date parameters are not currently used
@param title: window title for the dialog
@param format_str: format of date to be returned
... | [
"Show",
"a",
"calendar",
"dialog"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/scripting.py#L453-L467 | train |
autokey/autokey | lib/autokey/scripting.py | Window.activate | def activate(self, title, switchDesktop=False, matchClass=False):
"""
Activate the specified window, giving it input focus
Usage: C{window.activate(title, switchDesktop=False, matchClass=False)}
If switchDesktop is False (default), the window will be moved to the current deskto... | python | def activate(self, title, switchDesktop=False, matchClass=False):
"""
Activate the specified window, giving it input focus
Usage: C{window.activate(title, switchDesktop=False, matchClass=False)}
If switchDesktop is False (default), the window will be moved to the current deskto... | [
"def",
"activate",
"(",
"self",
",",
"title",
",",
"switchDesktop",
"=",
"False",
",",
"matchClass",
"=",
"False",
")",
":",
"if",
"switchDesktop",
":",
"args",
"=",
"[",
"\"-a\"",
",",
"title",
"]",
"else",
":",
"args",
"=",
"[",
"\"-R\"",
",",
"tit... | Activate the specified window, giving it input focus
Usage: C{window.activate(title, switchDesktop=False, matchClass=False)}
If switchDesktop is False (default), the window will be moved to the current desktop
and activated. Otherwise, switch to the window's current desktop and activat... | [
"Activate",
"the",
"specified",
"window",
"giving",
"it",
"input",
"focus"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/scripting.py#L963-L982 | train |
autokey/autokey | lib/autokey/scripting.py | Window.set_property | def set_property(self, title, action, prop, matchClass=False):
"""
Set a property on the given window using the specified action
Usage: C{window.set_property(title, action, prop, matchClass=False)}
Allowable actions: C{add, remove, toggle}
Allowable properties: C{modal,... | python | def set_property(self, title, action, prop, matchClass=False):
"""
Set a property on the given window using the specified action
Usage: C{window.set_property(title, action, prop, matchClass=False)}
Allowable actions: C{add, remove, toggle}
Allowable properties: C{modal,... | [
"def",
"set_property",
"(",
"self",
",",
"title",
",",
"action",
",",
"prop",
",",
"matchClass",
"=",
"False",
")",
":",
"if",
"matchClass",
":",
"xArgs",
"=",
"[",
"\"-x\"",
"]",
"else",
":",
"xArgs",
"=",
"[",
"]",
"self",
".",
"_run_wmctrl",
"(",
... | Set a property on the given window using the specified action
Usage: C{window.set_property(title, action, prop, matchClass=False)}
Allowable actions: C{add, remove, toggle}
Allowable properties: C{modal, sticky, maximized_vert, maximized_horz, shaded, skip_taskbar,
skip_pager, ... | [
"Set",
"a",
"property",
"on",
"the",
"given",
"window",
"using",
"the",
"specified",
"action"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/scripting.py#L1047-L1066 | train |
autokey/autokey | lib/autokey/scripting.py | Engine.run_script_from_macro | def run_script_from_macro(self, args):
"""
Used internally by AutoKey for phrase macros
"""
self.__macroArgs = args["args"].split(',')
try:
self.run_script(args["name"])
except Exception as e:
self.set_return_value("{ERROR: %s}" % str(e)) | python | def run_script_from_macro(self, args):
"""
Used internally by AutoKey for phrase macros
"""
self.__macroArgs = args["args"].split(',')
try:
self.run_script(args["name"])
except Exception as e:
self.set_return_value("{ERROR: %s}" % str(e)) | [
"def",
"run_script_from_macro",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"__macroArgs",
"=",
"args",
"[",
"\"args\"",
"]",
".",
"split",
"(",
"','",
")",
"try",
":",
"self",
".",
"run_script",
"(",
"args",
"[",
"\"name\"",
"]",
")",
"except",
... | Used internally by AutoKey for phrase macros | [
"Used",
"internally",
"by",
"AutoKey",
"for",
"phrase",
"macros"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/scripting.py#L1256-L1265 | train |
autokey/autokey | lib/autokey/scripting_highlevel.py | move_to_pat | def move_to_pat(pat: str, offset: (float, float)=None, tolerance: int=0) -> None:
"""See help for click_on_pat"""
with tempfile.NamedTemporaryFile() as f:
subprocess.call('''
xwd -root -silent -display :0 |
convert xwd:- png:''' + f.name, shell=True)
loc = visgrep(f.name, pat, t... | python | def move_to_pat(pat: str, offset: (float, float)=None, tolerance: int=0) -> None:
"""See help for click_on_pat"""
with tempfile.NamedTemporaryFile() as f:
subprocess.call('''
xwd -root -silent -display :0 |
convert xwd:- png:''' + f.name, shell=True)
loc = visgrep(f.name, pat, t... | [
"def",
"move_to_pat",
"(",
"pat",
":",
"str",
",",
"offset",
":",
"(",
"float",
",",
"float",
")",
"=",
"None",
",",
"tolerance",
":",
"int",
"=",
"0",
")",
"->",
"None",
":",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
")",
"as",
"f",
":",... | See help for click_on_pat | [
"See",
"help",
"for",
"click_on_pat"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/scripting_highlevel.py#L99-L111 | train |
autokey/autokey | lib/autokey/scripting_highlevel.py | acknowledge_gnome_notification | def acknowledge_gnome_notification():
"""
Moves mouse pointer to the bottom center of the screen and clicks on it.
"""
x0, y0 = mouse_pos()
mouse_move(10000, 10000) # TODO: What if the screen is larger? Loop until mouse position does not change anymore?
x, y = mouse_pos()
mouse_rmove(-x/2, ... | python | def acknowledge_gnome_notification():
"""
Moves mouse pointer to the bottom center of the screen and clicks on it.
"""
x0, y0 = mouse_pos()
mouse_move(10000, 10000) # TODO: What if the screen is larger? Loop until mouse position does not change anymore?
x, y = mouse_pos()
mouse_rmove(-x/2, ... | [
"def",
"acknowledge_gnome_notification",
"(",
")",
":",
"x0",
",",
"y0",
"=",
"mouse_pos",
"(",
")",
"mouse_move",
"(",
"10000",
",",
"10000",
")",
"# TODO: What if the screen is larger? Loop until mouse position does not change anymore?",
"x",
",",
"y",
"=",
"mouse_pos... | Moves mouse pointer to the bottom center of the screen and clicks on it. | [
"Moves",
"mouse",
"pointer",
"to",
"the",
"bottom",
"center",
"of",
"the",
"screen",
"and",
"clicks",
"on",
"it",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/scripting_highlevel.py#L114-L124 | train |
autokey/autokey | lib/autokey/service.py | Service.calculate_extra_keys | def calculate_extra_keys(self, buffer):
"""
Determine extra keys pressed since the given buffer was built
"""
extraBs = len(self.inputStack) - len(buffer)
if extraBs > 0:
extraKeys = ''.join(self.inputStack[len(buffer)])
else:
extraBs = 0
... | python | def calculate_extra_keys(self, buffer):
"""
Determine extra keys pressed since the given buffer was built
"""
extraBs = len(self.inputStack) - len(buffer)
if extraBs > 0:
extraKeys = ''.join(self.inputStack[len(buffer)])
else:
extraBs = 0
... | [
"def",
"calculate_extra_keys",
"(",
"self",
",",
"buffer",
")",
":",
"extraBs",
"=",
"len",
"(",
"self",
".",
"inputStack",
")",
"-",
"len",
"(",
"buffer",
")",
"if",
"extraBs",
">",
"0",
":",
"extraKeys",
"=",
"''",
".",
"join",
"(",
"self",
".",
... | Determine extra keys pressed since the given buffer was built | [
"Determine",
"extra",
"keys",
"pressed",
"since",
"the",
"given",
"buffer",
"was",
"built"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/service.py#L244-L254 | train |
autokey/autokey | lib/autokey/service.py | Service.__updateStack | def __updateStack(self, key):
"""
Update the input stack in non-hotkey mode, and determine if anything
further is needed.
@return: True if further action is needed
"""
#if self.lastMenu is not None:
# if not ConfigManager.SETTINGS[MENU_TAKES_FOCUS]:
# ... | python | def __updateStack(self, key):
"""
Update the input stack in non-hotkey mode, and determine if anything
further is needed.
@return: True if further action is needed
"""
#if self.lastMenu is not None:
# if not ConfigManager.SETTINGS[MENU_TAKES_FOCUS]:
# ... | [
"def",
"__updateStack",
"(",
"self",
",",
"key",
")",
":",
"#if self.lastMenu is not None:",
"# if not ConfigManager.SETTINGS[MENU_TAKES_FOCUS]:",
"# self.app.hide_menu()",
"#",
"# self.lastMenu = None",
"if",
"key",
"==",
"Key",
".",
"ENTER",
":",
"# Special cas... | Update the input stack in non-hotkey mode, and determine if anything
further is needed.
@return: True if further action is needed | [
"Update",
"the",
"input",
"stack",
"in",
"non",
"-",
"hotkey",
"mode",
"and",
"determine",
"if",
"anything",
"further",
"is",
"needed",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/service.py#L256-L299 | train |
autokey/autokey | lib/autokey/interface.py | XInterfaceBase.__grabHotkeys | def __grabHotkeys(self):
"""
Run during startup to grab global and specific hotkeys in all open windows
"""
c = self.app.configManager
hotkeys = c.hotKeys + c.hotKeyFolders
# Grab global hotkeys in root window
for item in c.globalHotkeys:
if item.enab... | python | def __grabHotkeys(self):
"""
Run during startup to grab global and specific hotkeys in all open windows
"""
c = self.app.configManager
hotkeys = c.hotKeys + c.hotKeyFolders
# Grab global hotkeys in root window
for item in c.globalHotkeys:
if item.enab... | [
"def",
"__grabHotkeys",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"app",
".",
"configManager",
"hotkeys",
"=",
"c",
".",
"hotKeys",
"+",
"c",
".",
"hotKeyFolders",
"# Grab global hotkeys in root window",
"for",
"item",
"in",
"c",
".",
"globalHotkeys",
":... | Run during startup to grab global and specific hotkeys in all open windows | [
"Run",
"during",
"startup",
"to",
"grab",
"global",
"and",
"specific",
"hotkeys",
"in",
"all",
"open",
"windows"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L353-L374 | train |
autokey/autokey | lib/autokey/interface.py | XInterfaceBase.__ungrabAllHotkeys | def __ungrabAllHotkeys(self):
"""
Ungrab all hotkeys in preparation for keymap change
"""
c = self.app.configManager
hotkeys = c.hotKeys + c.hotKeyFolders
# Ungrab global hotkeys in root window, recursively
for item in c.globalHotkeys:
if item.enabled... | python | def __ungrabAllHotkeys(self):
"""
Ungrab all hotkeys in preparation for keymap change
"""
c = self.app.configManager
hotkeys = c.hotKeys + c.hotKeyFolders
# Ungrab global hotkeys in root window, recursively
for item in c.globalHotkeys:
if item.enabled... | [
"def",
"__ungrabAllHotkeys",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"app",
".",
"configManager",
"hotkeys",
"=",
"c",
".",
"hotKeys",
"+",
"c",
".",
"hotKeyFolders",
"# Ungrab global hotkeys in root window, recursively",
"for",
"item",
"in",
"c",
".",
"... | Ungrab all hotkeys in preparation for keymap change | [
"Ungrab",
"all",
"hotkeys",
"in",
"preparation",
"for",
"keymap",
"change"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L397-L418 | train |
autokey/autokey | lib/autokey/interface.py | XInterfaceBase.__grabHotkeysForWindow | def __grabHotkeysForWindow(self, window):
"""
Grab all hotkeys relevant to the window
Used when a new window is created
"""
c = self.app.configManager
hotkeys = c.hotKeys + c.hotKeyFolders
window_info = self.get_window_info(window)
for item in hotkeys:
... | python | def __grabHotkeysForWindow(self, window):
"""
Grab all hotkeys relevant to the window
Used when a new window is created
"""
c = self.app.configManager
hotkeys = c.hotKeys + c.hotKeyFolders
window_info = self.get_window_info(window)
for item in hotkeys:
... | [
"def",
"__grabHotkeysForWindow",
"(",
"self",
",",
"window",
")",
":",
"c",
"=",
"self",
".",
"app",
".",
"configManager",
"hotkeys",
"=",
"c",
".",
"hotKeys",
"+",
"c",
".",
"hotKeyFolders",
"window_info",
"=",
"self",
".",
"get_window_info",
"(",
"window... | Grab all hotkeys relevant to the window
Used when a new window is created | [
"Grab",
"all",
"hotkeys",
"relevant",
"to",
"the",
"window"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L441-L454 | train |
autokey/autokey | lib/autokey/interface.py | XInterfaceBase.__grabHotkey | def __grabHotkey(self, key, modifiers, window):
"""
Grab a specific hotkey in the given window
"""
logger.debug("Grabbing hotkey: %r %r", modifiers, key)
try:
keycode = self.__lookupKeyCode(key)
mask = 0
for mod in modifiers:
ma... | python | def __grabHotkey(self, key, modifiers, window):
"""
Grab a specific hotkey in the given window
"""
logger.debug("Grabbing hotkey: %r %r", modifiers, key)
try:
keycode = self.__lookupKeyCode(key)
mask = 0
for mod in modifiers:
ma... | [
"def",
"__grabHotkey",
"(",
"self",
",",
"key",
",",
"modifiers",
",",
"window",
")",
":",
"logger",
".",
"debug",
"(",
"\"Grabbing hotkey: %r %r\"",
",",
"modifiers",
",",
"key",
")",
"try",
":",
"keycode",
"=",
"self",
".",
"__lookupKeyCode",
"(",
"key",... | Grab a specific hotkey in the given window | [
"Grab",
"a",
"specific",
"hotkey",
"in",
"the",
"given",
"window"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L456-L479 | train |
autokey/autokey | lib/autokey/interface.py | XInterfaceBase.grab_hotkey | def grab_hotkey(self, item):
"""
Grab a hotkey.
If the hotkey has no filter regex, it is global and is grabbed recursively from the root window
If it has a filter regex, iterate over all children of the root and grab from matching windows
"""
if item.get_applicable_regex... | python | def grab_hotkey(self, item):
"""
Grab a hotkey.
If the hotkey has no filter regex, it is global and is grabbed recursively from the root window
If it has a filter regex, iterate over all children of the root and grab from matching windows
"""
if item.get_applicable_regex... | [
"def",
"grab_hotkey",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
".",
"get_applicable_regex",
"(",
")",
"is",
"None",
":",
"self",
".",
"__enqueue",
"(",
"self",
".",
"__grabHotkey",
",",
"item",
".",
"hotKey",
",",
"item",
".",
"modifiers",
","... | Grab a hotkey.
If the hotkey has no filter regex, it is global and is grabbed recursively from the root window
If it has a filter regex, iterate over all children of the root and grab from matching windows | [
"Grab",
"a",
"hotkey",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L481-L493 | train |
autokey/autokey | lib/autokey/interface.py | XInterfaceBase.ungrab_hotkey | def ungrab_hotkey(self, item):
"""
Ungrab a hotkey.
If the hotkey has no filter regex, it is global and is grabbed recursively from the root window
If it has a filter regex, iterate over all children of the root and ungrab from matching windows
"""
import copy
ne... | python | def ungrab_hotkey(self, item):
"""
Ungrab a hotkey.
If the hotkey has no filter regex, it is global and is grabbed recursively from the root window
If it has a filter regex, iterate over all children of the root and ungrab from matching windows
"""
import copy
ne... | [
"def",
"ungrab_hotkey",
"(",
"self",
",",
"item",
")",
":",
"import",
"copy",
"newItem",
"=",
"copy",
".",
"copy",
"(",
"item",
")",
"if",
"item",
".",
"get_applicable_regex",
"(",
")",
"is",
"None",
":",
"self",
".",
"__enqueue",
"(",
"self",
".",
"... | Ungrab a hotkey.
If the hotkey has no filter regex, it is global and is grabbed recursively from the root window
If it has a filter regex, iterate over all children of the root and ungrab from matching windows | [
"Ungrab",
"a",
"hotkey",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L514-L529 | train |
autokey/autokey | lib/autokey/interface.py | XInterfaceBase.__ungrabHotkey | def __ungrabHotkey(self, key, modifiers, window):
"""
Ungrab a specific hotkey in the given window
"""
logger.debug("Ungrabbing hotkey: %r %r", modifiers, key)
try:
keycode = self.__lookupKeyCode(key)
mask = 0
for mod in modifiers:
... | python | def __ungrabHotkey(self, key, modifiers, window):
"""
Ungrab a specific hotkey in the given window
"""
logger.debug("Ungrabbing hotkey: %r %r", modifiers, key)
try:
keycode = self.__lookupKeyCode(key)
mask = 0
for mod in modifiers:
... | [
"def",
"__ungrabHotkey",
"(",
"self",
",",
"key",
",",
"modifiers",
",",
"window",
")",
":",
"logger",
".",
"debug",
"(",
"\"Ungrabbing hotkey: %r %r\"",
",",
"modifiers",
",",
"key",
")",
"try",
":",
"keycode",
"=",
"self",
".",
"__lookupKeyCode",
"(",
"k... | Ungrab a specific hotkey in the given window | [
"Ungrab",
"a",
"specific",
"hotkey",
"in",
"the",
"given",
"window"
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L550-L572 | train |
autokey/autokey | lib/autokey/interface.py | XInterfaceBase._send_string_clipboard | def _send_string_clipboard(self, string: str, paste_command: model.SendMode):
"""
Use the clipboard to send a string.
"""
backup = self.clipboard.text # Keep a backup of current content, to restore the original afterwards.
if backup is None:
logger.warning("Tried to ... | python | def _send_string_clipboard(self, string: str, paste_command: model.SendMode):
"""
Use the clipboard to send a string.
"""
backup = self.clipboard.text # Keep a backup of current content, to restore the original afterwards.
if backup is None:
logger.warning("Tried to ... | [
"def",
"_send_string_clipboard",
"(",
"self",
",",
"string",
":",
"str",
",",
"paste_command",
":",
"model",
".",
"SendMode",
")",
":",
"backup",
"=",
"self",
".",
"clipboard",
".",
"text",
"# Keep a backup of current content, to restore the original afterwards.",
"if... | Use the clipboard to send a string. | [
"Use",
"the",
"clipboard",
"to",
"send",
"a",
"string",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L615-L628 | train |
autokey/autokey | lib/autokey/interface.py | XInterfaceBase._restore_clipboard_text | def _restore_clipboard_text(self, backup: str):
"""Restore the clipboard content."""
# Pasting takes some time, so wait a bit before restoring the content. Otherwise the restore is done before
# the pasting happens, causing the backup to be pasted instead of the desired clipboard content.
... | python | def _restore_clipboard_text(self, backup: str):
"""Restore the clipboard content."""
# Pasting takes some time, so wait a bit before restoring the content. Otherwise the restore is done before
# the pasting happens, causing the backup to be pasted instead of the desired clipboard content.
... | [
"def",
"_restore_clipboard_text",
"(",
"self",
",",
"backup",
":",
"str",
")",
":",
"# Pasting takes some time, so wait a bit before restoring the content. Otherwise the restore is done before",
"# the pasting happens, causing the backup to be pasted instead of the desired clipboard content.",... | Restore the clipboard content. | [
"Restore",
"the",
"clipboard",
"content",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L630-L635 | train |
autokey/autokey | lib/autokey/interface.py | XInterfaceBase._send_string_selection | def _send_string_selection(self, string: str):
"""Use the mouse selection clipboard to send a string."""
backup = self.clipboard.selection # Keep a backup of current content, to restore the original afterwards.
if backup is None:
logger.warning("Tried to backup the X PRIMARY selecti... | python | def _send_string_selection(self, string: str):
"""Use the mouse selection clipboard to send a string."""
backup = self.clipboard.selection # Keep a backup of current content, to restore the original afterwards.
if backup is None:
logger.warning("Tried to backup the X PRIMARY selecti... | [
"def",
"_send_string_selection",
"(",
"self",
",",
"string",
":",
"str",
")",
":",
"backup",
"=",
"self",
".",
"clipboard",
".",
"selection",
"# Keep a backup of current content, to restore the original afterwards.",
"if",
"backup",
"is",
"None",
":",
"logger",
".",
... | Use the mouse selection clipboard to send a string. | [
"Use",
"the",
"mouse",
"selection",
"clipboard",
"to",
"send",
"a",
"string",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L637-L644 | train |
autokey/autokey | lib/autokey/interface.py | XInterfaceBase._restore_clipboard_selection | def _restore_clipboard_selection(self, backup: str):
"""Restore the selection clipboard content."""
# Pasting takes some time, so wait a bit before restoring the content. Otherwise the restore is done before
# the pasting happens, causing the backup to be pasted instead of the desired clipboard ... | python | def _restore_clipboard_selection(self, backup: str):
"""Restore the selection clipboard content."""
# Pasting takes some time, so wait a bit before restoring the content. Otherwise the restore is done before
# the pasting happens, causing the backup to be pasted instead of the desired clipboard ... | [
"def",
"_restore_clipboard_selection",
"(",
"self",
",",
"backup",
":",
"str",
")",
":",
"# Pasting takes some time, so wait a bit before restoring the content. Otherwise the restore is done before",
"# the pasting happens, causing the backup to be pasted instead of the desired clipboard conte... | Restore the selection clipboard content. | [
"Restore",
"the",
"selection",
"clipboard",
"content",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/interface.py#L646-L654 | train |
autokey/autokey | lib/autokey/qtui/settings/engine.py | EngineSettings.save | def save(self):
"""This function is called by the parent dialog window when the user selects to save the settings."""
if self.path is None: # Delete requested, so remove the current path from sys.path, if present
if self.config_manager.userCodeDir is not None:
sys.path.remov... | python | def save(self):
"""This function is called by the parent dialog window when the user selects to save the settings."""
if self.path is None: # Delete requested, so remove the current path from sys.path, if present
if self.config_manager.userCodeDir is not None:
sys.path.remov... | [
"def",
"save",
"(",
"self",
")",
":",
"if",
"self",
".",
"path",
"is",
"None",
":",
"# Delete requested, so remove the current path from sys.path, if present",
"if",
"self",
".",
"config_manager",
".",
"userCodeDir",
"is",
"not",
"None",
":",
"sys",
".",
"path",
... | This function is called by the parent dialog window when the user selects to save the settings. | [
"This",
"function",
"is",
"called",
"by",
"the",
"parent",
"dialog",
"window",
"when",
"the",
"user",
"selects",
"to",
"save",
"the",
"settings",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/settings/engine.py#L55-L69 | train |
autokey/autokey | lib/autokey/qtui/settings/engine.py | EngineSettings.on_browse_button_pressed | def on_browse_button_pressed(self):
"""
PyQt slot called when the user hits the "Browse" button.
Display a directory selection dialog and store the returned path.
"""
path = QFileDialog.getExistingDirectory(self.parentWidget(), "Choose a directory containing Python modules")
... | python | def on_browse_button_pressed(self):
"""
PyQt slot called when the user hits the "Browse" button.
Display a directory selection dialog and store the returned path.
"""
path = QFileDialog.getExistingDirectory(self.parentWidget(), "Choose a directory containing Python modules")
... | [
"def",
"on_browse_button_pressed",
"(",
"self",
")",
":",
"path",
"=",
"QFileDialog",
".",
"getExistingDirectory",
"(",
"self",
".",
"parentWidget",
"(",
")",
",",
"\"Choose a directory containing Python modules\"",
")",
"if",
"path",
":",
"# Non-empty means the user ch... | PyQt slot called when the user hits the "Browse" button.
Display a directory selection dialog and store the returned path. | [
"PyQt",
"slot",
"called",
"when",
"the",
"user",
"hits",
"the",
"Browse",
"button",
".",
"Display",
"a",
"directory",
"selection",
"dialog",
"and",
"store",
"the",
"returned",
"path",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/settings/engine.py#L72-L83 | train |
autokey/autokey | lib/autokey/qtui/settings/engine.py | EngineSettings.on_clear_button_pressed | def on_clear_button_pressed(self):
"""
PyQt slot called when the user hits the "Clear" button.
Removes any set custom module search path.
"""
self.path = None
self.clear_button.setEnabled(False)
self.folder_label.setText(self.initial_folder_label_text)
log... | python | def on_clear_button_pressed(self):
"""
PyQt slot called when the user hits the "Clear" button.
Removes any set custom module search path.
"""
self.path = None
self.clear_button.setEnabled(False)
self.folder_label.setText(self.initial_folder_label_text)
log... | [
"def",
"on_clear_button_pressed",
"(",
"self",
")",
":",
"self",
".",
"path",
"=",
"None",
"self",
".",
"clear_button",
".",
"setEnabled",
"(",
"False",
")",
"self",
".",
"folder_label",
".",
"setText",
"(",
"self",
".",
"initial_folder_label_text",
")",
"lo... | PyQt slot called when the user hits the "Clear" button.
Removes any set custom module search path. | [
"PyQt",
"slot",
"called",
"when",
"the",
"user",
"hits",
"the",
"Clear",
"button",
".",
"Removes",
"any",
"set",
"custom",
"module",
"search",
"path",
"."
] | 35decb72f286ce68cd2a1f09ace8891a520b58d1 | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/qtui/settings/engine.py#L86-L94 | train |
maartenbreddels/ipyvolume | ipyvolume/examples.py | example_ylm | def example_ylm(m=0, n=2, shape=128, limits=[-4, 4], draw=True, show=True, **kwargs):
"""Show a spherical harmonic."""
import ipyvolume.pylab as p3
__, __, __, r, theta, phi = xyz(shape=shape, limits=limits, spherical=True)
radial = np.exp(-(r - 2) ** 2)
data = np.abs(scipy.special.sph_harm(m, n, t... | python | def example_ylm(m=0, n=2, shape=128, limits=[-4, 4], draw=True, show=True, **kwargs):
"""Show a spherical harmonic."""
import ipyvolume.pylab as p3
__, __, __, r, theta, phi = xyz(shape=shape, limits=limits, spherical=True)
radial = np.exp(-(r - 2) ** 2)
data = np.abs(scipy.special.sph_harm(m, n, t... | [
"def",
"example_ylm",
"(",
"m",
"=",
"0",
",",
"n",
"=",
"2",
",",
"shape",
"=",
"128",
",",
"limits",
"=",
"[",
"-",
"4",
",",
"4",
"]",
",",
"draw",
"=",
"True",
",",
"show",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"ipyv... | Show a spherical harmonic. | [
"Show",
"a",
"spherical",
"harmonic",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/examples.py#L55-L68 | train |
maartenbreddels/ipyvolume | ipyvolume/examples.py | ball | def ball(rmax=3, rmin=0, shape=128, limits=[-4, 4], draw=True, show=True, **kwargs):
"""Show a ball."""
import ipyvolume.pylab as p3
__, __, __, r, _theta, _phi = xyz(shape=shape, limits=limits, spherical=True)
data = r * 0
data[(r < rmax) & (r >= rmin)] = 0.5
if "data_min" not in kwargs:
... | python | def ball(rmax=3, rmin=0, shape=128, limits=[-4, 4], draw=True, show=True, **kwargs):
"""Show a ball."""
import ipyvolume.pylab as p3
__, __, __, r, _theta, _phi = xyz(shape=shape, limits=limits, spherical=True)
data = r * 0
data[(r < rmax) & (r >= rmin)] = 0.5
if "data_min" not in kwargs:
... | [
"def",
"ball",
"(",
"rmax",
"=",
"3",
",",
"rmin",
"=",
"0",
",",
"shape",
"=",
"128",
",",
"limits",
"=",
"[",
"-",
"4",
",",
"4",
"]",
",",
"draw",
"=",
"True",
",",
"show",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"ipyvo... | Show a ball. | [
"Show",
"a",
"ball",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/examples.py#L72-L90 | train |
maartenbreddels/ipyvolume | ipyvolume/examples.py | brain | def brain(
draw=True, show=True, fiducial=True, flat=True, inflated=True, subject='S1', interval=1000, uv=True, color=None
):
"""Show a human brain model.
Requirement:
$ pip install https://github.com/gallantlab/pycortex
"""
import ipyvolume as ipv
try:
import cortex
excep... | python | def brain(
draw=True, show=True, fiducial=True, flat=True, inflated=True, subject='S1', interval=1000, uv=True, color=None
):
"""Show a human brain model.
Requirement:
$ pip install https://github.com/gallantlab/pycortex
"""
import ipyvolume as ipv
try:
import cortex
excep... | [
"def",
"brain",
"(",
"draw",
"=",
"True",
",",
"show",
"=",
"True",
",",
"fiducial",
"=",
"True",
",",
"flat",
"=",
"True",
",",
"inflated",
"=",
"True",
",",
"subject",
"=",
"'S1'",
",",
"interval",
"=",
"1000",
",",
"uv",
"=",
"True",
",",
"col... | Show a human brain model.
Requirement:
$ pip install https://github.com/gallantlab/pycortex | [
"Show",
"a",
"human",
"brain",
"model",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/examples.py#L161-L229 | train |
maartenbreddels/ipyvolume | ipyvolume/examples.py | head | def head(draw=True, show=True, max_shape=256):
"""Show a volumetric rendering of a human male head."""
# inspired by http://graphicsrunner.blogspot.com/2009/01/volume-rendering-102-transfer-functions.html
import ipyvolume as ipv
from scipy.interpolate import interp1d
# First part is a simpler versi... | python | def head(draw=True, show=True, max_shape=256):
"""Show a volumetric rendering of a human male head."""
# inspired by http://graphicsrunner.blogspot.com/2009/01/volume-rendering-102-transfer-functions.html
import ipyvolume as ipv
from scipy.interpolate import interp1d
# First part is a simpler versi... | [
"def",
"head",
"(",
"draw",
"=",
"True",
",",
"show",
"=",
"True",
",",
"max_shape",
"=",
"256",
")",
":",
"# inspired by http://graphicsrunner.blogspot.com/2009/01/volume-rendering-102-transfer-functions.html",
"import",
"ipyvolume",
"as",
"ipv",
"from",
"scipy",
".",
... | Show a volumetric rendering of a human male head. | [
"Show",
"a",
"volumetric",
"rendering",
"of",
"a",
"human",
"male",
"head",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/examples.py#L232-L266 | train |
maartenbreddels/ipyvolume | ipyvolume/examples.py | gaussian | def gaussian(N=1000, draw=True, show=True, seed=42, color=None, marker='sphere'):
"""Show N random gaussian distributed points using a scatter plot."""
import ipyvolume as ipv
rng = np.random.RandomState(seed) # pylint: disable=no-member
x, y, z = rng.normal(size=(3, N))
if draw:
if color... | python | def gaussian(N=1000, draw=True, show=True, seed=42, color=None, marker='sphere'):
"""Show N random gaussian distributed points using a scatter plot."""
import ipyvolume as ipv
rng = np.random.RandomState(seed) # pylint: disable=no-member
x, y, z = rng.normal(size=(3, N))
if draw:
if color... | [
"def",
"gaussian",
"(",
"N",
"=",
"1000",
",",
"draw",
"=",
"True",
",",
"show",
"=",
"True",
",",
"seed",
"=",
"42",
",",
"color",
"=",
"None",
",",
"marker",
"=",
"'sphere'",
")",
":",
"import",
"ipyvolume",
"as",
"ipv",
"rng",
"=",
"np",
".",
... | Show N random gaussian distributed points using a scatter plot. | [
"Show",
"N",
"random",
"gaussian",
"distributed",
"points",
"using",
"a",
"scatter",
"plot",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/examples.py#L269-L286 | train |
maartenbreddels/ipyvolume | ipyvolume/pylab.py | figure | def figure(
key=None,
width=400,
height=500,
lighting=True,
controls=True,
controls_vr=False,
controls_light=False,
debug=False,
**kwargs
):
"""Create a new figure if no key is given, or return the figure associated with key.
:param key: Python object that identifies this fi... | python | def figure(
key=None,
width=400,
height=500,
lighting=True,
controls=True,
controls_vr=False,
controls_light=False,
debug=False,
**kwargs
):
"""Create a new figure if no key is given, or return the figure associated with key.
:param key: Python object that identifies this fi... | [
"def",
"figure",
"(",
"key",
"=",
"None",
",",
"width",
"=",
"400",
",",
"height",
"=",
"500",
",",
"lighting",
"=",
"True",
",",
"controls",
"=",
"True",
",",
"controls_vr",
"=",
"False",
",",
"controls_light",
"=",
"False",
",",
"debug",
"=",
"Fals... | Create a new figure if no key is given, or return the figure associated with key.
:param key: Python object that identifies this figure
:param int width: pixel width of WebGL canvas
:param int height: .. height ..
:param bool lighting: use lighting or not
:param bool controls: show controls or not... | [
"Create",
"a",
"new",
"figure",
"if",
"no",
"key",
"is",
"given",
"or",
"return",
"the",
"figure",
"associated",
"with",
"key",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L168-L222 | train |
maartenbreddels/ipyvolume | ipyvolume/pylab.py | squarelim | def squarelim():
"""Set all axes with equal aspect ratio, such that the space is 'square'."""
fig = gcf()
xmin, xmax = fig.xlim
ymin, ymax = fig.ylim
zmin, zmax = fig.zlim
width = max([abs(xmax - xmin), abs(ymax - ymin), abs(zmax - zmin)])
xc = (xmin + xmax) / 2
yc = (ymin + ymax) / 2
... | python | def squarelim():
"""Set all axes with equal aspect ratio, such that the space is 'square'."""
fig = gcf()
xmin, xmax = fig.xlim
ymin, ymax = fig.ylim
zmin, zmax = fig.zlim
width = max([abs(xmax - xmin), abs(ymax - ymin), abs(zmax - zmin)])
xc = (xmin + xmax) / 2
yc = (ymin + ymax) / 2
... | [
"def",
"squarelim",
"(",
")",
":",
"fig",
"=",
"gcf",
"(",
")",
"xmin",
",",
"xmax",
"=",
"fig",
".",
"xlim",
"ymin",
",",
"ymax",
"=",
"fig",
".",
"ylim",
"zmin",
",",
"zmax",
"=",
"fig",
".",
"zlim",
"width",
"=",
"max",
"(",
"[",
"abs",
"(... | Set all axes with equal aspect ratio, such that the space is 'square'. | [
"Set",
"all",
"axes",
"with",
"equal",
"aspect",
"ratio",
"such",
"that",
"the",
"space",
"is",
"square",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L290-L302 | train |
maartenbreddels/ipyvolume | ipyvolume/pylab.py | plot_surface | def plot_surface(x, y, z, color=default_color, wrapx=False, wrapy=False):
"""Draws a 2d surface in 3d, defined by the 2d ordered arrays x,y,z.
:param x: {x2d}
:param y: {y2d}
:param z: {z2d}
:param color: {color2d}
:param bool wrapx: when True, the x direction is assumed to wrap, and polygons a... | python | def plot_surface(x, y, z, color=default_color, wrapx=False, wrapy=False):
"""Draws a 2d surface in 3d, defined by the 2d ordered arrays x,y,z.
:param x: {x2d}
:param y: {y2d}
:param z: {z2d}
:param color: {color2d}
:param bool wrapx: when True, the x direction is assumed to wrap, and polygons a... | [
"def",
"plot_surface",
"(",
"x",
",",
"y",
",",
"z",
",",
"color",
"=",
"default_color",
",",
"wrapx",
"=",
"False",
",",
"wrapy",
"=",
"False",
")",
":",
"return",
"plot_mesh",
"(",
"x",
",",
"y",
",",
"z",
",",
"color",
"=",
"color",
",",
"wrap... | Draws a 2d surface in 3d, defined by the 2d ordered arrays x,y,z.
:param x: {x2d}
:param y: {y2d}
:param z: {z2d}
:param color: {color2d}
:param bool wrapx: when True, the x direction is assumed to wrap, and polygons are drawn between the end end begin points
:param bool wrapy: simular for the ... | [
"Draws",
"a",
"2d",
"surface",
"in",
"3d",
"defined",
"by",
"the",
"2d",
"ordered",
"arrays",
"x",
"y",
"z",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L354-L365 | train |
maartenbreddels/ipyvolume | ipyvolume/pylab.py | plot_wireframe | def plot_wireframe(x, y, z, color=default_color, wrapx=False, wrapy=False):
"""Draws a 2d wireframe in 3d, defines by the 2d ordered arrays x,y,z.
See also :any:`ipyvolume.pylab.plot_mesh`
:param x: {x2d}
:param y: {y2d}
:param z: {z2d}
:param color: {color2d}
:param bool wrapx: when True,... | python | def plot_wireframe(x, y, z, color=default_color, wrapx=False, wrapy=False):
"""Draws a 2d wireframe in 3d, defines by the 2d ordered arrays x,y,z.
See also :any:`ipyvolume.pylab.plot_mesh`
:param x: {x2d}
:param y: {y2d}
:param z: {z2d}
:param color: {color2d}
:param bool wrapx: when True,... | [
"def",
"plot_wireframe",
"(",
"x",
",",
"y",
",",
"z",
",",
"color",
"=",
"default_color",
",",
"wrapx",
"=",
"False",
",",
"wrapy",
"=",
"False",
")",
":",
"return",
"plot_mesh",
"(",
"x",
",",
"y",
",",
"z",
",",
"color",
"=",
"color",
",",
"wr... | Draws a 2d wireframe in 3d, defines by the 2d ordered arrays x,y,z.
See also :any:`ipyvolume.pylab.plot_mesh`
:param x: {x2d}
:param y: {y2d}
:param z: {z2d}
:param color: {color2d}
:param bool wrapx: when True, the x direction is assumed to wrap, and polygons are drawn between the begin and e... | [
"Draws",
"a",
"2d",
"wireframe",
"in",
"3d",
"defines",
"by",
"the",
"2d",
"ordered",
"arrays",
"x",
"y",
"z",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L369-L382 | train |
maartenbreddels/ipyvolume | ipyvolume/pylab.py | plot | def plot(x, y, z, color=default_color, **kwargs):
"""Plot a line in 3d.
:param x: {x}
:param y: {y}
:param z: {z}
:param color: {color}
:param kwargs: extra arguments passed to the Scatter constructor
:return: :any:`Scatter`
"""
fig = gcf()
_grow_limits(x, y, z)
defaults = d... | python | def plot(x, y, z, color=default_color, **kwargs):
"""Plot a line in 3d.
:param x: {x}
:param y: {y}
:param z: {z}
:param color: {color}
:param kwargs: extra arguments passed to the Scatter constructor
:return: :any:`Scatter`
"""
fig = gcf()
_grow_limits(x, y, z)
defaults = d... | [
"def",
"plot",
"(",
"x",
",",
"y",
",",
"z",
",",
"color",
"=",
"default_color",
",",
"*",
"*",
"kwargs",
")",
":",
"fig",
"=",
"gcf",
"(",
")",
"_grow_limits",
"(",
"x",
",",
"y",
",",
"z",
")",
"defaults",
"=",
"dict",
"(",
"visible_lines",
"... | Plot a line in 3d.
:param x: {x}
:param y: {y}
:param z: {z}
:param color: {color}
:param kwargs: extra arguments passed to the Scatter constructor
:return: :any:`Scatter` | [
"Plot",
"a",
"line",
"in",
"3d",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L480-L499 | train |
maartenbreddels/ipyvolume | ipyvolume/pylab.py | quiver | def quiver(
x,
y,
z,
u,
v,
w,
size=default_size * 10,
size_selected=default_size_selected * 10,
color=default_color,
color_selected=default_color_selected,
marker="arrow",
**kwargs
):
"""Create a quiver plot, which is like a scatter plot but with arrows pointing in th... | python | def quiver(
x,
y,
z,
u,
v,
w,
size=default_size * 10,
size_selected=default_size_selected * 10,
color=default_color,
color_selected=default_color_selected,
marker="arrow",
**kwargs
):
"""Create a quiver plot, which is like a scatter plot but with arrows pointing in th... | [
"def",
"quiver",
"(",
"x",
",",
"y",
",",
"z",
",",
"u",
",",
"v",
",",
"w",
",",
"size",
"=",
"default_size",
"*",
"10",
",",
"size_selected",
"=",
"default_size_selected",
"*",
"10",
",",
"color",
"=",
"default_color",
",",
"color_selected",
"=",
"... | Create a quiver plot, which is like a scatter plot but with arrows pointing in the direction given by u, v and w.
:param x: {x}
:param y: {y}
:param z: {z}
:param u: {u_dir}
:param v: {v_dir}
:param w: {w_dir}
:param size: {size}
:param size_selected: like size, but for selected glyphs
... | [
"Create",
"a",
"quiver",
"plot",
"which",
"is",
"like",
"a",
"scatter",
"plot",
"but",
"with",
"arrows",
"pointing",
"in",
"the",
"direction",
"given",
"by",
"u",
"v",
"and",
"w",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L551-L600 | train |
maartenbreddels/ipyvolume | ipyvolume/pylab.py | animation_control | def animation_control(object, sequence_length=None, add=True, interval=200):
"""Animate scatter, quiver or mesh by adding a slider and play button.
:param object: :any:`Scatter` or :any:`Mesh` object (having an sequence_index property), or a list of these to
control multiple.
:param sequ... | python | def animation_control(object, sequence_length=None, add=True, interval=200):
"""Animate scatter, quiver or mesh by adding a slider and play button.
:param object: :any:`Scatter` or :any:`Mesh` object (having an sequence_index property), or a list of these to
control multiple.
:param sequ... | [
"def",
"animation_control",
"(",
"object",
",",
"sequence_length",
"=",
"None",
",",
"add",
"=",
"True",
",",
"interval",
"=",
"200",
")",
":",
"if",
"isinstance",
"(",
"object",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"objects",
"=",
"object",
... | Animate scatter, quiver or mesh by adding a slider and play button.
:param object: :any:`Scatter` or :any:`Mesh` object (having an sequence_index property), or a list of these to
control multiple.
:param sequence_length: If sequence_length is None we try try our best to figure out, in case w... | [
"Animate",
"scatter",
"quiver",
"or",
"mesh",
"by",
"adding",
"a",
"slider",
"and",
"play",
"button",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L617-L675 | train |
maartenbreddels/ipyvolume | ipyvolume/pylab.py | transfer_function | def transfer_function(
level=[0.1, 0.5, 0.9], opacity=[0.01, 0.05, 0.1], level_width=0.1, controls=True, max_opacity=0.2
):
"""Create a transfer function, see volshow."""
tf_kwargs = {}
# level, opacity and widths can be scalars
try:
level[0]
except:
level = [level]
try:
... | python | def transfer_function(
level=[0.1, 0.5, 0.9], opacity=[0.01, 0.05, 0.1], level_width=0.1, controls=True, max_opacity=0.2
):
"""Create a transfer function, see volshow."""
tf_kwargs = {}
# level, opacity and widths can be scalars
try:
level[0]
except:
level = [level]
try:
... | [
"def",
"transfer_function",
"(",
"level",
"=",
"[",
"0.1",
",",
"0.5",
",",
"0.9",
"]",
",",
"opacity",
"=",
"[",
"0.01",
",",
"0.05",
",",
"0.1",
"]",
",",
"level_width",
"=",
"0.1",
",",
"controls",
"=",
"True",
",",
"max_opacity",
"=",
"0.2",
")... | Create a transfer function, see volshow. | [
"Create",
"a",
"transfer",
"function",
"see",
"volshow",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L684-L722 | train |
maartenbreddels/ipyvolume | ipyvolume/pylab.py | save | def save(
filepath,
makedirs=True,
title=u'IPyVolume Widget',
all_states=False,
offline=False,
scripts_path='js',
drop_defaults=False,
template_options=(("extra_script_head", ""), ("body_pre", ""), ("body_post", "")),
devmode=False,
offline_cors=False,
):
"""Save the current ... | python | def save(
filepath,
makedirs=True,
title=u'IPyVolume Widget',
all_states=False,
offline=False,
scripts_path='js',
drop_defaults=False,
template_options=(("extra_script_head", ""), ("body_pre", ""), ("body_post", "")),
devmode=False,
offline_cors=False,
):
"""Save the current ... | [
"def",
"save",
"(",
"filepath",
",",
"makedirs",
"=",
"True",
",",
"title",
"=",
"u'IPyVolume Widget'",
",",
"all_states",
"=",
"False",
",",
"offline",
"=",
"False",
",",
"scripts_path",
"=",
"'js'",
",",
"drop_defaults",
"=",
"False",
",",
"template_option... | Save the current container to a HTML file.
By default the HTML file is not standalone and requires an internet connection to fetch a few javascript
libraries. Use offline=True to download these and make the HTML file work without an internet connection.
:param str filepath: The file to write the HTML outp... | [
"Save",
"the",
"current",
"container",
"to",
"a",
"HTML",
"file",
"."
] | e68b72852b61276f8e6793bc8811f5b2432a155f | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L888-L930 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.