Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
TarInfo._proc_gnusparse_00 | (self, next, pax_headers, buf) | Process a GNU tar extended sparse header, version 0.0.
| Process a GNU tar extended sparse header, version 0.0.
| def _proc_gnusparse_00(self, next, pax_headers, buf):
"""Process a GNU tar extended sparse header, version 0.0.
"""
offsets = []
for match in re.finditer(br"\d+ GNU.sparse.offset=(\d+)\n", buf):
offsets.append(int(match.group(1)))
numbytes = []
for match in re... | [
"def",
"_proc_gnusparse_00",
"(",
"self",
",",
"next",
",",
"pax_headers",
",",
"buf",
")",
":",
"offsets",
"=",
"[",
"]",
"for",
"match",
"in",
"re",
".",
"finditer",
"(",
"br\"\\d+ GNU.sparse.offset=(\\d+)\\n\"",
",",
"buf",
")",
":",
"offsets",
".",
"ap... | [
1484,
4
] | [
1493,
50
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._proc_gnusparse_01 | (self, next, pax_headers) | Process a GNU tar extended sparse header, version 0.1.
| Process a GNU tar extended sparse header, version 0.1.
| def _proc_gnusparse_01(self, next, pax_headers):
"""Process a GNU tar extended sparse header, version 0.1.
"""
sparse = [int(x) for x in pax_headers["GNU.sparse.map"].split(",")]
next.sparse = list(zip(sparse[::2], sparse[1::2])) | [
"def",
"_proc_gnusparse_01",
"(",
"self",
",",
"next",
",",
"pax_headers",
")",
":",
"sparse",
"=",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"pax_headers",
"[",
"\"GNU.sparse.map\"",
"]",
".",
"split",
"(",
"\",\"",
")",
"]",
"next",
".",
"sparse",... | [
1495,
4
] | [
1499,
58
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._proc_gnusparse_10 | (self, next, pax_headers, tarfile) | Process a GNU tar extended sparse header, version 1.0.
| Process a GNU tar extended sparse header, version 1.0.
| def _proc_gnusparse_10(self, next, pax_headers, tarfile):
"""Process a GNU tar extended sparse header, version 1.0.
"""
fields = None
sparse = []
buf = tarfile.fileobj.read(BLOCKSIZE)
fields, buf = buf.split(b"\n", 1)
fields = int(fields)
while len(sparse)... | [
"def",
"_proc_gnusparse_10",
"(",
"self",
",",
"next",
",",
"pax_headers",
",",
"tarfile",
")",
":",
"fields",
"=",
"None",
"sparse",
"=",
"[",
"]",
"buf",
"=",
"tarfile",
".",
"fileobj",
".",
"read",
"(",
"BLOCKSIZE",
")",
"fields",
",",
"buf",
"=",
... | [
1501,
4
] | [
1515,
58
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._apply_pax_info | (self, pax_headers, encoding, errors) | Replace fields with supplemental information from a previous
pax extended or global header.
| Replace fields with supplemental information from a previous
pax extended or global header.
| def _apply_pax_info(self, pax_headers, encoding, errors):
"""Replace fields with supplemental information from a previous
pax extended or global header.
"""
for keyword, value in pax_headers.items():
if keyword == "GNU.sparse.name":
setattr(self, "path", va... | [
"def",
"_apply_pax_info",
"(",
"self",
",",
"pax_headers",
",",
"encoding",
",",
"errors",
")",
":",
"for",
"keyword",
",",
"value",
"in",
"pax_headers",
".",
"items",
"(",
")",
":",
"if",
"keyword",
"==",
"\"GNU.sparse.name\"",
":",
"setattr",
"(",
"self"... | [
1517,
4
] | [
1538,
45
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._decode_pax_field | (self, value, encoding, fallback_encoding, fallback_errors) | Decode a single field from a pax record.
| Decode a single field from a pax record.
| def _decode_pax_field(self, value, encoding, fallback_encoding, fallback_errors):
"""Decode a single field from a pax record.
"""
try:
return value.decode(encoding, "strict")
except UnicodeDecodeError:
return value.decode(fallback_encoding, fallback_errors) | [
"def",
"_decode_pax_field",
"(",
"self",
",",
"value",
",",
"encoding",
",",
"fallback_encoding",
",",
"fallback_errors",
")",
":",
"try",
":",
"return",
"value",
".",
"decode",
"(",
"encoding",
",",
"\"strict\"",
")",
"except",
"UnicodeDecodeError",
":",
"ret... | [
1540,
4
] | [
1546,
67
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._block | (self, count) | Round up a byte count by BLOCKSIZE and return it,
e.g. _block(834) => 1024.
| Round up a byte count by BLOCKSIZE and return it,
e.g. _block(834) => 1024.
| def _block(self, count):
"""Round up a byte count by BLOCKSIZE and return it,
e.g. _block(834) => 1024.
"""
blocks, remainder = divmod(count, BLOCKSIZE)
if remainder:
blocks += 1
return blocks * BLOCKSIZE | [
"def",
"_block",
"(",
"self",
",",
"count",
")",
":",
"blocks",
",",
"remainder",
"=",
"divmod",
"(",
"count",
",",
"BLOCKSIZE",
")",
"if",
"remainder",
":",
"blocks",
"+=",
"1",
"return",
"blocks",
"*",
"BLOCKSIZE"
] | [
1548,
4
] | [
1555,
33
] | python | en | ['en', 'en', 'en'] | True |
TarFile.__init__ | (self, name=None, mode="r", fileobj=None, format=None,
tarinfo=None, dereference=None, ignore_zeros=None, encoding=None,
errors="surrogateescape", pax_headers=None, debug=None, errorlevel=None) | Open an (uncompressed) tar archive `name'. `mode' is either 'r' to
read from an existing archive, 'a' to append data to an existing
file or 'w' to create a new file overwriting an existing one. `mode'
defaults to 'r'.
If `fileobj' is given, it is used for reading or writing d... | Open an (uncompressed) tar archive `name'. `mode' is either 'r' to
read from an existing archive, 'a' to append data to an existing
file or 'w' to create a new file overwriting an existing one. `mode'
defaults to 'r'.
If `fileobj' is given, it is used for reading or writing d... | def __init__(self, name=None, mode="r", fileobj=None, format=None,
tarinfo=None, dereference=None, ignore_zeros=None, encoding=None,
errors="surrogateescape", pax_headers=None, debug=None, errorlevel=None):
"""Open an (uncompressed) tar archive `name'. `mode' is either 'r' to
... | [
"def",
"__init__",
"(",
"self",
",",
"name",
"=",
"None",
",",
"mode",
"=",
"\"r\"",
",",
"fileobj",
"=",
"None",
",",
"format",
"=",
"None",
",",
"tarinfo",
"=",
"None",
",",
"dereference",
"=",
"None",
",",
"ignore_zeros",
"=",
"None",
",",
"encodi... | [
1605,
4
] | [
1699,
17
] | python | en | ['en', 'en', 'en'] | True |
TarFile.open | (cls, name=None, mode="r", fileobj=None, bufsize=RECORDSIZE, **kwargs) | Open a tar archive for reading, writing or appending. Return
an appropriate TarFile class.
mode:
'r' or 'r:*' open for reading with transparent compression
'r:' open for reading exclusively uncompressed
'r:gz' open for reading with gzip compression
... | Open a tar archive for reading, writing or appending. Return
an appropriate TarFile class. | def open(cls, name=None, mode="r", fileobj=None, bufsize=RECORDSIZE, **kwargs):
"""Open a tar archive for reading, writing or appending. Return
an appropriate TarFile class.
mode:
'r' or 'r:*' open for reading with transparent compression
'r:' open for readin... | [
"def",
"open",
"(",
"cls",
",",
"name",
"=",
"None",
",",
"mode",
"=",
"\"r\"",
",",
"fileobj",
"=",
"None",
",",
"bufsize",
"=",
"RECORDSIZE",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"name",
"and",
"not",
"fileobj",
":",
"raise",
"ValueErr... | [
1713,
4
] | [
1786,
46
] | python | en | ['en', 'en', 'en'] | True |
TarFile.taropen | (cls, name, mode="r", fileobj=None, **kwargs) | Open uncompressed tar archive name for reading or writing.
| Open uncompressed tar archive name for reading or writing.
| def taropen(cls, name, mode="r", fileobj=None, **kwargs):
"""Open uncompressed tar archive name for reading or writing.
"""
if len(mode) > 1 or mode not in "raw":
raise ValueError("mode must be 'r', 'a' or 'w'")
return cls(name, mode, fileobj, **kwargs) | [
"def",
"taropen",
"(",
"cls",
",",
"name",
",",
"mode",
"=",
"\"r\"",
",",
"fileobj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"mode",
")",
">",
"1",
"or",
"mode",
"not",
"in",
"\"raw\"",
":",
"raise",
"ValueError",
"(",
... | [
1789,
4
] | [
1794,
49
] | python | en | ['en', 'en', 'en'] | True |
TarFile.gzopen | (cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs) | Open gzip compressed tar archive name for reading or writing.
Appending is not allowed.
| Open gzip compressed tar archive name for reading or writing.
Appending is not allowed.
| def gzopen(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs):
"""Open gzip compressed tar archive name for reading or writing.
Appending is not allowed.
"""
if len(mode) > 1 or mode not in "rw":
raise ValueError("mode must be 'r' or 'w'")
try:
... | [
"def",
"gzopen",
"(",
"cls",
",",
"name",
",",
"mode",
"=",
"\"r\"",
",",
"fileobj",
"=",
"None",
",",
"compresslevel",
"=",
"9",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"mode",
")",
">",
"1",
"or",
"mode",
"not",
"in",
"\"rw\"",
"... | [
1797,
4
] | [
1825,
16
] | python | en | ['en', 'en', 'en'] | True |
TarFile.bz2open | (cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs) | Open bzip2 compressed tar archive name for reading or writing.
Appending is not allowed.
| Open bzip2 compressed tar archive name for reading or writing.
Appending is not allowed.
| def bz2open(cls, name, mode="r", fileobj=None, compresslevel=9, **kwargs):
"""Open bzip2 compressed tar archive name for reading or writing.
Appending is not allowed.
"""
if len(mode) > 1 or mode not in "rw":
raise ValueError("mode must be 'r' or 'w'.")
try:
... | [
"def",
"bz2open",
"(",
"cls",
",",
"name",
",",
"mode",
"=",
"\"r\"",
",",
"fileobj",
"=",
"None",
",",
"compresslevel",
"=",
"9",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"mode",
")",
">",
"1",
"or",
"mode",
"not",
"in",
"\"rw\"",
... | [
1828,
4
] | [
1851,
16
] | python | en | ['en', 'en', 'en'] | True |
TarFile.close | (self) | Close the TarFile. In write-mode, two finishing zero blocks are
appended to the archive.
| Close the TarFile. In write-mode, two finishing zero blocks are
appended to the archive.
| def close(self):
"""Close the TarFile. In write-mode, two finishing zero blocks are
appended to the archive.
"""
if self.closed:
return
if self.mode in "aw":
self.fileobj.write(NUL * (BLOCKSIZE * 2))
self.offset += (BLOCKSIZE * 2)
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"closed",
":",
"return",
"if",
"self",
".",
"mode",
"in",
"\"aw\"",
":",
"self",
".",
"fileobj",
".",
"write",
"(",
"NUL",
"*",
"(",
"BLOCKSIZE",
"*",
"2",
")",
")",
"self",
".",
"offset",... | [
1863,
4
] | [
1881,
26
] | python | en | ['en', 'it', 'en'] | True |
TarFile.getmember | (self, name) | Return a TarInfo object for member `name'. If `name' can not be
found in the archive, KeyError is raised. If a member occurs more
than once in the archive, its last occurrence is assumed to be the
most up-to-date version.
| Return a TarInfo object for member `name'. If `name' can not be
found in the archive, KeyError is raised. If a member occurs more
than once in the archive, its last occurrence is assumed to be the
most up-to-date version.
| def getmember(self, name):
"""Return a TarInfo object for member `name'. If `name' can not be
found in the archive, KeyError is raised. If a member occurs more
than once in the archive, its last occurrence is assumed to be the
most up-to-date version.
"""
tarinfo... | [
"def",
"getmember",
"(",
"self",
",",
"name",
")",
":",
"tarinfo",
"=",
"self",
".",
"_getmember",
"(",
"name",
")",
"if",
"tarinfo",
"is",
"None",
":",
"raise",
"KeyError",
"(",
"\"filename %r not found\"",
"%",
"name",
")",
"return",
"tarinfo"
] | [
1883,
4
] | [
1892,
22
] | python | en | ['en', 'en', 'en'] | True |
TarFile.getmembers | (self) | Return the members of the archive as a list of TarInfo objects. The
list has the same order as the members in the archive.
| Return the members of the archive as a list of TarInfo objects. The
list has the same order as the members in the archive.
| def getmembers(self):
"""Return the members of the archive as a list of TarInfo objects. The
list has the same order as the members in the archive.
"""
self._check()
if not self._loaded: # if we want to obtain a list of
self._load() # all members, we firs... | [
"def",
"getmembers",
"(",
"self",
")",
":",
"self",
".",
"_check",
"(",
")",
"if",
"not",
"self",
".",
"_loaded",
":",
"# if we want to obtain a list of",
"self",
".",
"_load",
"(",
")",
"# all members, we first have to",
"# scan the whole archive.",
"return",
"se... | [
1894,
4
] | [
1902,
27
] | python | en | ['en', 'en', 'en'] | True |
TarFile.getnames | (self) | Return the members of the archive as a list of their names. It has
the same order as the list returned by getmembers().
| Return the members of the archive as a list of their names. It has
the same order as the list returned by getmembers().
| def getnames(self):
"""Return the members of the archive as a list of their names. It has
the same order as the list returned by getmembers().
"""
return [tarinfo.name for tarinfo in self.getmembers()] | [
"def",
"getnames",
"(",
"self",
")",
":",
"return",
"[",
"tarinfo",
".",
"name",
"for",
"tarinfo",
"in",
"self",
".",
"getmembers",
"(",
")",
"]"
] | [
1904,
4
] | [
1908,
62
] | python | en | ['en', 'en', 'en'] | True |
TarFile.gettarinfo | (self, name=None, arcname=None, fileobj=None) | Create a TarInfo object for either the file `name' or the file
object `fileobj' (using os.fstat on its file descriptor). You can
modify some of the TarInfo's attributes before you add it using
addfile(). If given, `arcname' specifies an alternative name for the
file in the ar... | Create a TarInfo object for either the file `name' or the file
object `fileobj' (using os.fstat on its file descriptor). You can
modify some of the TarInfo's attributes before you add it using
addfile(). If given, `arcname' specifies an alternative name for the
file in the ar... | def gettarinfo(self, name=None, arcname=None, fileobj=None):
"""Create a TarInfo object for either the file `name' or the file
object `fileobj' (using os.fstat on its file descriptor). You can
modify some of the TarInfo's attributes before you add it using
addfile(). If given, `... | [
"def",
"gettarinfo",
"(",
"self",
",",
"name",
"=",
"None",
",",
"arcname",
"=",
"None",
",",
"fileobj",
"=",
"None",
")",
":",
"self",
".",
"_check",
"(",
"\"aw\"",
")",
"# When fileobj is given, replace name by",
"# fileobj's real name.",
"if",
"fileobj",
"i... | [
1910,
4
] | [
2006,
22
] | python | en | ['en', 'en', 'en'] | True |
TarFile.list | (self, verbose=True) | Print a table of contents to sys.stdout. If `verbose' is False, only
the names of the members are printed. If it is True, an `ls -l'-like
output is produced.
| Print a table of contents to sys.stdout. If `verbose' is False, only
the names of the members are printed. If it is True, an `ls -l'-like
output is produced.
| def list(self, verbose=True):
"""Print a table of contents to sys.stdout. If `verbose' is False, only
the names of the members are printed. If it is True, an `ls -l'-like
output is produced.
"""
self._check()
for tarinfo in self:
if verbose:
... | [
"def",
"list",
"(",
"self",
",",
"verbose",
"=",
"True",
")",
":",
"self",
".",
"_check",
"(",
")",
"for",
"tarinfo",
"in",
"self",
":",
"if",
"verbose",
":",
"print",
"(",
"filemode",
"(",
"tarinfo",
".",
"mode",
")",
",",
"end",
"=",
"' '",
")"... | [
2008,
4
] | [
2035,
19
] | python | en | ['en', 'en', 'en'] | True |
TarFile.add | (self, name, arcname=None, recursive=True, exclude=None, filter=None) | Add the file `name' to the archive. `name' may be any type of file
(directory, fifo, symbolic link, etc.). If given, `arcname'
specifies an alternative name for the file in the archive.
Directories are added recursively by default. This can be avoided by
setting `recursive' t... | Add the file `name' to the archive. `name' may be any type of file
(directory, fifo, symbolic link, etc.). If given, `arcname'
specifies an alternative name for the file in the archive.
Directories are added recursively by default. This can be avoided by
setting `recursive' t... | def add(self, name, arcname=None, recursive=True, exclude=None, filter=None):
"""Add the file `name' to the archive. `name' may be any type of file
(directory, fifo, symbolic link, etc.). If given, `arcname'
specifies an alternative name for the file in the archive.
Directories ... | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"arcname",
"=",
"None",
",",
"recursive",
"=",
"True",
",",
"exclude",
"=",
"None",
",",
"filter",
"=",
"None",
")",
":",
"self",
".",
"_check",
"(",
"\"aw\"",
")",
"if",
"arcname",
"is",
"None",
":",
... | [
2037,
4
] | [
2097,
33
] | python | en | ['en', 'en', 'en'] | True |
TarFile.addfile | (self, tarinfo, fileobj=None) | Add the TarInfo object `tarinfo' to the archive. If `fileobj' is
given, tarinfo.size bytes are read from it and added to the archive.
You can create TarInfo objects using gettarinfo().
On Windows platforms, `fileobj' should always be opened with mode
'rb' to avoid irritation ... | Add the TarInfo object `tarinfo' to the archive. If `fileobj' is
given, tarinfo.size bytes are read from it and added to the archive.
You can create TarInfo objects using gettarinfo().
On Windows platforms, `fileobj' should always be opened with mode
'rb' to avoid irritation ... | def addfile(self, tarinfo, fileobj=None):
"""Add the TarInfo object `tarinfo' to the archive. If `fileobj' is
given, tarinfo.size bytes are read from it and added to the archive.
You can create TarInfo objects using gettarinfo().
On Windows platforms, `fileobj' should always be ... | [
"def",
"addfile",
"(",
"self",
",",
"tarinfo",
",",
"fileobj",
"=",
"None",
")",
":",
"self",
".",
"_check",
"(",
"\"aw\"",
")",
"tarinfo",
"=",
"copy",
".",
"copy",
"(",
"tarinfo",
")",
"buf",
"=",
"tarinfo",
".",
"tobuf",
"(",
"self",
".",
"forma... | [
2099,
4
] | [
2123,
36
] | python | en | ['en', 'en', 'en'] | True |
TarFile.extractall | (self, path=".", members=None) | Extract all members from the archive to the current working
directory and set owner, modification time and permissions on
directories afterwards. `path' specifies a different directory
to extract to. `members' is optional and must be a subset of the
list returned by getmember... | Extract all members from the archive to the current working
directory and set owner, modification time and permissions on
directories afterwards. `path' specifies a different directory
to extract to. `members' is optional and must be a subset of the
list returned by getmember... | def extractall(self, path=".", members=None):
"""Extract all members from the archive to the current working
directory and set owner, modification time and permissions on
directories afterwards. `path' specifies a different directory
to extract to. `members' is optional and must... | [
"def",
"extractall",
"(",
"self",
",",
"path",
"=",
"\".\"",
",",
"members",
"=",
"None",
")",
":",
"directories",
"=",
"[",
"]",
"if",
"members",
"is",
"None",
":",
"members",
"=",
"self",
"for",
"tarinfo",
"in",
"members",
":",
"if",
"tarinfo",
"."... | [
2125,
4
] | [
2161,
51
] | python | en | ['en', 'en', 'en'] | True |
TarFile.extract | (self, member, path="", set_attrs=True) | Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
as possible. `member' may be a filename or a TarInfo object. You can
specify a different directory using `path'. File attributes (owner,
mt... | Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
as possible. `member' may be a filename or a TarInfo object. You can
specify a different directory using `path'. File attributes (owner,
mt... | def extract(self, member, path="", set_attrs=True):
"""Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
as possible. `member' may be a filename or a TarInfo object. You can
specify a differen... | [
"def",
"extract",
"(",
"self",
",",
"member",
",",
"path",
"=",
"\"\"",
",",
"set_attrs",
"=",
"True",
")",
":",
"self",
".",
"_check",
"(",
"\"r\"",
")",
"if",
"isinstance",
"(",
"member",
",",
"str",
")",
":",
"tarinfo",
"=",
"self",
".",
"getmem... | [
2163,
4
] | [
2196,
47
] | python | en | ['en', 'en', 'en'] | True |
TarFile.extractfile | (self, member) | Extract a member from the archive as a file object. `member' may be
a filename or a TarInfo object. If `member' is a regular file, a
file-like object is returned. If `member' is a link, a file-like
object is constructed from the link's target. If `member' is none of
the above... | Extract a member from the archive as a file object. `member' may be
a filename or a TarInfo object. If `member' is a regular file, a
file-like object is returned. If `member' is a link, a file-like
object is constructed from the link's target. If `member' is none of
the above... | def extractfile(self, member):
"""Extract a member from the archive as a file object. `member' may be
a filename or a TarInfo object. If `member' is a regular file, a
file-like object is returned. If `member' is a link, a file-like
object is constructed from the link's target. I... | [
"def",
"extractfile",
"(",
"self",
",",
"member",
")",
":",
"self",
".",
"_check",
"(",
"\"r\"",
")",
"if",
"isinstance",
"(",
"member",
",",
"str",
")",
":",
"tarinfo",
"=",
"self",
".",
"getmember",
"(",
"member",
")",
"else",
":",
"tarinfo",
"=",
... | [
2198,
4
] | [
2234,
23
] | python | en | ['en', 'en', 'en'] | True |
TarFile._extract_member | (self, tarinfo, targetpath, set_attrs=True) | Extract the TarInfo object tarinfo to a physical
file called targetpath.
| Extract the TarInfo object tarinfo to a physical
file called targetpath.
| def _extract_member(self, tarinfo, targetpath, set_attrs=True):
"""Extract the TarInfo object tarinfo to a physical
file called targetpath.
"""
# Fetch the TarInfo object for the given name
# and build the destination pathname, replacing
# forward slashes to platform s... | [
"def",
"_extract_member",
"(",
"self",
",",
"tarinfo",
",",
"targetpath",
",",
"set_attrs",
"=",
"True",
")",
":",
"# Fetch the TarInfo object for the given name",
"# and build the destination pathname, replacing",
"# forward slashes to platform specific separators.",
"targetpath",... | [
2236,
4
] | [
2277,
47
] | python | en | ['en', 'en', 'en'] | True |
TarFile.makedir | (self, tarinfo, targetpath) | Make a directory called targetpath.
| Make a directory called targetpath.
| def makedir(self, tarinfo, targetpath):
"""Make a directory called targetpath.
"""
try:
# Use a safe mode for the directory, the real mode is set
# later in _extract_member().
os.mkdir(targetpath, 0o700)
except EnvironmentError as e:
if e.e... | [
"def",
"makedir",
"(",
"self",
",",
"tarinfo",
",",
"targetpath",
")",
":",
"try",
":",
"# Use a safe mode for the directory, the real mode is set",
"# later in _extract_member().",
"os",
".",
"mkdir",
"(",
"targetpath",
",",
"0o700",
")",
"except",
"EnvironmentError",
... | [
2284,
4
] | [
2293,
21
] | python | en | ['en', 'en', 'en'] | True |
TarFile.makefile | (self, tarinfo, targetpath) | Make a file called targetpath.
| Make a file called targetpath.
| def makefile(self, tarinfo, targetpath):
"""Make a file called targetpath.
"""
source = self.fileobj
source.seek(tarinfo.offset_data)
target = bltn_open(targetpath, "wb")
if tarinfo.sparse is not None:
for offset, size in tarinfo.sparse:
target... | [
"def",
"makefile",
"(",
"self",
",",
"tarinfo",
",",
"targetpath",
")",
":",
"source",
"=",
"self",
".",
"fileobj",
"source",
".",
"seek",
"(",
"tarinfo",
".",
"offset_data",
")",
"target",
"=",
"bltn_open",
"(",
"targetpath",
",",
"\"wb\"",
")",
"if",
... | [
2295,
4
] | [
2309,
22
] | python | en | ['en', 'ig', 'en'] | True |
TarFile.makeunknown | (self, tarinfo, targetpath) | Make a file from a TarInfo object with an unknown type
at targetpath.
| Make a file from a TarInfo object with an unknown type
at targetpath.
| def makeunknown(self, tarinfo, targetpath):
"""Make a file from a TarInfo object with an unknown type
at targetpath.
"""
self.makefile(tarinfo, targetpath)
self._dbg(1, "tarfile: Unknown file type %r, " \
"extracted as regular file." % tarinfo.type) | [
"def",
"makeunknown",
"(",
"self",
",",
"tarinfo",
",",
"targetpath",
")",
":",
"self",
".",
"makefile",
"(",
"tarinfo",
",",
"targetpath",
")",
"self",
".",
"_dbg",
"(",
"1",
",",
"\"tarfile: Unknown file type %r, \"",
"\"extracted as regular file.\"",
"%",
"ta... | [
2311,
4
] | [
2317,
65
] | python | en | ['en', 'en', 'en'] | True |
TarFile.makefifo | (self, tarinfo, targetpath) | Make a fifo called targetpath.
| Make a fifo called targetpath.
| def makefifo(self, tarinfo, targetpath):
"""Make a fifo called targetpath.
"""
if hasattr(os, "mkfifo"):
os.mkfifo(targetpath)
else:
raise ExtractError("fifo not supported by system") | [
"def",
"makefifo",
"(",
"self",
",",
"tarinfo",
",",
"targetpath",
")",
":",
"if",
"hasattr",
"(",
"os",
",",
"\"mkfifo\"",
")",
":",
"os",
".",
"mkfifo",
"(",
"targetpath",
")",
"else",
":",
"raise",
"ExtractError",
"(",
"\"fifo not supported by system\"",
... | [
2319,
4
] | [
2325,
62
] | python | en | ['en', 'ig', 'en'] | True |
TarFile.makedev | (self, tarinfo, targetpath) | Make a character or block device called targetpath.
| Make a character or block device called targetpath.
| def makedev(self, tarinfo, targetpath):
"""Make a character or block device called targetpath.
"""
if not hasattr(os, "mknod") or not hasattr(os, "makedev"):
raise ExtractError("special devices not supported by system")
mode = tarinfo.mode
if tarinfo.isblk():
... | [
"def",
"makedev",
"(",
"self",
",",
"tarinfo",
",",
"targetpath",
")",
":",
"if",
"not",
"hasattr",
"(",
"os",
",",
"\"mknod\"",
")",
"or",
"not",
"hasattr",
"(",
"os",
",",
"\"makedev\"",
")",
":",
"raise",
"ExtractError",
"(",
"\"special devices not supp... | [
2327,
4
] | [
2340,
64
] | python | en | ['en', 'en', 'en'] | True |
TarFile.makelink | (self, tarinfo, targetpath) | Make a (symbolic) link called targetpath. If it cannot be created
(platform limitation), we try to make a copy of the referenced file
instead of a link.
| Make a (symbolic) link called targetpath. If it cannot be created
(platform limitation), we try to make a copy of the referenced file
instead of a link.
| def makelink(self, tarinfo, targetpath):
"""Make a (symbolic) link called targetpath. If it cannot be created
(platform limitation), we try to make a copy of the referenced file
instead of a link.
"""
try:
# For systems that support symbolic and hard links.
... | [
"def",
"makelink",
"(",
"self",
",",
"tarinfo",
",",
"targetpath",
")",
":",
"try",
":",
"# For systems that support symbolic and hard links.",
"if",
"tarinfo",
".",
"issym",
"(",
")",
":",
"os",
".",
"symlink",
"(",
"tarinfo",
".",
"linkname",
",",
"targetpat... | [
2342,
4
] | [
2369,
75
] | python | en | ['en', 'en', 'en'] | True |
TarFile.chown | (self, tarinfo, targetpath) | Set owner of targetpath according to tarinfo.
| Set owner of targetpath according to tarinfo.
| def chown(self, tarinfo, targetpath):
"""Set owner of targetpath according to tarinfo.
"""
if pwd and hasattr(os, "geteuid") and os.geteuid() == 0:
# We have to be root to do so.
try:
g = grp.getgrnam(tarinfo.gname)[2]
except KeyError:
... | [
"def",
"chown",
"(",
"self",
",",
"tarinfo",
",",
"targetpath",
")",
":",
"if",
"pwd",
"and",
"hasattr",
"(",
"os",
",",
"\"geteuid\"",
")",
"and",
"os",
".",
"geteuid",
"(",
")",
"==",
"0",
":",
"# We have to be root to do so.",
"try",
":",
"g",
"=",
... | [
2371,
4
] | [
2391,
60
] | python | en | ['en', 'en', 'en'] | True |
TarFile.chmod | (self, tarinfo, targetpath) | Set file permissions of targetpath according to tarinfo.
| Set file permissions of targetpath according to tarinfo.
| def chmod(self, tarinfo, targetpath):
"""Set file permissions of targetpath according to tarinfo.
"""
if hasattr(os, 'chmod'):
try:
os.chmod(targetpath, tarinfo.mode)
except EnvironmentError as e:
raise ExtractError("could not change mode") | [
"def",
"chmod",
"(",
"self",
",",
"tarinfo",
",",
"targetpath",
")",
":",
"if",
"hasattr",
"(",
"os",
",",
"'chmod'",
")",
":",
"try",
":",
"os",
".",
"chmod",
"(",
"targetpath",
",",
"tarinfo",
".",
"mode",
")",
"except",
"EnvironmentError",
"as",
"... | [
2393,
4
] | [
2400,
59
] | python | en | ['en', 'en', 'en'] | True |
TarFile.utime | (self, tarinfo, targetpath) | Set modification time of targetpath according to tarinfo.
| Set modification time of targetpath according to tarinfo.
| def utime(self, tarinfo, targetpath):
"""Set modification time of targetpath according to tarinfo.
"""
if not hasattr(os, 'utime'):
return
try:
os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime))
except EnvironmentError as e:
raise ExtractErro... | [
"def",
"utime",
"(",
"self",
",",
"tarinfo",
",",
"targetpath",
")",
":",
"if",
"not",
"hasattr",
"(",
"os",
",",
"'utime'",
")",
":",
"return",
"try",
":",
"os",
".",
"utime",
"(",
"targetpath",
",",
"(",
"tarinfo",
".",
"mtime",
",",
"tarinfo",
"... | [
2402,
4
] | [
2410,
68
] | python | en | ['en', 'en', 'en'] | True |
TarFile.next | (self) | Return the next member of the archive as a TarInfo object, when
TarFile is opened for reading. Return None if there is no more
available.
| Return the next member of the archive as a TarInfo object, when
TarFile is opened for reading. Return None if there is no more
available.
| def next(self):
"""Return the next member of the archive as a TarInfo object, when
TarFile is opened for reading. Return None if there is no more
available.
"""
self._check("ra")
if self.firstmember is not None:
m = self.firstmember
self.firs... | [
"def",
"next",
"(",
"self",
")",
":",
"self",
".",
"_check",
"(",
"\"ra\"",
")",
"if",
"self",
".",
"firstmember",
"is",
"not",
"None",
":",
"m",
"=",
"self",
".",
"firstmember",
"self",
".",
"firstmember",
"=",
"None",
"return",
"m",
"# Read the next ... | [
2413,
4
] | [
2457,
22
] | python | en | ['en', 'en', 'en'] | True |
TarFile._getmember | (self, name, tarinfo=None, normalize=False) | Find an archive member by name from bottom to top.
If tarinfo is given, it is used as the starting point.
| Find an archive member by name from bottom to top.
If tarinfo is given, it is used as the starting point.
| def _getmember(self, name, tarinfo=None, normalize=False):
"""Find an archive member by name from bottom to top.
If tarinfo is given, it is used as the starting point.
"""
# Ensure that all members have been loaded.
members = self.getmembers()
# Limit the member searc... | [
"def",
"_getmember",
"(",
"self",
",",
"name",
",",
"tarinfo",
"=",
"None",
",",
"normalize",
"=",
"False",
")",
":",
"# Ensure that all members have been loaded.",
"members",
"=",
"self",
".",
"getmembers",
"(",
")",
"# Limit the member search list up to tarinfo.",
... | [
2462,
4
] | [
2483,
29
] | python | en | ['en', 'en', 'en'] | True |
TarFile._load | (self) | Read through the entire archive file and look for readable
members.
| Read through the entire archive file and look for readable
members.
| def _load(self):
"""Read through the entire archive file and look for readable
members.
"""
while True:
tarinfo = self.next()
if tarinfo is None:
break
self._loaded = True | [
"def",
"_load",
"(",
"self",
")",
":",
"while",
"True",
":",
"tarinfo",
"=",
"self",
".",
"next",
"(",
")",
"if",
"tarinfo",
"is",
"None",
":",
"break",
"self",
".",
"_loaded",
"=",
"True"
] | [
2485,
4
] | [
2493,
27
] | python | en | ['en', 'en', 'en'] | True |
TarFile._check | (self, mode=None) | Check if TarFile is still open, and if the operation's mode
corresponds to TarFile's mode.
| Check if TarFile is still open, and if the operation's mode
corresponds to TarFile's mode.
| def _check(self, mode=None):
"""Check if TarFile is still open, and if the operation's mode
corresponds to TarFile's mode.
"""
if self.closed:
raise IOError("%s is closed" % self.__class__.__name__)
if mode is not None and self.mode not in mode:
raise I... | [
"def",
"_check",
"(",
"self",
",",
"mode",
"=",
"None",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"IOError",
"(",
"\"%s is closed\"",
"%",
"self",
".",
"__class__",
".",
"__name__",
")",
"if",
"mode",
"is",
"not",
"None",
"and",
"self",
".... | [
2495,
4
] | [
2502,
66
] | python | en | ['en', 'en', 'en'] | True |
TarFile._find_link_target | (self, tarinfo) | Find the target member of a symlink or hardlink member in the
archive.
| Find the target member of a symlink or hardlink member in the
archive.
| def _find_link_target(self, tarinfo):
"""Find the target member of a symlink or hardlink member in the
archive.
"""
if tarinfo.issym():
# Always search the entire archive.
linkname = os.path.dirname(tarinfo.name) + "/" + tarinfo.linkname
limit = Non... | [
"def",
"_find_link_target",
"(",
"self",
",",
"tarinfo",
")",
":",
"if",
"tarinfo",
".",
"issym",
"(",
")",
":",
"# Always search the entire archive.",
"linkname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"tarinfo",
".",
"name",
")",
"+",
"\"/\"",
"+",... | [
2504,
4
] | [
2521,
21
] | python | en | ['en', 'da', 'en'] | True |
TarFile.__iter__ | (self) | Provide an iterator object.
| Provide an iterator object.
| def __iter__(self):
"""Provide an iterator object.
"""
if self._loaded:
return iter(self.members)
else:
return TarIter(self) | [
"def",
"__iter__",
"(",
"self",
")",
":",
"if",
"self",
".",
"_loaded",
":",
"return",
"iter",
"(",
"self",
".",
"members",
")",
"else",
":",
"return",
"TarIter",
"(",
"self",
")"
] | [
2523,
4
] | [
2529,
32
] | python | en | ['en', 'en', 'en'] | True |
TarFile._dbg | (self, level, msg) | Write debugging output to sys.stderr.
| Write debugging output to sys.stderr.
| def _dbg(self, level, msg):
"""Write debugging output to sys.stderr.
"""
if level <= self.debug:
print(msg, file=sys.stderr) | [
"def",
"_dbg",
"(",
"self",
",",
"level",
",",
"msg",
")",
":",
"if",
"level",
"<=",
"self",
".",
"debug",
":",
"print",
"(",
"msg",
",",
"file",
"=",
"sys",
".",
"stderr",
")"
] | [
2531,
4
] | [
2535,
39
] | python | en | ['it', 'en', 'nl'] | False |
TarIter.__init__ | (self, tarfile) | Construct a TarIter object.
| Construct a TarIter object.
| def __init__(self, tarfile):
"""Construct a TarIter object.
"""
self.tarfile = tarfile
self.index = 0 | [
"def",
"__init__",
"(",
"self",
",",
"tarfile",
")",
":",
"self",
".",
"tarfile",
"=",
"tarfile",
"self",
".",
"index",
"=",
"0"
] | [
2559,
4
] | [
2563,
22
] | python | en | ['en', 'en', 'en'] | True |
TarIter.__iter__ | (self) | Return iterator object.
| Return iterator object.
| def __iter__(self):
"""Return iterator object.
"""
return self | [
"def",
"__iter__",
"(",
"self",
")",
":",
"return",
"self"
] | [
2564,
4
] | [
2567,
19
] | python | en | ['en', 'mt', 'en'] | True |
TarIter.__next__ | (self) | Return the next item using TarFile's next() method.
When all members have been read, set TarFile as _loaded.
| Return the next item using TarFile's next() method.
When all members have been read, set TarFile as _loaded.
| def __next__(self):
"""Return the next item using TarFile's next() method.
When all members have been read, set TarFile as _loaded.
"""
# Fix for SF #1100429: Under rare circumstances it can
# happen that getmembers() is called during iteration,
# which will cause TarI... | [
"def",
"__next__",
"(",
"self",
")",
":",
"# Fix for SF #1100429: Under rare circumstances it can",
"# happen that getmembers() is called during iteration,",
"# which will cause TarIter to stop prematurely.",
"if",
"not",
"self",
".",
"tarfile",
".",
"_loaded",
":",
"tarinfo",
"=... | [
2569,
4
] | [
2587,
22
] | python | en | ['en', 'lt', 'en'] | True |
pack | (o, stream, **kwargs) |
Pack object `o` and write it to `stream`
See :class:`Packer` for options.
|
Pack object `o` and write it to `stream` | def pack(o, stream, **kwargs):
"""
Pack object `o` and write it to `stream`
See :class:`Packer` for options.
"""
packer = Packer(**kwargs)
stream.write(packer.pack(o)) | [
"def",
"pack",
"(",
"o",
",",
"stream",
",",
"*",
"*",
"kwargs",
")",
":",
"packer",
"=",
"Packer",
"(",
"*",
"*",
"kwargs",
")",
"stream",
".",
"write",
"(",
"packer",
".",
"pack",
"(",
"o",
")",
")"
] | [
18,
0
] | [
25,
32
] | python | en | ['en', 'error', 'th'] | False |
packb | (o, **kwargs) |
Pack object `o` and return packed bytes
See :class:`Packer` for options.
|
Pack object `o` and return packed bytes | def packb(o, **kwargs):
"""
Pack object `o` and return packed bytes
See :class:`Packer` for options.
"""
return Packer(**kwargs).pack(o) | [
"def",
"packb",
"(",
"o",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Packer",
"(",
"*",
"*",
"kwargs",
")",
".",
"pack",
"(",
"o",
")"
] | [
28,
0
] | [
34,
35
] | python | en | ['en', 'error', 'th'] | False |
unpack | (stream, **kwargs) |
Unpack an object from `stream`.
Raises `ExtraData` when `stream` contains extra bytes.
See :class:`Unpacker` for options.
|
Unpack an object from `stream`. | def unpack(stream, **kwargs):
"""
Unpack an object from `stream`.
Raises `ExtraData` when `stream` contains extra bytes.
See :class:`Unpacker` for options.
"""
data = stream.read()
return unpackb(data, **kwargs) | [
"def",
"unpack",
"(",
"stream",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"stream",
".",
"read",
"(",
")",
"return",
"unpackb",
"(",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
37,
0
] | [
45,
34
] | python | en | ['en', 'error', 'th'] | False |
cli | (ctx, input, organism_id, analysis_id, query_type="polypeptide", match_on_name=False, name_column=2, go_column=5, re_name="", skip_missing=False) | Load GO annotation from a tabular file
Output:
Number of inserted GO terms
| Load GO annotation from a tabular file | def cli(ctx, input, organism_id, analysis_id, query_type="polypeptide", match_on_name=False, name_column=2, go_column=5, re_name="", skip_missing=False):
"""Load GO annotation from a tabular file
Output:
Number of inserted GO terms
"""
return ctx.gi.feature.load_go(input, organism_id, analysis_id, que... | [
"def",
"cli",
"(",
"ctx",
",",
"input",
",",
"organism_id",
",",
"analysis_id",
",",
"query_type",
"=",
"\"polypeptide\"",
",",
"match_on_name",
"=",
"False",
",",
"name_column",
"=",
"2",
",",
"go_column",
"=",
"5",
",",
"re_name",
"=",
"\"\"",
",",
"sk... | [
48,
0
] | [
55,
208
] | python | en | ['en', 'en', 'en'] | True |
nested_value | (ndict, *keys) | Return a nested dict value or None if it doesn't exist. | Return a nested dict value or None if it doesn't exist. | def nested_value(ndict, *keys):
"""Return a nested dict value or None if it doesn't exist."""
if len(keys) == 0:
return ndict
key = keys[0]
if not isinstance(ndict, dict) or key not in ndict:
return None
return nested_value(ndict[key], *keys[1:]) | [
"def",
"nested_value",
"(",
"ndict",
",",
"*",
"keys",
")",
":",
"if",
"len",
"(",
"keys",
")",
"==",
"0",
":",
"return",
"ndict",
"key",
"=",
"keys",
"[",
"0",
"]",
"if",
"not",
"isinstance",
"(",
"ndict",
",",
"dict",
")",
"or",
"key",
"not",
... | [
136,
0
] | [
143,
46
] | python | en | ['en', 'en', 'en'] | True |
test_setup | (hass) | Test that devices are reported correctly. | Test that devices are reported correctly. | async def test_setup(hass):
"""Test that devices are reported correctly."""
with patch(
"sense_energy.SenseLink",
return_value=Mock(start=AsyncMock(), close=AsyncMock()),
):
assert await async_setup_component(hass, DOMAIN, CONFIG) is True | [
"async",
"def",
"test_setup",
"(",
"hass",
")",
":",
"with",
"patch",
"(",
"\"sense_energy.SenseLink\"",
",",
"return_value",
"=",
"Mock",
"(",
"start",
"=",
"AsyncMock",
"(",
")",
",",
"close",
"=",
"AsyncMock",
"(",
")",
")",
",",
")",
":",
"assert",
... | [
146,
0
] | [
152,
72
] | python | en | ['en', 'en', 'en'] | True |
test_float | (hass) | Test a configuration using a simple float. | Test a configuration using a simple float. | async def test_float(hass):
"""Test a configuration using a simple float."""
config = CONFIG_SWITCH[DOMAIN][CONF_ENTITIES]
assert await async_setup_component(
hass,
SWITCH_DOMAIN,
{SWITCH_DOMAIN: {"platform": "demo"}},
)
with patch(
"sense_energy.SenseLink",
r... | [
"async",
"def",
"test_float",
"(",
"hass",
")",
":",
"config",
"=",
"CONFIG_SWITCH",
"[",
"DOMAIN",
"]",
"[",
"CONF_ENTITIES",
"]",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"SWITCH_DOMAIN",
",",
"{",
"SWITCH_DOMAIN",
":",
"{",
"\"platform\... | [
155,
0
] | [
195,
33
] | python | en | ['en', 'en', 'en'] | True |
test_switch_power | (hass) | Test a configuration using a simple float. | Test a configuration using a simple float. | async def test_switch_power(hass):
"""Test a configuration using a simple float."""
config = CONFIG_SWITCH_NO_POWER[DOMAIN][CONF_ENTITIES]
assert await async_setup_component(
hass,
SWITCH_DOMAIN,
{SWITCH_DOMAIN: {"platform": "demo"}},
)
with patch(
"sense_energy.Sense... | [
"async",
"def",
"test_switch_power",
"(",
"hass",
")",
":",
"config",
"=",
"CONFIG_SWITCH_NO_POWER",
"[",
"DOMAIN",
"]",
"[",
"CONF_ENTITIES",
"]",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"SWITCH_DOMAIN",
",",
"{",
"SWITCH_DOMAIN",
":",
"{"... | [
198,
0
] | [
260,
33
] | python | en | ['en', 'en', 'en'] | True |
test_template | (hass) | Test a configuration using a complex template. | Test a configuration using a complex template. | async def test_template(hass):
"""Test a configuration using a complex template."""
config = CONFIG_FAN[DOMAIN][CONF_ENTITIES]
assert await async_setup_component(
hass, FAN_DOMAIN, {FAN_DOMAIN: {"platform": "demo"}}
)
with patch(
"sense_energy.SenseLink",
return_value=Mock(st... | [
"async",
"def",
"test_template",
"(",
"hass",
")",
":",
"config",
"=",
"CONFIG_FAN",
"[",
"DOMAIN",
"]",
"[",
"CONF_ENTITIES",
"]",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"FAN_DOMAIN",
",",
"{",
"FAN_DOMAIN",
":",
"{",
"\"platform\"",
... | [
263,
0
] | [
319,
33
] | python | en | ['en', 'en', 'en'] | True |
test_sensor | (hass) | Test a configuration using a sensor in a template. | Test a configuration using a sensor in a template. | async def test_sensor(hass):
"""Test a configuration using a sensor in a template."""
config = CONFIG_LIGHT[DOMAIN][CONF_ENTITIES]
assert await async_setup_component(
hass, LIGHT_DOMAIN, {LIGHT_DOMAIN: {"platform": "demo"}}
)
assert await async_setup_component(
hass,
SENSOR_D... | [
"async",
"def",
"test_sensor",
"(",
"hass",
")",
":",
"config",
"=",
"CONFIG_LIGHT",
"[",
"DOMAIN",
"]",
"[",
"CONF_ENTITIES",
"]",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"LIGHT_DOMAIN",
",",
"{",
"LIGHT_DOMAIN",
":",
"{",
"\"platform\""... | [
322,
0
] | [
376,
33
] | python | en | ['en', 'en', 'en'] | True |
test_sensor_state | (hass) | Test a configuration using a sensor in a template. | Test a configuration using a sensor in a template. | async def test_sensor_state(hass):
"""Test a configuration using a sensor in a template."""
config = CONFIG_SENSOR[DOMAIN][CONF_ENTITIES]
assert await async_setup_component(
hass,
SENSOR_DOMAIN,
{SENSOR_DOMAIN: {"platform": "demo"}},
)
with patch(
"sense_energy.SenseL... | [
"async",
"def",
"test_sensor_state",
"(",
"hass",
")",
":",
"config",
"=",
"CONFIG_SENSOR",
"[",
"DOMAIN",
"]",
"[",
"CONF_ENTITIES",
"]",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"SENSOR_DOMAIN",
",",
"{",
"SENSOR_DOMAIN",
":",
"{",
"\"pl... | [
379,
0
] | [
423,
33
] | python | en | ['en', 'en', 'en'] | True |
test_multiple_devices | (hass) | Test that devices are reported correctly. | Test that devices are reported correctly. | async def test_multiple_devices(hass):
"""Test that devices are reported correctly."""
config = CONFIG[DOMAIN][CONF_ENTITIES]
assert await async_setup_component(
hass, SWITCH_DOMAIN, {SWITCH_DOMAIN: {"platform": "demo"}}
)
assert await async_setup_component(
hass, LIGHT_DOMAIN, {LIGH... | [
"async",
"def",
"test_multiple_devices",
"(",
"hass",
")",
":",
"config",
"=",
"CONFIG",
"[",
"DOMAIN",
"]",
"[",
"CONF_ENTITIES",
"]",
"assert",
"await",
"async_setup_component",
"(",
"hass",
",",
"SWITCH_DOMAIN",
",",
"{",
"SWITCH_DOMAIN",
":",
"{",
"\"platf... | [
426,
0
] | [
499,
38
] | python | en | ['en', 'en', 'en'] | True |
async_setup | (hass, config) | Set up the wake on LAN component. | Set up the wake on LAN component. | async def async_setup(hass, config):
"""Set up the wake on LAN component."""
async def send_magic_packet(call):
"""Send magic packet to wake up a device."""
mac_address = call.data.get(CONF_MAC)
broadcast_address = call.data.get(CONF_BROADCAST_ADDRESS)
broadcast_port = call.data... | [
"async",
"def",
"async_setup",
"(",
"hass",
",",
"config",
")",
":",
"async",
"def",
"send_magic_packet",
"(",
"call",
")",
":",
"\"\"\"Send magic packet to wake up a device.\"\"\"",
"mac_address",
"=",
"call",
".",
"data",
".",
"get",
"(",
"CONF_MAC",
")",
"bro... | [
25,
0
] | [
58,
15
] | python | en | ['en', 'en', 'en'] | True |
GrowattServerConfigFlow.__init__ | (self) | Initialise growatt server flow. | Initialise growatt server flow. | def __init__(self):
"""Initialise growatt server flow."""
self.api = growattServer.GrowattApi()
self.user_id = None
self.data = {} | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"api",
"=",
"growattServer",
".",
"GrowattApi",
"(",
")",
"self",
".",
"user_id",
"=",
"None",
"self",
".",
"data",
"=",
"{",
"}"
] | [
16,
4
] | [
20,
22
] | python | no | ['no', 'no', 'en'] | True |
GrowattServerConfigFlow._async_show_user_form | (self, errors=None) | Show the form to the user. | Show the form to the user. | def _async_show_user_form(self, errors=None):
"""Show the form to the user."""
data_schema = vol.Schema(
{
vol.Required(CONF_USERNAME): str,
vol.Required(CONF_PASSWORD): str,
vol.Required(CONF_URL, default=DEFAULT_URL): vol.In(SERVER_URLS),
... | [
"def",
"_async_show_user_form",
"(",
"self",
",",
"errors",
"=",
"None",
")",
":",
"data_schema",
"=",
"vol",
".",
"Schema",
"(",
"{",
"vol",
".",
"Required",
"(",
"CONF_USERNAME",
")",
":",
"str",
",",
"vol",
".",
"Required",
"(",
"CONF_PASSWORD",
")",
... | [
23,
4
] | [
35,
9
] | python | en | ['en', 'en', 'en'] | True |
GrowattServerConfigFlow.async_step_user | (self, user_input=None) | Handle the start of the config flow. | Handle the start of the config flow. | async def async_step_user(self, user_input=None):
"""Handle the start of the config flow."""
if not user_input:
return self._async_show_user_form()
self.api.server_url = user_input[CONF_URL]
login_response = await self.hass.async_add_executor_job(
self.api.login,... | [
"async",
"def",
"async_step_user",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"if",
"not",
"user_input",
":",
"return",
"self",
".",
"_async_show_user_form",
"(",
")",
"self",
".",
"api",
".",
"server_url",
"=",
"user_input",
"[",
"CONF_URL",
"... | [
37,
4
] | [
52,
44
] | python | en | ['en', 'en', 'en'] | True |
GrowattServerConfigFlow.async_step_plant | (self, user_input=None) | Handle adding a "plant" to Home Assistant. | Handle adding a "plant" to Home Assistant. | async def async_step_plant(self, user_input=None):
"""Handle adding a "plant" to Home Assistant."""
plant_info = await self.hass.async_add_executor_job(
self.api.plant_list, self.user_id
)
if not plant_info["data"]:
return self.async_abort(reason="no_plants")
... | [
"async",
"def",
"async_step_plant",
"(",
"self",
",",
"user_input",
"=",
"None",
")",
":",
"plant_info",
"=",
"await",
"self",
".",
"hass",
".",
"async_add_executor_job",
"(",
"self",
".",
"api",
".",
"plant_list",
",",
"self",
".",
"user_id",
")",
"if",
... | [
54,
4
] | [
77,
82
] | python | en | ['en', 'en', 'en'] | True |
TestVultrSwitchSetup.add_entities | (self, devices, action) | Mock add devices. | Mock add devices. | def add_entities(self, devices, action):
"""Mock add devices."""
for device in devices:
self.DEVICES.append(device) | [
"def",
"add_entities",
"(",
"self",
",",
"devices",
",",
"action",
")",
":",
"for",
"device",
"in",
"devices",
":",
"self",
".",
"DEVICES",
".",
"append",
"(",
"device",
")"
] | [
31,
4
] | [
34,
39
] | python | en | ['es', 'en', 'en'] | True |
TestVultrSwitchSetup.setUp | (self) | Init values for this testcase class. | Init values for this testcase class. | def setUp(self):
"""Init values for this testcase class."""
self.hass = get_test_home_assistant()
self.configs = [
{CONF_SUBSCRIPTION: "576965", CONF_NAME: "A Server"},
{CONF_SUBSCRIPTION: "123456", CONF_NAME: "Failed Server"},
{CONF_SUBSCRIPTION: "555555", CO... | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"hass",
"=",
"get_test_home_assistant",
"(",
")",
"self",
".",
"configs",
"=",
"[",
"{",
"CONF_SUBSCRIPTION",
":",
"\"576965\"",
",",
"CONF_NAME",
":",
"\"A Server\"",
"}",
",",
"{",
"CONF_SUBSCRIPTION",
... | [
36,
4
] | [
44,
47
] | python | en | ['en', 'en', 'en'] | True |
TestVultrSwitchSetup.tear_down_cleanup | (self) | Stop our started services. | Stop our started services. | def tear_down_cleanup(self):
"""Stop our started services."""
self.hass.stop() | [
"def",
"tear_down_cleanup",
"(",
"self",
")",
":",
"self",
".",
"hass",
".",
"stop",
"(",
")"
] | [
46,
4
] | [
48,
24
] | python | en | ['de', 'en', 'en'] | True |
TestVultrSwitchSetup.test_switch | (self, mock) | Test successful instance. | Test successful instance. | def test_switch(self, mock):
"""Test successful instance."""
mock.get(
"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567",
text=load_fixture("vultr_account_info.json"),
)
with patch(
"vultr.Vultr.server_list",
return_value=json... | [
"def",
"test_switch",
"(",
"self",
",",
"mock",
")",
":",
"mock",
".",
"get",
"(",
"\"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567\"",
",",
"text",
"=",
"load_fixture",
"(",
"\"vultr_account_info.json\"",
")",
",",
")",
"with",
"patch",
"(",
"\"vultr... | [
51,
4
] | [
109,
26
] | python | en | ['en', 'ro', 'en'] | True |
TestVultrSwitchSetup.test_turn_on | (self, mock) | Test turning a subscription on. | Test turning a subscription on. | def test_turn_on(self, mock):
"""Test turning a subscription on."""
with patch(
"vultr.Vultr.server_list",
return_value=json.loads(load_fixture("vultr_server_list.json")),
), patch("vultr.Vultr.server_start") as mock_start:
for device in self.DEVICES:
... | [
"def",
"test_turn_on",
"(",
"self",
",",
"mock",
")",
":",
"with",
"patch",
"(",
"\"vultr.Vultr.server_list\"",
",",
"return_value",
"=",
"json",
".",
"loads",
"(",
"load_fixture",
"(",
"\"vultr_server_list.json\"",
")",
")",
",",
")",
",",
"patch",
"(",
"\"... | [
112,
4
] | [
123,
41
] | python | en | ['en', 'en', 'en'] | True |
TestVultrSwitchSetup.test_turn_off | (self, mock) | Test turning a subscription off. | Test turning a subscription off. | def test_turn_off(self, mock):
"""Test turning a subscription off."""
with patch(
"vultr.Vultr.server_list",
return_value=json.loads(load_fixture("vultr_server_list.json")),
), patch("vultr.Vultr.server_halt") as mock_halt:
for device in self.DEVICES:
... | [
"def",
"test_turn_off",
"(",
"self",
",",
"mock",
")",
":",
"with",
"patch",
"(",
"\"vultr.Vultr.server_list\"",
",",
"return_value",
"=",
"json",
".",
"loads",
"(",
"load_fixture",
"(",
"\"vultr_server_list.json\"",
")",
")",
",",
")",
",",
"patch",
"(",
"\... | [
126,
4
] | [
137,
40
] | python | en | ['en', 'en', 'en'] | True |
TestVultrSwitchSetup.test_invalid_switch_config | (self) | Test config type failures. | Test config type failures. | def test_invalid_switch_config(self):
"""Test config type failures."""
with pytest.raises(vol.Invalid): # No subscription
vultr.PLATFORM_SCHEMA({CONF_PLATFORM: base_vultr.DOMAIN}) | [
"def",
"test_invalid_switch_config",
"(",
"self",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"vol",
".",
"Invalid",
")",
":",
"# No subscription",
"vultr",
".",
"PLATFORM_SCHEMA",
"(",
"{",
"CONF_PLATFORM",
":",
"base_vultr",
".",
"DOMAIN",
"}",
")"
] | [
139,
4
] | [
142,
69
] | python | en | ['en', 'en', 'en'] | True |
TestVultrSwitchSetup.test_invalid_switches | (self, mock) | Test the VultrSwitch fails. | Test the VultrSwitch fails. | def test_invalid_switches(self, mock):
"""Test the VultrSwitch fails."""
mock.get(
"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567",
text=load_fixture("vultr_account_info.json"),
)
with patch(
"vultr.Vultr.server_list",
retur... | [
"def",
"test_invalid_switches",
"(",
"self",
",",
"mock",
")",
":",
"mock",
".",
"get",
"(",
"\"https://api.vultr.com/v1/account/info?api_key=ABCDEFG1234567\"",
",",
"text",
"=",
"load_fixture",
"(",
"\"vultr_account_info.json\"",
")",
",",
")",
"with",
"patch",
"(",
... | [
145,
4
] | [
176,
43
] | python | en | ['en', 'en', 'en'] | True |
usb_device_from_port | (port: ListPortInfo) | Convert serial ListPortInfo to USBDevice. | Convert serial ListPortInfo to USBDevice. | def usb_device_from_port(port: ListPortInfo) -> USBDevice:
"""Convert serial ListPortInfo to USBDevice."""
return USBDevice(
device=port.device,
vid=f"{hex(port.vid)[2:]:0>4}".upper(),
pid=f"{hex(port.pid)[2:]:0>4}".upper(),
serial_number=port.serial_number,
manufacturer=... | [
"def",
"usb_device_from_port",
"(",
"port",
":",
"ListPortInfo",
")",
"->",
"USBDevice",
":",
"return",
"USBDevice",
"(",
"device",
"=",
"port",
".",
"device",
",",
"vid",
"=",
"f\"{hex(port.vid)[2:]:0>4}\"",
".",
"upper",
"(",
")",
",",
"pid",
"=",
"f\"{hex... | [
8,
0
] | [
17,
5
] | python | en | ['en', 'lb', 'en'] | True |
test_process_integration_platforms | (hass) | Test processing integrations. | Test processing integrations. | async def test_process_integration_platforms(hass):
"""Test processing integrations."""
loaded_platform = Mock()
mock_platform(hass, "loaded.platform_to_check", loaded_platform)
hass.config.components.add("loaded")
event_platform = Mock()
mock_platform(hass, "event.platform_to_check", event_pla... | [
"async",
"def",
"test_process_integration_platforms",
"(",
"hass",
")",
":",
"loaded_platform",
"=",
"Mock",
"(",
")",
"mock_platform",
"(",
"hass",
",",
"\"loaded.platform_to_check\"",
",",
"loaded_platform",
")",
"hass",
".",
"config",
".",
"components",
".",
"a... | [
8,
0
] | [
36,
44
] | python | en | ['en', 'en', 'en'] | True |
create_config_entry | (hass, token_expiration_time=None) | Create a ConfigEntry and add it to Home Assistant. | Create a ConfigEntry and add it to Home Assistant. | def create_config_entry(hass, token_expiration_time=None):
"""Create a ConfigEntry and add it to Home Assistant."""
if token_expiration_time is None:
token_expiration_time = time.time() + 86400
config_entry_data = {
"sdm": {}, # Indicates new SDM API, not legacy API
"auth_implementa... | [
"def",
"create_config_entry",
"(",
"hass",
",",
"token_expiration_time",
"=",
"None",
")",
":",
"if",
"token_expiration_time",
"is",
"None",
":",
"token_expiration_time",
"=",
"time",
".",
"time",
"(",
")",
"+",
"86400",
"config_entry_data",
"=",
"{",
"\"sdm\"",... | [
34,
0
] | [
49,
76
] | python | en | ['en', 'en', 'en'] | True |
async_setup_sdm_platform | (hass, platform, devices={}, structures={}) | Set up the platform and prerequisites. | Set up the platform and prerequisites. | async def async_setup_sdm_platform(hass, platform, devices={}, structures={}):
"""Set up the platform and prerequisites."""
create_config_entry(hass)
device_manager = FakeDeviceManager(devices=devices, structures=structures)
subscriber = FakeSubscriber(device_manager)
with patch(
"homeassist... | [
"async",
"def",
"async_setup_sdm_platform",
"(",
"hass",
",",
"platform",
",",
"devices",
"=",
"{",
"}",
",",
"structures",
"=",
"{",
"}",
")",
":",
"create_config_entry",
"(",
"hass",
")",
"device_manager",
"=",
"FakeDeviceManager",
"(",
"devices",
"=",
"de... | [
101,
0
] | [
113,
21
] | python | en | ['en', 'en', 'en'] | True |
FakeDeviceManager.__init__ | (self, devices: dict, structures: dict) | Initialize FakeDeviceManager. | Initialize FakeDeviceManager. | def __init__(self, devices: dict, structures: dict):
"""Initialize FakeDeviceManager."""
super().__init__()
self._devices = devices | [
"def",
"__init__",
"(",
"self",
",",
"devices",
":",
"dict",
",",
"structures",
":",
"dict",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_devices",
"=",
"devices"
] | [
55,
4
] | [
58,
31
] | python | en | ['en', 'en', 'it'] | False |
FakeDeviceManager.structures | (self) | Override structures with fake result. | Override structures with fake result. | def structures(self) -> dict:
"""Override structures with fake result."""
return self._structures | [
"def",
"structures",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"self",
".",
"_structures"
] | [
61,
4
] | [
63,
31
] | python | en | ['en', 'en', 'en'] | True |
FakeDeviceManager.devices | (self) | Override devices with fake result. | Override devices with fake result. | def devices(self) -> dict:
"""Override devices with fake result."""
return self._devices | [
"def",
"devices",
"(",
"self",
")",
"->",
"dict",
":",
"return",
"self",
".",
"_devices"
] | [
66,
4
] | [
68,
28
] | python | en | ['en', 'en', 'en'] | True |
FakeSubscriber.__init__ | (self, device_manager: FakeDeviceManager) | Initialize Fake Subscriber. | Initialize Fake Subscriber. | def __init__(self, device_manager: FakeDeviceManager):
"""Initialize Fake Subscriber."""
self._device_manager = device_manager | [
"def",
"__init__",
"(",
"self",
",",
"device_manager",
":",
"FakeDeviceManager",
")",
":",
"self",
".",
"_device_manager",
"=",
"device_manager"
] | [
74,
4
] | [
76,
45
] | python | en | ['en', 'en', 'en'] | True |
FakeSubscriber.set_update_callback | (self, callback: Callable[[EventMessage], Awaitable[None]]) | Capture the callback set by Home Assistant. | Capture the callback set by Home Assistant. | def set_update_callback(self, callback: Callable[[EventMessage], Awaitable[None]]):
"""Capture the callback set by Home Assistant."""
self._callback = callback | [
"def",
"set_update_callback",
"(",
"self",
",",
"callback",
":",
"Callable",
"[",
"[",
"EventMessage",
"]",
",",
"Awaitable",
"[",
"None",
"]",
"]",
")",
":",
"self",
".",
"_callback",
"=",
"callback"
] | [
78,
4
] | [
80,
33
] | python | en | ['en', 'en', 'en'] | True |
FakeSubscriber.start_async | (self) | Return the fake device manager. | Return the fake device manager. | async def start_async(self):
"""Return the fake device manager."""
return self._device_manager | [
"async",
"def",
"start_async",
"(",
"self",
")",
":",
"return",
"self",
".",
"_device_manager"
] | [
82,
4
] | [
84,
35
] | python | en | ['en', 'en', 'en'] | True |
FakeSubscriber.async_get_device_manager | (self) | Return the fake device manager. | Return the fake device manager. | async def async_get_device_manager(self) -> DeviceManager:
"""Return the fake device manager."""
return self._device_manager | [
"async",
"def",
"async_get_device_manager",
"(",
"self",
")",
"->",
"DeviceManager",
":",
"return",
"self",
".",
"_device_manager"
] | [
86,
4
] | [
88,
35
] | python | en | ['en', 'en', 'en'] | True |
FakeSubscriber.stop_async | (self) | No-op to stop the subscriber. | No-op to stop the subscriber. | def stop_async(self):
"""No-op to stop the subscriber."""
return None | [
"def",
"stop_async",
"(",
"self",
")",
":",
"return",
"None"
] | [
90,
4
] | [
92,
19
] | python | en | ['en', 'en', 'en'] | True |
FakeSubscriber.async_receive_event | (self, event_message: EventMessage) | Simulate a received pubsub message, invoked by tests. | Simulate a received pubsub message, invoked by tests. | async def async_receive_event(self, event_message: EventMessage):
"""Simulate a received pubsub message, invoked by tests."""
# Update device state, then invoke HomeAssistant to refresh
await self._device_manager.async_handle_event(event_message)
await self._callback(event_message) | [
"async",
"def",
"async_receive_event",
"(",
"self",
",",
"event_message",
":",
"EventMessage",
")",
":",
"# Update device state, then invoke HomeAssistant to refresh",
"await",
"self",
".",
"_device_manager",
".",
"async_handle_event",
"(",
"event_message",
")",
"await",
... | [
94,
4
] | [
98,
43
] | python | en | ['en', 'en', 'en'] | True |
mock_config_entry | () | Return the default mocked config entry. | Return the default mocked config entry. | def mock_config_entry() -> MockConfigEntry:
"""Return the default mocked config entry."""
return MockConfigEntry(
title="Home Sweet Home",
domain=DOMAIN,
data={CONF_LATITUDE: 52.42, CONF_LONGITUDE: 4.44, CONF_API_KEY: "example"},
unique_id="unique_thingy",
) | [
"def",
"mock_config_entry",
"(",
")",
"->",
"MockConfigEntry",
":",
"return",
"MockConfigEntry",
"(",
"title",
"=",
"\"Home Sweet Home\"",
",",
"domain",
"=",
"DOMAIN",
",",
"data",
"=",
"{",
"CONF_LATITUDE",
":",
"52.42",
",",
"CONF_LONGITUDE",
":",
"4.44",
"... | [
16,
0
] | [
23,
5
] | python | en | ['en', 'da', 'en'] | True |
mock_ambee | (aioclient_mock: AiohttpClientMocker) | Return a mocked Ambee client. | Return a mocked Ambee client. | def mock_ambee(aioclient_mock: AiohttpClientMocker):
"""Return a mocked Ambee client."""
with patch("homeassistant.components.ambee.Ambee") as ambee_mock:
client = ambee_mock.return_value
client.air_quality = AsyncMock(
return_value=AirQuality.from_dict(
json.loads(lo... | [
"def",
"mock_ambee",
"(",
"aioclient_mock",
":",
"AiohttpClientMocker",
")",
":",
"with",
"patch",
"(",
"\"homeassistant.components.ambee.Ambee\"",
")",
"as",
"ambee_mock",
":",
"client",
"=",
"ambee_mock",
".",
"return_value",
"client",
".",
"air_quality",
"=",
"As... | [
27,
0
] | [
39,
24
] | python | en | ['en', 'en', 'en'] | True |
init_integration | (
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_ambee: MagicMock
) | Set up the Ambee integration for testing. | Set up the Ambee integration for testing. | async def init_integration(
hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_ambee: MagicMock
) -> MockConfigEntry:
"""Set up the Ambee integration for testing."""
mock_config_entry.add_to_hass(hass)
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_blo... | [
"async",
"def",
"init_integration",
"(",
"hass",
":",
"HomeAssistant",
",",
"mock_config_entry",
":",
"MockConfigEntry",
",",
"mock_ambee",
":",
"MagicMock",
")",
"->",
"MockConfigEntry",
":",
"mock_config_entry",
".",
"add_to_hass",
"(",
"hass",
")",
"await",
"ha... | [
43,
0
] | [
52,
28
] | python | en | ['en', 'en', 'en'] | True |
accuracy | (output, target, topk=(1,)) | Computes the accuracy@k for the specified values of k | Computes the accuracy | def accuracy(output, target, topk=(1,)):
"""Computes the accuracy@k for the specified values of k"""
corrrect_ks = correct(output, target, topk)
batch_size = target.size(0)
return [correct_k.float().mul_(100.0 / batch_size) for correct_k in corrrect_ks] | [
"def",
"accuracy",
"(",
"output",
",",
"target",
",",
"topk",
"=",
"(",
"1",
",",
")",
")",
":",
"corrrect_ks",
"=",
"correct",
"(",
"output",
",",
"target",
",",
"topk",
")",
"batch_size",
"=",
"target",
".",
"size",
"(",
"0",
")",
"return",
"[",
... | [
408,
0
] | [
412,
84
] | python | en | ['en', 'en', 'en'] | True |
correct | (output, target, topk=(1,)) | Computes the accuracy@k for the specified values of k | Computes the accuracy | def correct(output, target, topk=(1,)):
"""Computes the accuracy@k for the specified values of k"""
maxk = max(topk)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-... | [
"def",
"correct",
"(",
"output",
",",
"target",
",",
"topk",
"=",
"(",
"1",
",",
")",
")",
":",
"maxk",
"=",
"max",
"(",
"topk",
")",
"_",
",",
"pred",
"=",
"output",
".",
"topk",
"(",
"maxk",
",",
"1",
",",
"True",
",",
"True",
")",
"pred",
... | [
414,
0
] | [
424,
14
] | python | en | ['en', 'en', 'en'] | True |
DataManager.set_data | (self, phase) | Initializes data loader. | Initializes data loader. | def set_data(self, phase):
"""Initializes data loader."""
if phase.get('keep_dl', False):
log.event(f'Batch size changed: {phase["bs"]}')
tb.log_size(phase['bs'])
self.trn_dl.update_batch_size(phase['bs'])
return
log.event(f'Dataset change... | [
"def",
"set_data",
"(",
"self",
",",
"phase",
")",
":",
"if",
"phase",
".",
"get",
"(",
"'keep_dl'",
",",
"False",
")",
":",
"log",
".",
"event",
"(",
"f'Batch size changed: {phase[\"bs\"]}'",
")",
"tb",
".",
"log_size",
"(",
"phase",
"[",
"'bs'",
"]",
... | [
303,
4
] | [
318,
20
] | python | en | ['pt', 'en', 'en'] | True |
DataManager.preload_data | (self, ep, sz, bs, trndir, valdir, **kwargs) | Pre-initializes data-loaders. Use set_data to start using it. | Pre-initializes data-loaders. Use set_data to start using it. | def preload_data(self, ep, sz, bs, trndir, valdir, **kwargs): # dummy ep var to prevent error
if 'lr' in kwargs: del kwargs['lr'] # in case we mix schedule and data phases
"""Pre-initializes data-loaders. Use set_data to start using it."""
if sz == 128: val_bs = max(bs, 512)
elif sz == 2... | [
"def",
"preload_data",
"(",
"self",
",",
"ep",
",",
"sz",
",",
"bs",
",",
"trndir",
",",
"valdir",
",",
"*",
"*",
"kwargs",
")",
":",
"# dummy ep var to prevent error",
"if",
"'lr'",
"in",
"kwargs",
":",
"del",
"kwargs",
"[",
"'lr'",
"]",
"# in case we m... | [
333,
4
] | [
339,
144
] | python | en | ['pt', 'en', 'en'] | True |
TestOrder.make_instance | (self, include_optional) | Test Order
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | Test Order
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | def make_instance(self, include_optional):
"""Test Order
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = petstore_api.models.order.Order() # noqa: E501
if includ... | [
"def",
"make_instance",
"(",
"self",
",",
"include_optional",
")",
":",
"# model = petstore_api.models.order.Order() # noqa: E501",
"if",
"include_optional",
":",
"return",
"Order",
"(",
"id",
"=",
"56",
",",
"pet_id",
"=",
"56",
",",
"quantity",
"=",
"56",
",",
... | [
30,
4
] | [
47,
9
] | python | en | ['en', 'da', 'en'] | False |
async_setup_platform | (
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: dict[str, Any] | None = None,
) | Set up the API streams platform. | Set up the API streams platform. | async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: dict[str, Any] | None = None,
) -> None:
"""Set up the API streams platform."""
entity = APICount()
async_add_entities([entity]) | [
"async",
"def",
"async_setup_platform",
"(",
"hass",
":",
"HomeAssistant",
",",
"config",
":",
"ConfigType",
",",
"async_add_entities",
":",
"AddEntitiesCallback",
",",
"discovery_info",
":",
"dict",
"[",
"str",
",",
"Any",
"]",
"|",
"None",
"=",
"None",
",",
... | [
17,
0
] | [
26,
32
] | python | en | ['en', 'pt', 'en'] | True |
APICount.__init__ | (self) | Initialize the API count. | Initialize the API count. | def __init__(self) -> None:
"""Initialize the API count."""
self.count = 0 | [
"def",
"__init__",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"count",
"=",
"0"
] | [
32,
4
] | [
34,
22
] | python | en | ['en', 'en', 'en'] | True |
APICount.async_added_to_hass | (self) | Added to hass. | Added to hass. | async def async_added_to_hass(self) -> None:
"""Added to hass."""
self.async_on_remove(
self.hass.helpers.dispatcher.async_dispatcher_connect(
SIGNAL_WEBSOCKET_CONNECTED, self._update_count
)
)
self.async_on_remove(
self.hass.helpers.di... | [
"async",
"def",
"async_added_to_hass",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"async_on_remove",
"(",
"self",
".",
"hass",
".",
"helpers",
".",
"dispatcher",
".",
"async_dispatcher_connect",
"(",
"SIGNAL_WEBSOCKET_CONNECTED",
",",
"self",
".",
"_updat... | [
36,
4
] | [
47,
9
] | python | en | ['en', 'en', 'en'] | True |
APICount.name | (self) | Return name of entity. | Return name of entity. | def name(self) -> str:
"""Return name of entity."""
return "Connected clients" | [
"def",
"name",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"Connected clients\""
] | [
50,
4
] | [
52,
34
] | python | en | ['en', 'ig', 'en'] | True |
APICount.native_value | (self) | Return current API count. | Return current API count. | def native_value(self) -> int:
"""Return current API count."""
return self.count | [
"def",
"native_value",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"count"
] | [
55,
4
] | [
57,
25
] | python | en | ['en', 'la', 'en'] | True |
APICount.native_unit_of_measurement | (self) | Return the unit of measurement. | Return the unit of measurement. | def native_unit_of_measurement(self) -> str:
"""Return the unit of measurement."""
return "clients" | [
"def",
"native_unit_of_measurement",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"clients\""
] | [
60,
4
] | [
62,
24
] | python | en | ['en', 'la', 'en'] | True |
test_async_setup_entry | (hass) | Test a successful setup entry. | Test a successful setup entry. | async def test_async_setup_entry(hass):
"""Test a successful setup entry."""
await init_integration(hass)
state = hass.states.get("weather.home")
assert state is not None
assert state.state != STATE_UNAVAILABLE
assert state.state == "sunny" | [
"async",
"def",
"test_async_setup_entry",
"(",
"hass",
")",
":",
"await",
"init_integration",
"(",
"hass",
")",
"state",
"=",
"hass",
".",
"states",
".",
"get",
"(",
"\"weather.home\"",
")",
"assert",
"state",
"is",
"not",
"None",
"assert",
"state",
".",
"... | [
16,
0
] | [
23,
33
] | python | en | ['en', 'en', 'en'] | True |
test_config_not_ready | (hass) | Test for setup failure if connection to AccuWeather is missing. | Test for setup failure if connection to AccuWeather is missing. | async def test_config_not_ready(hass):
"""Test for setup failure if connection to AccuWeather is missing."""
entry = MockConfigEntry(
domain=DOMAIN,
title="Home",
unique_id="0123456",
data={
"api_key": "32-character-string-1234567890qw",
"latitude": 55.55,... | [
"async",
"def",
"test_config_not_ready",
"(",
"hass",
")",
":",
"entry",
"=",
"MockConfigEntry",
"(",
"domain",
"=",
"DOMAIN",
",",
"title",
"=",
"\"Home\"",
",",
"unique_id",
"=",
"\"0123456\"",
",",
"data",
"=",
"{",
"\"api_key\"",
":",
"\"32-character-strin... | [
26,
0
] | [
46,
58
] | python | en | ['en', 'en', 'en'] | True |
test_unload_entry | (hass) | Test successful unload of entry. | Test successful unload of entry. | async def test_unload_entry(hass):
"""Test successful unload of entry."""
entry = await init_integration(hass)
assert len(hass.config_entries.async_entries(DOMAIN)) == 1
assert entry.state is ConfigEntryState.LOADED
assert await hass.config_entries.async_unload(entry.entry_id)
await hass.async... | [
"async",
"def",
"test_unload_entry",
"(",
"hass",
")",
":",
"entry",
"=",
"await",
"init_integration",
"(",
"hass",
")",
"assert",
"len",
"(",
"hass",
".",
"config_entries",
".",
"async_entries",
"(",
"DOMAIN",
")",
")",
"==",
"1",
"assert",
"entry",
".",
... | [
49,
0
] | [
60,
36
] | python | en | ['en', 'en', 'en'] | True |
test_update_interval | (hass) | Test correct update interval. | Test correct update interval. | async def test_update_interval(hass):
"""Test correct update interval."""
entry = await init_integration(hass)
assert entry.state is ConfigEntryState.LOADED
current = json.loads(load_fixture("accuweather/current_conditions_data.json"))
future = utcnow() + timedelta(minutes=40)
with patch(
... | [
"async",
"def",
"test_update_interval",
"(",
"hass",
")",
":",
"entry",
"=",
"await",
"init_integration",
"(",
"hass",
")",
"assert",
"entry",
".",
"state",
"is",
"ConfigEntryState",
".",
"LOADED",
"current",
"=",
"json",
".",
"loads",
"(",
"load_fixture",
"... | [
63,
0
] | [
82,
43
] | python | en | ['en', 'en', 'en'] | True |
test_update_interval_forecast | (hass) | Test correct update interval when forecast is True. | Test correct update interval when forecast is True. | async def test_update_interval_forecast(hass):
"""Test correct update interval when forecast is True."""
entry = await init_integration(hass, forecast=True)
assert entry.state is ConfigEntryState.LOADED
current = json.loads(load_fixture("accuweather/current_conditions_data.json"))
forecast = json.... | [
"async",
"def",
"test_update_interval_forecast",
"(",
"hass",
")",
":",
"entry",
"=",
"await",
"init_integration",
"(",
"hass",
",",
"forecast",
"=",
"True",
")",
"assert",
"entry",
".",
"state",
"is",
"ConfigEntryState",
".",
"LOADED",
"current",
"=",
"json",... | [
85,
0
] | [
110,
44
] | python | en | ['en', 'en', 'en'] | True |
wait_for_read | (sock, timeout=None) | Waits for reading to be available on a given socket.
Returns True if the socket is readable, or False if the timeout expired.
| Waits for reading to be available on a given socket.
Returns True if the socket is readable, or False if the timeout expired.
| def wait_for_read(sock, timeout=None):
""" Waits for reading to be available on a given socket.
Returns True if the socket is readable, or False if the timeout expired.
"""
return wait_for_socket(sock, read=True, timeout=timeout) | [
"def",
"wait_for_read",
"(",
"sock",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"wait_for_socket",
"(",
"sock",
",",
"read",
"=",
"True",
",",
"timeout",
"=",
"timeout",
")"
] | [
141,
0
] | [
145,
60
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.