id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
225,700 | sosreport/sos | sos/plugins/origin.py | OpenShiftOrigin.is_static_etcd | def is_static_etcd(self):
'''Determine if we are on a node running etcd'''
return os.path.exists(os.path.join(self.static_pod_dir, "etcd.yaml")) | python | def is_static_etcd(self):
'''Determine if we are on a node running etcd'''
return os.path.exists(os.path.join(self.static_pod_dir, "etcd.yaml")) | [
"def",
"is_static_etcd",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"static_pod_dir",
",",
"\"etcd.yaml\"",
")",
")"
] | Determine if we are on a node running etcd | [
"Determine",
"if",
"we",
"are",
"on",
"a",
"node",
"running",
"etcd"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/origin.py#L78-L80 |
225,701 | sosreport/sos | sos/plugins/networking.py | Networking.get_ip_netns | def get_ip_netns(self, ip_netns_file):
"""Returns a list for which items are namespaces in the output of
ip netns stored in the ip_netns_file.
"""
out = []
try:
ip_netns_out = open(ip_netns_file).read()
except IOError:
return out
for line i... | python | def get_ip_netns(self, ip_netns_file):
"""Returns a list for which items are namespaces in the output of
ip netns stored in the ip_netns_file.
"""
out = []
try:
ip_netns_out = open(ip_netns_file).read()
except IOError:
return out
for line i... | [
"def",
"get_ip_netns",
"(",
"self",
",",
"ip_netns_file",
")",
":",
"out",
"=",
"[",
"]",
"try",
":",
"ip_netns_out",
"=",
"open",
"(",
"ip_netns_file",
")",
".",
"read",
"(",
")",
"except",
"IOError",
":",
"return",
"out",
"for",
"line",
"in",
"ip_net... | Returns a list for which items are namespaces in the output of
ip netns stored in the ip_netns_file. | [
"Returns",
"a",
"list",
"for",
"which",
"items",
"are",
"namespaces",
"in",
"the",
"output",
"of",
"ip",
"netns",
"stored",
"in",
"the",
"ip_netns_file",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/networking.py#L28-L44 |
225,702 | sosreport/sos | sos/plugins/networking.py | Networking.collect_iptable | def collect_iptable(self, tablename):
""" When running the iptables command, it unfortunately auto-loads
the modules before trying to get output. Some people explicitly
don't want this, so check if the modules are loaded before running
the command. If they aren't loaded, there can't po... | python | def collect_iptable(self, tablename):
""" When running the iptables command, it unfortunately auto-loads
the modules before trying to get output. Some people explicitly
don't want this, so check if the modules are loaded before running
the command. If they aren't loaded, there can't po... | [
"def",
"collect_iptable",
"(",
"self",
",",
"tablename",
")",
":",
"modname",
"=",
"\"iptable_\"",
"+",
"tablename",
"if",
"self",
".",
"check_ext_prog",
"(",
"\"grep -q %s /proc/modules\"",
"%",
"modname",
")",
":",
"cmd",
"=",
"\"iptables -t \"",
"+",
"tablena... | When running the iptables command, it unfortunately auto-loads
the modules before trying to get output. Some people explicitly
don't want this, so check if the modules are loaded before running
the command. If they aren't loaded, there can't possibly be any
relevant rules in that table | [
"When",
"running",
"the",
"iptables",
"command",
"it",
"unfortunately",
"auto",
"-",
"loads",
"the",
"modules",
"before",
"trying",
"to",
"get",
"output",
".",
"Some",
"people",
"explicitly",
"don",
"t",
"want",
"this",
"so",
"check",
"if",
"the",
"modules",... | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/networking.py#L46-L56 |
225,703 | sosreport/sos | sos/plugins/networking.py | Networking.collect_ip6table | def collect_ip6table(self, tablename):
""" Same as function above, but for ipv6 """
modname = "ip6table_"+tablename
if self.check_ext_prog("grep -q %s /proc/modules" % modname):
cmd = "ip6tables -t "+tablename+" -nvL"
self.add_cmd_output(cmd) | python | def collect_ip6table(self, tablename):
""" Same as function above, but for ipv6 """
modname = "ip6table_"+tablename
if self.check_ext_prog("grep -q %s /proc/modules" % modname):
cmd = "ip6tables -t "+tablename+" -nvL"
self.add_cmd_output(cmd) | [
"def",
"collect_ip6table",
"(",
"self",
",",
"tablename",
")",
":",
"modname",
"=",
"\"ip6table_\"",
"+",
"tablename",
"if",
"self",
".",
"check_ext_prog",
"(",
"\"grep -q %s /proc/modules\"",
"%",
"modname",
")",
":",
"cmd",
"=",
"\"ip6tables -t \"",
"+",
"tabl... | Same as function above, but for ipv6 | [
"Same",
"as",
"function",
"above",
"but",
"for",
"ipv6"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/networking.py#L58-L64 |
225,704 | sosreport/sos | sos/plugins/ovirt.py | Ovirt.postproc | def postproc(self):
"""
Obfuscate sensitive keys.
"""
self.do_file_sub(
"/etc/ovirt-engine/engine-config/engine-config.properties",
r"Password.type=(.*)",
r"Password.type=********"
)
self.do_file_sub(
"/etc/rhevm/rhevm-confi... | python | def postproc(self):
"""
Obfuscate sensitive keys.
"""
self.do_file_sub(
"/etc/ovirt-engine/engine-config/engine-config.properties",
r"Password.type=(.*)",
r"Password.type=********"
)
self.do_file_sub(
"/etc/rhevm/rhevm-confi... | [
"def",
"postproc",
"(",
"self",
")",
":",
"self",
".",
"do_file_sub",
"(",
"\"/etc/ovirt-engine/engine-config/engine-config.properties\"",
",",
"r\"Password.type=(.*)\"",
",",
"r\"Password.type=********\"",
")",
"self",
".",
"do_file_sub",
"(",
"\"/etc/rhevm/rhevm-config/rhev... | Obfuscate sensitive keys. | [
"Obfuscate",
"sensitive",
"keys",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/ovirt.py#L135-L226 |
225,705 | sosreport/sos | sos/plugins/watchdog.py | Watchdog.get_log_dir | def get_log_dir(self, conf_file):
"""Get watchdog log directory.
Get watchdog log directory path configured in ``conf_file``.
:returns: The watchdog log directory path.
:returntype: str.
:raises: IOError if ``conf_file`` is not readable.
"""
log_... | python | def get_log_dir(self, conf_file):
"""Get watchdog log directory.
Get watchdog log directory path configured in ``conf_file``.
:returns: The watchdog log directory path.
:returntype: str.
:raises: IOError if ``conf_file`` is not readable.
"""
log_... | [
"def",
"get_log_dir",
"(",
"self",
",",
"conf_file",
")",
":",
"log_dir",
"=",
"None",
"with",
"open",
"(",
"conf_file",
",",
"'r'",
")",
"as",
"conf_f",
":",
"for",
"line",
"in",
"conf_f",
":",
"line",
"=",
"line",
".",
"split",
"(",
"'#'",
")",
"... | Get watchdog log directory.
Get watchdog log directory path configured in ``conf_file``.
:returns: The watchdog log directory path.
:returntype: str.
:raises: IOError if ``conf_file`` is not readable. | [
"Get",
"watchdog",
"log",
"directory",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/watchdog.py#L27-L49 |
225,706 | sosreport/sos | sos/plugins/watchdog.py | Watchdog.setup | def setup(self):
"""Collect watchdog information.
Collect configuration files, custom executables for test-binary
and repair-binary, and stdout/stderr logs.
"""
conf_file = self.get_option('conf_file')
log_dir = '/var/log/watchdog'
# Get service configur... | python | def setup(self):
"""Collect watchdog information.
Collect configuration files, custom executables for test-binary
and repair-binary, and stdout/stderr logs.
"""
conf_file = self.get_option('conf_file')
log_dir = '/var/log/watchdog'
# Get service configur... | [
"def",
"setup",
"(",
"self",
")",
":",
"conf_file",
"=",
"self",
".",
"get_option",
"(",
"'conf_file'",
")",
"log_dir",
"=",
"'/var/log/watchdog'",
"# Get service configuration and sysconfig files",
"self",
".",
"add_copy_spec",
"(",
"[",
"conf_file",
",",
"'/etc/sy... | Collect watchdog information.
Collect configuration files, custom executables for test-binary
and repair-binary, and stdout/stderr logs. | [
"Collect",
"watchdog",
"information",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/watchdog.py#L51-L90 |
225,707 | sosreport/sos | sos/plugins/gluster.py | Gluster.get_volume_names | def get_volume_names(self, volume_file):
"""Return a dictionary for which key are volume names according to the
output of gluster volume info stored in volume_file.
"""
out = []
fp = open(volume_file, 'r')
for line in fp.readlines():
if not line.startswith("Vo... | python | def get_volume_names(self, volume_file):
"""Return a dictionary for which key are volume names according to the
output of gluster volume info stored in volume_file.
"""
out = []
fp = open(volume_file, 'r')
for line in fp.readlines():
if not line.startswith("Vo... | [
"def",
"get_volume_names",
"(",
"self",
",",
"volume_file",
")",
":",
"out",
"=",
"[",
"]",
"fp",
"=",
"open",
"(",
"volume_file",
",",
"'r'",
")",
"for",
"line",
"in",
"fp",
".",
"readlines",
"(",
")",
":",
"if",
"not",
"line",
".",
"startswith",
... | Return a dictionary for which key are volume names according to the
output of gluster volume info stored in volume_file. | [
"Return",
"a",
"dictionary",
"for",
"which",
"key",
"are",
"volume",
"names",
"according",
"to",
"the",
"output",
"of",
"gluster",
"volume",
"info",
"stored",
"in",
"volume_file",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/gluster.py#L29-L41 |
225,708 | sosreport/sos | sos/policies/ubuntu.py | UbuntuPolicy.dist_version | def dist_version(self):
""" Returns the version stated in DISTRIB_RELEASE
"""
try:
with open('/etc/lsb-release', 'r') as fp:
lines = fp.readlines()
for line in lines:
if "DISTRIB_RELEASE" in line:
return line... | python | def dist_version(self):
""" Returns the version stated in DISTRIB_RELEASE
"""
try:
with open('/etc/lsb-release', 'r') as fp:
lines = fp.readlines()
for line in lines:
if "DISTRIB_RELEASE" in line:
return line... | [
"def",
"dist_version",
"(",
"self",
")",
":",
"try",
":",
"with",
"open",
"(",
"'/etc/lsb-release'",
",",
"'r'",
")",
"as",
"fp",
":",
"lines",
"=",
"fp",
".",
"readlines",
"(",
")",
"for",
"line",
"in",
"lines",
":",
"if",
"\"DISTRIB_RELEASE\"",
"in",... | Returns the version stated in DISTRIB_RELEASE | [
"Returns",
"the",
"version",
"stated",
"in",
"DISTRIB_RELEASE"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/ubuntu.py#L26-L37 |
225,709 | sosreport/sos | sos/archive.py | FileCacheArchive._make_leading_paths | def _make_leading_paths(self, src, mode=0o700):
"""Create leading path components
The standard python `os.makedirs` is insufficient for our
needs: it will only create directories, and ignores the fact
that some path components may be symbolic links.
:param src: ... | python | def _make_leading_paths(self, src, mode=0o700):
"""Create leading path components
The standard python `os.makedirs` is insufficient for our
needs: it will only create directories, and ignores the fact
that some path components may be symbolic links.
:param src: ... | [
"def",
"_make_leading_paths",
"(",
"self",
",",
"src",
",",
"mode",
"=",
"0o700",
")",
":",
"self",
".",
"log_debug",
"(",
"\"Making leading paths for %s\"",
"%",
"src",
")",
"root",
"=",
"self",
".",
"_archive_root",
"dest",
"=",
"src",
"def",
"in_archive",... | Create leading path components
The standard python `os.makedirs` is insufficient for our
needs: it will only create directories, and ignores the fact
that some path components may be symbolic links.
:param src: The source path in the host file system for which
... | [
"Create",
"leading",
"path",
"components"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/archive.py#L159-L243 |
225,710 | sosreport/sos | sos/archive.py | FileCacheArchive._check_path | def _check_path(self, src, path_type, dest=None, force=False):
"""Check a new destination path in the archive.
Since it is possible for multiple plugins to collect the same
paths, and since plugins can now run concurrently, it is possible
for two threads to race in archive m... | python | def _check_path(self, src, path_type, dest=None, force=False):
"""Check a new destination path in the archive.
Since it is possible for multiple plugins to collect the same
paths, and since plugins can now run concurrently, it is possible
for two threads to race in archive m... | [
"def",
"_check_path",
"(",
"self",
",",
"src",
",",
"path_type",
",",
"dest",
"=",
"None",
",",
"force",
"=",
"False",
")",
":",
"dest",
"=",
"dest",
"or",
"self",
".",
"dest_path",
"(",
"src",
")",
"if",
"path_type",
"==",
"P_DIR",
":",
"dest_dir",
... | Check a new destination path in the archive.
Since it is possible for multiple plugins to collect the same
paths, and since plugins can now run concurrently, it is possible
for two threads to race in archive methods: historically the
archive class only needed to test for... | [
"Check",
"a",
"new",
"destination",
"path",
"in",
"the",
"archive",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/archive.py#L245-L318 |
225,711 | sosreport/sos | sos/archive.py | FileCacheArchive.makedirs | def makedirs(self, path, mode=0o700):
"""Create path, including leading components.
Used by sos.sosreport to set up sos_* directories.
"""
os.makedirs(os.path.join(self._archive_root, path), mode=mode)
self.log_debug("created directory at '%s' in FileCacheArchive '%s'"
... | python | def makedirs(self, path, mode=0o700):
"""Create path, including leading components.
Used by sos.sosreport to set up sos_* directories.
"""
os.makedirs(os.path.join(self._archive_root, path), mode=mode)
self.log_debug("created directory at '%s' in FileCacheArchive '%s'"
... | [
"def",
"makedirs",
"(",
"self",
",",
"path",
",",
"mode",
"=",
"0o700",
")",
":",
"os",
".",
"makedirs",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_archive_root",
",",
"path",
")",
",",
"mode",
"=",
"mode",
")",
"self",
".",
"log_de... | Create path, including leading components.
Used by sos.sosreport to set up sos_* directories. | [
"Create",
"path",
"including",
"leading",
"components",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/archive.py#L510-L517 |
225,712 | sosreport/sos | sos/archive.py | FileCacheArchive._encrypt | def _encrypt(self, archive):
"""Encrypts the compressed archive using GPG.
If encryption fails for any reason, it should be logged by sos but not
cause execution to stop. The assumption is that the unencrypted archive
would still be of use to the user, and/or that the end user has anoth... | python | def _encrypt(self, archive):
"""Encrypts the compressed archive using GPG.
If encryption fails for any reason, it should be logged by sos but not
cause execution to stop. The assumption is that the unencrypted archive
would still be of use to the user, and/or that the end user has anoth... | [
"def",
"_encrypt",
"(",
"self",
",",
"archive",
")",
":",
"arc_name",
"=",
"archive",
".",
"replace",
"(",
"\"sosreport-\"",
",",
"\"secured-sosreport-\"",
")",
"arc_name",
"+=",
"\".gpg\"",
"enc_cmd",
"=",
"\"gpg --batch -o %s \"",
"%",
"arc_name",
"env",
"=",
... | Encrypts the compressed archive using GPG.
If encryption fails for any reason, it should be logged by sos but not
cause execution to stop. The assumption is that the unencrypted archive
would still be of use to the user, and/or that the end user has another
means of securing the archive... | [
"Encrypts",
"the",
"compressed",
"archive",
"using",
"GPG",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/archive.py#L552-L593 |
225,713 | sosreport/sos | sos/utilities.py | tail | def tail(filename, number_of_bytes):
"""Returns the last number_of_bytes of filename"""
with open(filename, "rb") as f:
if os.stat(filename).st_size > number_of_bytes:
f.seek(-number_of_bytes, 2)
return f.read() | python | def tail(filename, number_of_bytes):
"""Returns the last number_of_bytes of filename"""
with open(filename, "rb") as f:
if os.stat(filename).st_size > number_of_bytes:
f.seek(-number_of_bytes, 2)
return f.read() | [
"def",
"tail",
"(",
"filename",
",",
"number_of_bytes",
")",
":",
"with",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"as",
"f",
":",
"if",
"os",
".",
"stat",
"(",
"filename",
")",
".",
"st_size",
">",
"number_of_bytes",
":",
"f",
".",
"seek",
"(",
... | Returns the last number_of_bytes of filename | [
"Returns",
"the",
"last",
"number_of_bytes",
"of",
"filename"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L29-L34 |
225,714 | sosreport/sos | sos/utilities.py | fileobj | def fileobj(path_or_file, mode='r'):
"""Returns a file-like object that can be used as a context manager"""
if isinstance(path_or_file, six.string_types):
try:
return open(path_or_file, mode)
except IOError:
log = logging.getLogger('sos')
log.debug("fileobj: %... | python | def fileobj(path_or_file, mode='r'):
"""Returns a file-like object that can be used as a context manager"""
if isinstance(path_or_file, six.string_types):
try:
return open(path_or_file, mode)
except IOError:
log = logging.getLogger('sos')
log.debug("fileobj: %... | [
"def",
"fileobj",
"(",
"path_or_file",
",",
"mode",
"=",
"'r'",
")",
":",
"if",
"isinstance",
"(",
"path_or_file",
",",
"six",
".",
"string_types",
")",
":",
"try",
":",
"return",
"open",
"(",
"path_or_file",
",",
"mode",
")",
"except",
"IOError",
":",
... | Returns a file-like object that can be used as a context manager | [
"Returns",
"a",
"file",
"-",
"like",
"object",
"that",
"can",
"be",
"used",
"as",
"a",
"context",
"manager"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L37-L47 |
225,715 | sosreport/sos | sos/utilities.py | convert_bytes | def convert_bytes(bytes_, K=1 << 10, M=1 << 20, G=1 << 30, T=1 << 40):
"""Converts a number of bytes to a shorter, more human friendly format"""
fn = float(bytes_)
if bytes_ >= T:
return '%.1fT' % (fn / T)
elif bytes_ >= G:
return '%.1fG' % (fn / G)
elif bytes_ >= M:
return '... | python | def convert_bytes(bytes_, K=1 << 10, M=1 << 20, G=1 << 30, T=1 << 40):
"""Converts a number of bytes to a shorter, more human friendly format"""
fn = float(bytes_)
if bytes_ >= T:
return '%.1fT' % (fn / T)
elif bytes_ >= G:
return '%.1fG' % (fn / G)
elif bytes_ >= M:
return '... | [
"def",
"convert_bytes",
"(",
"bytes_",
",",
"K",
"=",
"1",
"<<",
"10",
",",
"M",
"=",
"1",
"<<",
"20",
",",
"G",
"=",
"1",
"<<",
"30",
",",
"T",
"=",
"1",
"<<",
"40",
")",
":",
"fn",
"=",
"float",
"(",
"bytes_",
")",
"if",
"bytes_",
">=",
... | Converts a number of bytes to a shorter, more human friendly format | [
"Converts",
"a",
"number",
"of",
"bytes",
"to",
"a",
"shorter",
"more",
"human",
"friendly",
"format"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L50-L62 |
225,716 | sosreport/sos | sos/utilities.py | grep | def grep(pattern, *files_or_paths):
"""Returns lines matched in fnames, where fnames can either be pathnames to
files to grep through or open file objects to grep through line by line"""
matches = []
for fop in files_or_paths:
with fileobj(fop) as fo:
matches.extend((line for line i... | python | def grep(pattern, *files_or_paths):
"""Returns lines matched in fnames, where fnames can either be pathnames to
files to grep through or open file objects to grep through line by line"""
matches = []
for fop in files_or_paths:
with fileobj(fop) as fo:
matches.extend((line for line i... | [
"def",
"grep",
"(",
"pattern",
",",
"*",
"files_or_paths",
")",
":",
"matches",
"=",
"[",
"]",
"for",
"fop",
"in",
"files_or_paths",
":",
"with",
"fileobj",
"(",
"fop",
")",
"as",
"fo",
":",
"matches",
".",
"extend",
"(",
"(",
"line",
"for",
"line",
... | Returns lines matched in fnames, where fnames can either be pathnames to
files to grep through or open file objects to grep through line by line | [
"Returns",
"lines",
"matched",
"in",
"fnames",
"where",
"fnames",
"can",
"either",
"be",
"pathnames",
"to",
"files",
"to",
"grep",
"through",
"or",
"open",
"file",
"objects",
"to",
"grep",
"through",
"line",
"by",
"line"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L87-L96 |
225,717 | sosreport/sos | sos/utilities.py | is_executable | def is_executable(command):
"""Returns if a command matches an executable on the PATH"""
paths = os.environ.get("PATH", "").split(os.path.pathsep)
candidates = [command] + [os.path.join(p, command) for p in paths]
return any(os.access(path, os.X_OK) for path in candidates) | python | def is_executable(command):
"""Returns if a command matches an executable on the PATH"""
paths = os.environ.get("PATH", "").split(os.path.pathsep)
candidates = [command] + [os.path.join(p, command) for p in paths]
return any(os.access(path, os.X_OK) for path in candidates) | [
"def",
"is_executable",
"(",
"command",
")",
":",
"paths",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"PATH\"",
",",
"\"\"",
")",
".",
"split",
"(",
"os",
".",
"path",
".",
"pathsep",
")",
"candidates",
"=",
"[",
"command",
"]",
"+",
"[",
"os",
... | Returns if a command matches an executable on the PATH | [
"Returns",
"if",
"a",
"command",
"matches",
"an",
"executable",
"on",
"the",
"PATH"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L99-L104 |
225,718 | sosreport/sos | sos/utilities.py | sos_get_command_output | def sos_get_command_output(command, timeout=300, stderr=False,
chroot=None, chdir=None, env=None,
binary=False, sizelimit=None, poller=None):
"""Execute a command and return a dictionary of status and output,
optionally changing root or current working direc... | python | def sos_get_command_output(command, timeout=300, stderr=False,
chroot=None, chdir=None, env=None,
binary=False, sizelimit=None, poller=None):
"""Execute a command and return a dictionary of status and output,
optionally changing root or current working direc... | [
"def",
"sos_get_command_output",
"(",
"command",
",",
"timeout",
"=",
"300",
",",
"stderr",
"=",
"False",
",",
"chroot",
"=",
"None",
",",
"chdir",
"=",
"None",
",",
"env",
"=",
"None",
",",
"binary",
"=",
"False",
",",
"sizelimit",
"=",
"None",
",",
... | Execute a command and return a dictionary of status and output,
optionally changing root or current working directory before
executing command. | [
"Execute",
"a",
"command",
"and",
"return",
"a",
"dictionary",
"of",
"status",
"and",
"output",
"optionally",
"changing",
"root",
"or",
"current",
"working",
"directory",
"before",
"executing",
"command",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L107-L177 |
225,719 | sosreport/sos | sos/utilities.py | import_module | def import_module(module_fqname, superclasses=None):
"""Imports the module module_fqname and returns a list of defined classes
from that module. If superclasses is defined then the classes returned will
be subclasses of the specified superclass or superclasses. If superclasses
is plural it must be a tup... | python | def import_module(module_fqname, superclasses=None):
"""Imports the module module_fqname and returns a list of defined classes
from that module. If superclasses is defined then the classes returned will
be subclasses of the specified superclass or superclasses. If superclasses
is plural it must be a tup... | [
"def",
"import_module",
"(",
"module_fqname",
",",
"superclasses",
"=",
"None",
")",
":",
"module_name",
"=",
"module_fqname",
".",
"rpartition",
"(",
"\".\"",
")",
"[",
"-",
"1",
"]",
"module",
"=",
"__import__",
"(",
"module_fqname",
",",
"globals",
"(",
... | Imports the module module_fqname and returns a list of defined classes
from that module. If superclasses is defined then the classes returned will
be subclasses of the specified superclass or superclasses. If superclasses
is plural it must be a tuple of classes. | [
"Imports",
"the",
"module",
"module_fqname",
"and",
"returns",
"a",
"list",
"of",
"defined",
"classes",
"from",
"that",
"module",
".",
"If",
"superclasses",
"is",
"defined",
"then",
"the",
"classes",
"returned",
"will",
"be",
"subclasses",
"of",
"the",
"specif... | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L180-L193 |
225,720 | sosreport/sos | sos/utilities.py | shell_out | def shell_out(cmd, timeout=30, chroot=None, runat=None):
"""Shell out to an external command and return the output or the empty
string in case of error.
"""
return sos_get_command_output(cmd, timeout=timeout,
chroot=chroot, chdir=runat)['output'] | python | def shell_out(cmd, timeout=30, chroot=None, runat=None):
"""Shell out to an external command and return the output or the empty
string in case of error.
"""
return sos_get_command_output(cmd, timeout=timeout,
chroot=chroot, chdir=runat)['output'] | [
"def",
"shell_out",
"(",
"cmd",
",",
"timeout",
"=",
"30",
",",
"chroot",
"=",
"None",
",",
"runat",
"=",
"None",
")",
":",
"return",
"sos_get_command_output",
"(",
"cmd",
",",
"timeout",
"=",
"timeout",
",",
"chroot",
"=",
"chroot",
",",
"chdir",
"=",... | Shell out to an external command and return the output or the empty
string in case of error. | [
"Shell",
"out",
"to",
"an",
"external",
"command",
"and",
"return",
"the",
"output",
"or",
"the",
"empty",
"string",
"in",
"case",
"of",
"error",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L196-L201 |
225,721 | sosreport/sos | sos/utilities.py | AsyncReader.get_contents | def get_contents(self):
'''Returns the contents of the deque as a string'''
# block until command completes or timesout (separate from the plugin
# hitting a timeout)
while self.running:
pass
if not self.binary:
return ''.join(ln.decode('utf-8', 'ignore') ... | python | def get_contents(self):
'''Returns the contents of the deque as a string'''
# block until command completes or timesout (separate from the plugin
# hitting a timeout)
while self.running:
pass
if not self.binary:
return ''.join(ln.decode('utf-8', 'ignore') ... | [
"def",
"get_contents",
"(",
"self",
")",
":",
"# block until command completes or timesout (separate from the plugin",
"# hitting a timeout)",
"while",
"self",
".",
"running",
":",
"pass",
"if",
"not",
"self",
".",
"binary",
":",
"return",
"''",
".",
"join",
"(",
"l... | Returns the contents of the deque as a string | [
"Returns",
"the",
"contents",
"of",
"the",
"deque",
"as",
"a",
"string"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L246-L255 |
225,722 | sosreport/sos | sos/utilities.py | ImporterHelper._plugin_name | def _plugin_name(self, path):
"Returns the plugin module name given the path"
base = os.path.basename(path)
name, ext = os.path.splitext(base)
return name | python | def _plugin_name(self, path):
"Returns the plugin module name given the path"
base = os.path.basename(path)
name, ext = os.path.splitext(base)
return name | [
"def",
"_plugin_name",
"(",
"self",
",",
"path",
")",
":",
"base",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"base",
")",
"return",
"name"
] | Returns the plugin module name given the path | [
"Returns",
"the",
"plugin",
"module",
"name",
"given",
"the",
"path"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L270-L274 |
225,723 | sosreport/sos | sos/utilities.py | ImporterHelper.get_modules | def get_modules(self):
"""Returns the list of importable modules in the configured python
package. """
plugins = []
for path in self.package.__path__:
if os.path.isdir(path):
plugins.extend(self._find_plugins_in_dir(path))
return plugins | python | def get_modules(self):
"""Returns the list of importable modules in the configured python
package. """
plugins = []
for path in self.package.__path__:
if os.path.isdir(path):
plugins.extend(self._find_plugins_in_dir(path))
return plugins | [
"def",
"get_modules",
"(",
"self",
")",
":",
"plugins",
"=",
"[",
"]",
"for",
"path",
"in",
"self",
".",
"package",
".",
"__path__",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
":",
"plugins",
".",
"extend",
"(",
"self",
".",
"_... | Returns the list of importable modules in the configured python
package. | [
"Returns",
"the",
"list",
"of",
"importable",
"modules",
"in",
"the",
"configured",
"python",
"package",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/utilities.py#L292-L300 |
225,724 | sosreport/sos | sos/policies/redhat.py | RedHatPolicy.check_usrmove | def check_usrmove(self, pkgs):
"""Test whether the running system implements UsrMove.
If the 'filesystem' package is present, it will check that the
version is greater than 3. If the package is not present the
'/bin' and '/sbin' paths are checked and UsrMove is assumed
... | python | def check_usrmove(self, pkgs):
"""Test whether the running system implements UsrMove.
If the 'filesystem' package is present, it will check that the
version is greater than 3. If the package is not present the
'/bin' and '/sbin' paths are checked and UsrMove is assumed
... | [
"def",
"check_usrmove",
"(",
"self",
",",
"pkgs",
")",
":",
"if",
"'filesystem'",
"not",
"in",
"pkgs",
":",
"return",
"os",
".",
"path",
".",
"islink",
"(",
"'/bin'",
")",
"and",
"os",
".",
"path",
".",
"islink",
"(",
"'/sbin'",
")",
"else",
":",
"... | Test whether the running system implements UsrMove.
If the 'filesystem' package is present, it will check that the
version is greater than 3. If the package is not present the
'/bin' and '/sbin' paths are checked and UsrMove is assumed
if both are symbolic links.
... | [
"Test",
"whether",
"the",
"running",
"system",
"implements",
"UsrMove",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/redhat.py#L100-L114 |
225,725 | sosreport/sos | sos/policies/redhat.py | RedHatPolicy.mangle_package_path | def mangle_package_path(self, files):
"""Mangle paths for post-UsrMove systems.
If the system implements UsrMove, all files will be in
'/usr/[s]bin'. This method substitutes all the /[s]bin
references in the 'files' list with '/usr/[s]bin'.
:param files: the lis... | python | def mangle_package_path(self, files):
"""Mangle paths for post-UsrMove systems.
If the system implements UsrMove, all files will be in
'/usr/[s]bin'. This method substitutes all the /[s]bin
references in the 'files' list with '/usr/[s]bin'.
:param files: the lis... | [
"def",
"mangle_package_path",
"(",
"self",
",",
"files",
")",
":",
"paths",
"=",
"[",
"]",
"def",
"transform_path",
"(",
"path",
")",
":",
"# Some packages actually own paths in /bin: in this case,",
"# duplicate the path as both the / and /usr version.",
"skip_paths",
"=",... | Mangle paths for post-UsrMove systems.
If the system implements UsrMove, all files will be in
'/usr/[s]bin'. This method substitutes all the /[s]bin
references in the 'files' list with '/usr/[s]bin'.
:param files: the list of package managed files | [
"Mangle",
"paths",
"for",
"post",
"-",
"UsrMove",
"systems",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/redhat.py#L116-L140 |
225,726 | sosreport/sos | sos/policies/redhat.py | RedHatPolicy._container_init | def _container_init(self):
"""Check if sos is running in a container and perform container
specific initialisation based on ENV_HOST_SYSROOT.
"""
if ENV_CONTAINER in os.environ:
if os.environ[ENV_CONTAINER] in ['docker', 'oci']:
self._in_container = True
... | python | def _container_init(self):
"""Check if sos is running in a container and perform container
specific initialisation based on ENV_HOST_SYSROOT.
"""
if ENV_CONTAINER in os.environ:
if os.environ[ENV_CONTAINER] in ['docker', 'oci']:
self._in_container = True
... | [
"def",
"_container_init",
"(",
"self",
")",
":",
"if",
"ENV_CONTAINER",
"in",
"os",
".",
"environ",
":",
"if",
"os",
".",
"environ",
"[",
"ENV_CONTAINER",
"]",
"in",
"[",
"'docker'",
",",
"'oci'",
"]",
":",
"self",
".",
"_in_container",
"=",
"True",
"i... | Check if sos is running in a container and perform container
specific initialisation based on ENV_HOST_SYSROOT. | [
"Check",
"if",
"sos",
"is",
"running",
"in",
"a",
"container",
"and",
"perform",
"container",
"specific",
"initialisation",
"based",
"on",
"ENV_HOST_SYSROOT",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/redhat.py#L142-L155 |
225,727 | sosreport/sos | sos/policies/redhat.py | RHELPolicy.check | def check(cls):
"""Test to see if the running host is a RHEL installation.
Checks for the presence of the "Red Hat Enterprise Linux"
release string at the beginning of the NAME field in the
`/etc/os-release` file and returns ``True`` if it is
found, and ``False``... | python | def check(cls):
"""Test to see if the running host is a RHEL installation.
Checks for the presence of the "Red Hat Enterprise Linux"
release string at the beginning of the NAME field in the
`/etc/os-release` file and returns ``True`` if it is
found, and ``False``... | [
"def",
"check",
"(",
"cls",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"OS_RELEASE",
")",
":",
"return",
"False",
"with",
"open",
"(",
"OS_RELEASE",
",",
"\"r\"",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"line"... | Test to see if the running host is a RHEL installation.
Checks for the presence of the "Red Hat Enterprise Linux"
release string at the beginning of the NAME field in the
`/etc/os-release` file and returns ``True`` if it is
found, and ``False`` otherwise.
:r... | [
"Test",
"to",
"see",
"if",
"the",
"running",
"host",
"is",
"a",
"RHEL",
"installation",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/policies/redhat.py#L274-L295 |
225,728 | sosreport/sos | sos/plugins/lustre.py | Lustre.get_params | def get_params(self, name, param_list):
'''Use lctl get_param to collect a selection of parameters into a
file.
'''
self.add_cmd_output("lctl get_param %s" % " ".join(param_list),
suggest_filename="params-%s" % name,
stderr=Fal... | python | def get_params(self, name, param_list):
'''Use lctl get_param to collect a selection of parameters into a
file.
'''
self.add_cmd_output("lctl get_param %s" % " ".join(param_list),
suggest_filename="params-%s" % name,
stderr=Fal... | [
"def",
"get_params",
"(",
"self",
",",
"name",
",",
"param_list",
")",
":",
"self",
".",
"add_cmd_output",
"(",
"\"lctl get_param %s\"",
"%",
"\" \"",
".",
"join",
"(",
"param_list",
")",
",",
"suggest_filename",
"=",
"\"params-%s\"",
"%",
"name",
",",
"stde... | Use lctl get_param to collect a selection of parameters into a
file. | [
"Use",
"lctl",
"get_param",
"to",
"collect",
"a",
"selection",
"of",
"parameters",
"into",
"a",
"file",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/lustre.py#L19-L26 |
225,729 | sosreport/sos | sos/plugins/qpid_dispatch.py | QpidDispatch.setup | def setup(self):
""" performs data collection for qpid dispatch router """
options = ""
if self.get_option("port"):
options = (options + " -b " + gethostname() +
":%s" % (self.get_option("port")))
# gethostname() is due to DISPATCH-156
# for ei... | python | def setup(self):
""" performs data collection for qpid dispatch router """
options = ""
if self.get_option("port"):
options = (options + " -b " + gethostname() +
":%s" % (self.get_option("port")))
# gethostname() is due to DISPATCH-156
# for ei... | [
"def",
"setup",
"(",
"self",
")",
":",
"options",
"=",
"\"\"",
"if",
"self",
".",
"get_option",
"(",
"\"port\"",
")",
":",
"options",
"=",
"(",
"options",
"+",
"\" -b \"",
"+",
"gethostname",
"(",
")",
"+",
"\":%s\"",
"%",
"(",
"self",
".",
"get_opti... | performs data collection for qpid dispatch router | [
"performs",
"data",
"collection",
"for",
"qpid",
"dispatch",
"router"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/qpid_dispatch.py#L30-L53 |
225,730 | sosreport/sos | sos/plugins/__init__.py | SoSPredicate.__str | def __str(self, quote=False, prefix="", suffix=""):
"""Return a string representation of this SoSPredicate with
optional prefix, suffix and value quoting.
"""
quotes = '"%s"'
pstr = "dry_run=%s, " % self._dry_run
kmods = self._kmods
kmods = [quotes % k for k ... | python | def __str(self, quote=False, prefix="", suffix=""):
"""Return a string representation of this SoSPredicate with
optional prefix, suffix and value quoting.
"""
quotes = '"%s"'
pstr = "dry_run=%s, " % self._dry_run
kmods = self._kmods
kmods = [quotes % k for k ... | [
"def",
"__str",
"(",
"self",
",",
"quote",
"=",
"False",
",",
"prefix",
"=",
"\"\"",
",",
"suffix",
"=",
"\"\"",
")",
":",
"quotes",
"=",
"'\"%s\"'",
"pstr",
"=",
"\"dry_run=%s, \"",
"%",
"self",
".",
"_dry_run",
"kmods",
"=",
"self",
".",
"_kmods",
... | Return a string representation of this SoSPredicate with
optional prefix, suffix and value quoting. | [
"Return",
"a",
"string",
"representation",
"of",
"this",
"SoSPredicate",
"with",
"optional",
"prefix",
"suffix",
"and",
"value",
"quoting",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L117-L132 |
225,731 | sosreport/sos | sos/plugins/__init__.py | Plugin.do_file_sub | def do_file_sub(self, srcpath, regexp, subst):
'''Apply a regexp substitution to a file archived by sosreport.
srcpath is the path in the archive where the file can be found. regexp
can be a regexp string or a compiled re object. subst is a string to
replace each occurance of regexp in... | python | def do_file_sub(self, srcpath, regexp, subst):
'''Apply a regexp substitution to a file archived by sosreport.
srcpath is the path in the archive where the file can be found. regexp
can be a regexp string or a compiled re object. subst is a string to
replace each occurance of regexp in... | [
"def",
"do_file_sub",
"(",
"self",
",",
"srcpath",
",",
"regexp",
",",
"subst",
")",
":",
"try",
":",
"path",
"=",
"self",
".",
"_get_dest_for_srcpath",
"(",
"srcpath",
")",
"self",
".",
"_log_debug",
"(",
"\"substituting scrpath '%s'\"",
"%",
"srcpath",
")"... | Apply a regexp substitution to a file archived by sosreport.
srcpath is the path in the archive where the file can be found. regexp
can be a regexp string or a compiled re object. subst is a string to
replace each occurance of regexp in the content of srcpath.
This function returns th... | [
"Apply",
"a",
"regexp",
"substitution",
"to",
"a",
"file",
"archived",
"by",
"sosreport",
".",
"srcpath",
"is",
"the",
"path",
"in",
"the",
"archive",
"where",
"the",
"file",
"can",
"be",
"found",
".",
"regexp",
"can",
"be",
"a",
"regexp",
"string",
"or"... | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L482-L516 |
225,732 | sosreport/sos | sos/plugins/__init__.py | Plugin.do_path_regex_sub | def do_path_regex_sub(self, pathexp, regexp, subst):
'''Apply a regexp substituation to a set of files archived by
sos. The set of files to be substituted is generated by matching
collected file pathnames against pathexp which may be a regular
expression string or compiled re object. The... | python | def do_path_regex_sub(self, pathexp, regexp, subst):
'''Apply a regexp substituation to a set of files archived by
sos. The set of files to be substituted is generated by matching
collected file pathnames against pathexp which may be a regular
expression string or compiled re object. The... | [
"def",
"do_path_regex_sub",
"(",
"self",
",",
"pathexp",
",",
"regexp",
",",
"subst",
")",
":",
"if",
"not",
"hasattr",
"(",
"pathexp",
",",
"\"match\"",
")",
":",
"pathexp",
"=",
"re",
".",
"compile",
"(",
"pathexp",
")",
"match",
"=",
"pathexp",
".",... | Apply a regexp substituation to a set of files archived by
sos. The set of files to be substituted is generated by matching
collected file pathnames against pathexp which may be a regular
expression string or compiled re object. The portion of the file
to be replaced is specified via reg... | [
"Apply",
"a",
"regexp",
"substituation",
"to",
"a",
"set",
"of",
"files",
"archived",
"by",
"sos",
".",
"The",
"set",
"of",
"files",
"to",
"be",
"substituted",
"is",
"generated",
"by",
"matching",
"collected",
"file",
"pathnames",
"against",
"pathexp",
"whic... | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L518-L530 |
225,733 | sosreport/sos | sos/plugins/__init__.py | Plugin._do_copy_path | def _do_copy_path(self, srcpath, dest=None):
'''Copy file or directory to the destination tree. If a directory, then
everything below it is recursively copied. A list of copied files are
saved for use later in preparing a report.
'''
if self._is_forbidden_path(srcpath):
... | python | def _do_copy_path(self, srcpath, dest=None):
'''Copy file or directory to the destination tree. If a directory, then
everything below it is recursively copied. A list of copied files are
saved for use later in preparing a report.
'''
if self._is_forbidden_path(srcpath):
... | [
"def",
"_do_copy_path",
"(",
"self",
",",
"srcpath",
",",
"dest",
"=",
"None",
")",
":",
"if",
"self",
".",
"_is_forbidden_path",
"(",
"srcpath",
")",
":",
"self",
".",
"_log_debug",
"(",
"\"skipping forbidden path '%s'\"",
"%",
"srcpath",
")",
"return",
"''... | Copy file or directory to the destination tree. If a directory, then
everything below it is recursively copied. A list of copied files are
saved for use later in preparing a report. | [
"Copy",
"file",
"or",
"directory",
"to",
"the",
"destination",
"tree",
".",
"If",
"a",
"directory",
"then",
"everything",
"below",
"it",
"is",
"recursively",
"copied",
".",
"A",
"list",
"of",
"copied",
"files",
"are",
"saved",
"for",
"use",
"later",
"in",
... | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L627-L678 |
225,734 | sosreport/sos | sos/plugins/__init__.py | Plugin.set_option | def set_option(self, optionname, value):
"""Set the named option to value. Ensure the original type
of the option value is preserved.
"""
for name, parms in zip(self.opt_names, self.opt_parms):
if name == optionname:
# FIXME: ensure that the resulting type ... | python | def set_option(self, optionname, value):
"""Set the named option to value. Ensure the original type
of the option value is preserved.
"""
for name, parms in zip(self.opt_names, self.opt_parms):
if name == optionname:
# FIXME: ensure that the resulting type ... | [
"def",
"set_option",
"(",
"self",
",",
"optionname",
",",
"value",
")",
":",
"for",
"name",
",",
"parms",
"in",
"zip",
"(",
"self",
".",
"opt_names",
",",
"self",
".",
"opt_parms",
")",
":",
"if",
"name",
"==",
"optionname",
":",
"# FIXME: ensure that th... | Set the named option to value. Ensure the original type
of the option value is preserved. | [
"Set",
"the",
"named",
"option",
"to",
"value",
".",
"Ensure",
"the",
"original",
"type",
"of",
"the",
"option",
"value",
"is",
"preserved",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L699-L716 |
225,735 | sosreport/sos | sos/plugins/__init__.py | Plugin.get_option | def get_option(self, optionname, default=0):
"""Returns the first value that matches 'optionname' in parameters
passed in via the command line or set via set_option or via the
global_plugin_options dictionary, in that order.
optionaname may be iterable, in which case the first option th... | python | def get_option(self, optionname, default=0):
"""Returns the first value that matches 'optionname' in parameters
passed in via the command line or set via set_option or via the
global_plugin_options dictionary, in that order.
optionaname may be iterable, in which case the first option th... | [
"def",
"get_option",
"(",
"self",
",",
"optionname",
",",
"default",
"=",
"0",
")",
":",
"global_options",
"=",
"(",
"'verify'",
",",
"'all_logs'",
",",
"'log_size'",
",",
"'plugin_timeout'",
")",
"if",
"optionname",
"in",
"global_options",
":",
"return",
"g... | Returns the first value that matches 'optionname' in parameters
passed in via the command line or set via set_option or via the
global_plugin_options dictionary, in that order.
optionaname may be iterable, in which case the first option that
matches any of the option names is returned. | [
"Returns",
"the",
"first",
"value",
"that",
"matches",
"optionname",
"in",
"parameters",
"passed",
"in",
"via",
"the",
"command",
"line",
"or",
"set",
"via",
"set_option",
"or",
"via",
"the",
"global_plugin_options",
"dictionary",
"in",
"that",
"order",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L718-L738 |
225,736 | sosreport/sos | sos/plugins/__init__.py | Plugin.get_option_as_list | def get_option_as_list(self, optionname, delimiter=",", default=None):
'''Will try to return the option as a list separated by the
delimiter.
'''
option = self.get_option(optionname)
try:
opt_list = [opt.strip() for opt in option.split(delimiter)]
return l... | python | def get_option_as_list(self, optionname, delimiter=",", default=None):
'''Will try to return the option as a list separated by the
delimiter.
'''
option = self.get_option(optionname)
try:
opt_list = [opt.strip() for opt in option.split(delimiter)]
return l... | [
"def",
"get_option_as_list",
"(",
"self",
",",
"optionname",
",",
"delimiter",
"=",
"\",\"",
",",
"default",
"=",
"None",
")",
":",
"option",
"=",
"self",
".",
"get_option",
"(",
"optionname",
")",
"try",
":",
"opt_list",
"=",
"[",
"opt",
".",
"strip",
... | Will try to return the option as a list separated by the
delimiter. | [
"Will",
"try",
"to",
"return",
"the",
"option",
"as",
"a",
"list",
"separated",
"by",
"the",
"delimiter",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L740-L749 |
225,737 | sosreport/sos | sos/plugins/__init__.py | Plugin.add_copy_spec | def add_copy_spec(self, copyspecs, sizelimit=None, tailit=True, pred=None):
"""Add a file or glob but limit it to sizelimit megabytes. If fname is
a single file the file will be tailed to meet sizelimit. If the first
file in a glob is too large it will be tailed to meet the sizelimit.
""... | python | def add_copy_spec(self, copyspecs, sizelimit=None, tailit=True, pred=None):
"""Add a file or glob but limit it to sizelimit megabytes. If fname is
a single file the file will be tailed to meet sizelimit. If the first
file in a glob is too large it will be tailed to meet the sizelimit.
""... | [
"def",
"add_copy_spec",
"(",
"self",
",",
"copyspecs",
",",
"sizelimit",
"=",
"None",
",",
"tailit",
"=",
"True",
",",
"pred",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"test_predicate",
"(",
"pred",
"=",
"pred",
")",
":",
"self",
".",
"_log_i... | Add a file or glob but limit it to sizelimit megabytes. If fname is
a single file the file will be tailed to meet sizelimit. If the first
file in a glob is too large it will be tailed to meet the sizelimit. | [
"Add",
"a",
"file",
"or",
"glob",
"but",
"limit",
"it",
"to",
"sizelimit",
"megabytes",
".",
"If",
"fname",
"is",
"a",
"single",
"file",
"the",
"file",
"will",
"be",
"tailed",
"to",
"meet",
"sizelimit",
".",
"If",
"the",
"first",
"file",
"in",
"a",
"... | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L754-L827 |
225,738 | sosreport/sos | sos/plugins/__init__.py | Plugin.call_ext_prog | def call_ext_prog(self, prog, timeout=300, stderr=True,
chroot=True, runat=None):
"""Execute a command independantly of the output gathering part of
sosreport.
"""
return self.get_command_output(prog, timeout=timeout, stderr=stderr,
... | python | def call_ext_prog(self, prog, timeout=300, stderr=True,
chroot=True, runat=None):
"""Execute a command independantly of the output gathering part of
sosreport.
"""
return self.get_command_output(prog, timeout=timeout, stderr=stderr,
... | [
"def",
"call_ext_prog",
"(",
"self",
",",
"prog",
",",
"timeout",
"=",
"300",
",",
"stderr",
"=",
"True",
",",
"chroot",
"=",
"True",
",",
"runat",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_command_output",
"(",
"prog",
",",
"timeout",
"=",
... | Execute a command independantly of the output gathering part of
sosreport. | [
"Execute",
"a",
"command",
"independantly",
"of",
"the",
"output",
"gathering",
"part",
"of",
"sosreport",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L862-L868 |
225,739 | sosreport/sos | sos/plugins/__init__.py | Plugin._add_cmd_output | def _add_cmd_output(self, cmd, suggest_filename=None,
root_symlink=None, timeout=300, stderr=True,
chroot=True, runat=None, env=None, binary=False,
sizelimit=None, pred=None):
"""Internal helper to add a single command to the collection lis... | python | def _add_cmd_output(self, cmd, suggest_filename=None,
root_symlink=None, timeout=300, stderr=True,
chroot=True, runat=None, env=None, binary=False,
sizelimit=None, pred=None):
"""Internal helper to add a single command to the collection lis... | [
"def",
"_add_cmd_output",
"(",
"self",
",",
"cmd",
",",
"suggest_filename",
"=",
"None",
",",
"root_symlink",
"=",
"None",
",",
"timeout",
"=",
"300",
",",
"stderr",
"=",
"True",
",",
"chroot",
"=",
"True",
",",
"runat",
"=",
"None",
",",
"env",
"=",
... | Internal helper to add a single command to the collection list. | [
"Internal",
"helper",
"to",
"add",
"a",
"single",
"command",
"to",
"the",
"collection",
"list",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L877-L896 |
225,740 | sosreport/sos | sos/plugins/__init__.py | Plugin.add_cmd_output | def add_cmd_output(self, cmds, suggest_filename=None,
root_symlink=None, timeout=300, stderr=True,
chroot=True, runat=None, env=None, binary=False,
sizelimit=None, pred=None):
"""Run a program or a list of programs and collect the output"""
... | python | def add_cmd_output(self, cmds, suggest_filename=None,
root_symlink=None, timeout=300, stderr=True,
chroot=True, runat=None, env=None, binary=False,
sizelimit=None, pred=None):
"""Run a program or a list of programs and collect the output"""
... | [
"def",
"add_cmd_output",
"(",
"self",
",",
"cmds",
",",
"suggest_filename",
"=",
"None",
",",
"root_symlink",
"=",
"None",
",",
"timeout",
"=",
"300",
",",
"stderr",
"=",
"True",
",",
"chroot",
"=",
"True",
",",
"runat",
"=",
"None",
",",
"env",
"=",
... | Run a program or a list of programs and collect the output | [
"Run",
"a",
"program",
"or",
"a",
"list",
"of",
"programs",
"and",
"collect",
"the",
"output"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L898-L914 |
225,741 | sosreport/sos | sos/plugins/__init__.py | Plugin.get_cmd_output_path | def get_cmd_output_path(self, name=None, make=True):
"""Return a path into which this module should store collected
command output
"""
cmd_output_path = os.path.join(self.archive.get_tmp_dir(),
'sos_commands', self.name())
if name:
... | python | def get_cmd_output_path(self, name=None, make=True):
"""Return a path into which this module should store collected
command output
"""
cmd_output_path = os.path.join(self.archive.get_tmp_dir(),
'sos_commands', self.name())
if name:
... | [
"def",
"get_cmd_output_path",
"(",
"self",
",",
"name",
"=",
"None",
",",
"make",
"=",
"True",
")",
":",
"cmd_output_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"archive",
".",
"get_tmp_dir",
"(",
")",
",",
"'sos_commands'",
",",
"sel... | Return a path into which this module should store collected
command output | [
"Return",
"a",
"path",
"into",
"which",
"this",
"module",
"should",
"store",
"collected",
"command",
"output"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L916-L927 |
225,742 | sosreport/sos | sos/plugins/__init__.py | Plugin._make_command_filename | def _make_command_filename(self, exe):
"""The internal function to build up a filename based on a command."""
outfn = os.path.join(self.commons['cmddir'], self.name(),
self._mangle_command(exe))
# check for collisions
if os.path.exists(outfn):
i... | python | def _make_command_filename(self, exe):
"""The internal function to build up a filename based on a command."""
outfn = os.path.join(self.commons['cmddir'], self.name(),
self._mangle_command(exe))
# check for collisions
if os.path.exists(outfn):
i... | [
"def",
"_make_command_filename",
"(",
"self",
",",
"exe",
")",
":",
"outfn",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"commons",
"[",
"'cmddir'",
"]",
",",
"self",
".",
"name",
"(",
")",
",",
"self",
".",
"_mangle_command",
"(",
"exe",
... | The internal function to build up a filename based on a command. | [
"The",
"internal",
"function",
"to",
"build",
"up",
"a",
"filename",
"based",
"on",
"a",
"command",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L940-L956 |
225,743 | sosreport/sos | sos/plugins/__init__.py | Plugin.add_string_as_file | def add_string_as_file(self, content, filename, pred=None):
"""Add a string to the archive as a file named `filename`"""
# Generate summary string for logging
summary = content.splitlines()[0] if content else ''
if not isinstance(summary, six.string_types):
summary = content... | python | def add_string_as_file(self, content, filename, pred=None):
"""Add a string to the archive as a file named `filename`"""
# Generate summary string for logging
summary = content.splitlines()[0] if content else ''
if not isinstance(summary, six.string_types):
summary = content... | [
"def",
"add_string_as_file",
"(",
"self",
",",
"content",
",",
"filename",
",",
"pred",
"=",
"None",
")",
":",
"# Generate summary string for logging",
"summary",
"=",
"content",
".",
"splitlines",
"(",
")",
"[",
"0",
"]",
"if",
"content",
"else",
"''",
"if"... | Add a string to the archive as a file named `filename` | [
"Add",
"a",
"string",
"to",
"the",
"archive",
"as",
"a",
"file",
"named",
"filename"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L958-L972 |
225,744 | sosreport/sos | sos/plugins/__init__.py | Plugin.add_journal | def add_journal(self, units=None, boot=None, since=None, until=None,
lines=None, allfields=False, output=None, timeout=None,
identifier=None, catalog=None, sizelimit=None, pred=None):
"""Collect journald logs from one of more units.
:param units: A string, or lis... | python | def add_journal(self, units=None, boot=None, since=None, until=None,
lines=None, allfields=False, output=None, timeout=None,
identifier=None, catalog=None, sizelimit=None, pred=None):
"""Collect journald logs from one of more units.
:param units: A string, or lis... | [
"def",
"add_journal",
"(",
"self",
",",
"units",
"=",
"None",
",",
"boot",
"=",
"None",
",",
"since",
"=",
"None",
",",
"until",
"=",
"None",
",",
"lines",
"=",
"None",
",",
"allfields",
"=",
"False",
",",
"output",
"=",
"None",
",",
"timeout",
"="... | Collect journald logs from one of more units.
:param units: A string, or list of strings specifying the
systemd units for which journal entries will be
collected.
:param boot: A string selecting a boot index using the
journalctl synta... | [
"Collect",
"journald",
"logs",
"from",
"one",
"of",
"more",
"units",
"."
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1046-L1133 |
225,745 | sosreport/sos | sos/plugins/__init__.py | Plugin.add_udev_info | def add_udev_info(self, device, attrs=False):
"""Collect udevadm info output for a given device
:param device: A string or list of strings of device names or sysfs
paths. E.G. either '/sys/class/scsi_host/host0' or
'/dev/sda' is valid.
:param attrs:... | python | def add_udev_info(self, device, attrs=False):
"""Collect udevadm info output for a given device
:param device: A string or list of strings of device names or sysfs
paths. E.G. either '/sys/class/scsi_host/host0' or
'/dev/sda' is valid.
:param attrs:... | [
"def",
"add_udev_info",
"(",
"self",
",",
"device",
",",
"attrs",
"=",
"False",
")",
":",
"udev_cmd",
"=",
"'udevadm info'",
"if",
"attrs",
":",
"udev_cmd",
"+=",
"' -a'",
"if",
"isinstance",
"(",
"device",
",",
"six",
".",
"string_types",
")",
":",
"dev... | Collect udevadm info output for a given device
:param device: A string or list of strings of device names or sysfs
paths. E.G. either '/sys/class/scsi_host/host0' or
'/dev/sda' is valid.
:param attrs: If True, run udevadm with the --attribute-walk option. | [
"Collect",
"udevadm",
"info",
"output",
"for",
"a",
"given",
"device"
] | 2ebc04da53dc871c8dd5243567afa4f8592dca29 | https://github.com/sosreport/sos/blob/2ebc04da53dc871c8dd5243567afa4f8592dca29/sos/plugins/__init__.py#L1135-L1152 |
225,746 | 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 |
225,747 | 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 |
225,748 | 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 |
225,749 | 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 |
225,750 | 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 |
225,751 | 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 |
225,752 | 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 |
225,753 | 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 |
225,754 | 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 |
225,755 | 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 |
225,756 | 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 |
225,757 | 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 |
225,758 | 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 |
225,759 | 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 |
225,760 | 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 |
225,761 | 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 |
225,762 | 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 |
225,763 | 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 |
225,764 | 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 |
225,765 | 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 |
225,766 | 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 |
225,767 | 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 |
225,768 | 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 |
225,769 | 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 |
225,770 | 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 |
225,771 | 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 |
225,772 | 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 |
225,773 | 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 |
225,774 | 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 |
225,775 | 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 |
225,776 | 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 |
225,777 | 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 |
225,778 | 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 |
225,779 | 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 |
225,780 | 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 |
225,781 | 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 |
225,782 | 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 |
225,783 | 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 |
225,784 | 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 |
225,785 | 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 |
225,786 | 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 |
225,787 | 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 |
225,788 | 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 |
225,789 | 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 |
225,790 | 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 |
225,791 | 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 |
225,792 | 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 |
225,793 | 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 |
225,794 | 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 |
225,795 | 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 |
225,796 | 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 |
225,797 | 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 |
225,798 | 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 |
225,799 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.