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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
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 |
View.__init__ | (self, **kwargs) |
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
|
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
| def __init__(self, **kwargs):
"""
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
"""
# Go through keyword arguments, and either save their values to our
# instance, or raise an error.
for key, value in six.iterit... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Go through keyword arguments, and either save their values to our",
"# instance, or raise an error.",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"kwargs",
")",
":",
"setattr",
... | [
35,
4
] | [
43,
37
] | python | en | ['en', 'error', 'th'] | False |
View.as_view | (cls, **initkwargs) |
Main entry point for a request-response process.
|
Main entry point for a request-response process.
| def as_view(cls, **initkwargs):
"""
Main entry point for a request-response process.
"""
# sanitize keyword arguments
for key in initkwargs:
if key in cls.http_method_names:
raise TypeError("You tried to pass in the %s method name as a "
... | [
"def",
"as_view",
"(",
"cls",
",",
"*",
"*",
"initkwargs",
")",
":",
"# sanitize keyword arguments",
"for",
"key",
"in",
"initkwargs",
":",
"if",
"key",
"in",
"cls",
".",
"http_method_names",
":",
"raise",
"TypeError",
"(",
"\"You tried to pass in the %s method na... | [
46,
4
] | [
76,
19
] | python | en | ['en', 'error', 'th'] | False |
View.options | (self, request, *args, **kwargs) |
Handles responding to requests for the OPTIONS HTTP verb.
|
Handles responding to requests for the OPTIONS HTTP verb.
| def options(self, request, *args, **kwargs):
"""
Handles responding to requests for the OPTIONS HTTP verb.
"""
response = http.HttpResponse()
response['Allow'] = ', '.join(self._allowed_methods())
response['Content-Length'] = '0'
return response | [
"def",
"options",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"http",
".",
"HttpResponse",
"(",
")",
"response",
"[",
"'Allow'",
"]",
"=",
"', '",
".",
"join",
"(",
"self",
".",
"_allowed_methods... | [
97,
4
] | [
104,
23
] | python | en | ['en', 'error', 'th'] | False |
TemplateResponseMixin.render_to_response | (self, context, **response_kwargs) |
Returns a response, using the `response_class` for this
view, with a template rendered with the given context.
If any keyword arguments are provided, they will be
passed to the constructor of the response class.
|
Returns a response, using the `response_class` for this
view, with a template rendered with the given context. | def render_to_response(self, context, **response_kwargs):
"""
Returns a response, using the `response_class` for this
view, with a template rendered with the given context.
If any keyword arguments are provided, they will be
passed to the constructor of the response class.
... | [
"def",
"render_to_response",
"(",
"self",
",",
"context",
",",
"*",
"*",
"response_kwargs",
")",
":",
"response_kwargs",
".",
"setdefault",
"(",
"'content_type'",
",",
"self",
".",
"content_type",
")",
"return",
"self",
".",
"response_class",
"(",
"request",
"... | [
118,
4
] | [
132,
9
] | python | en | ['en', 'error', 'th'] | False |
TemplateResponseMixin.get_template_names | (self) |
Returns a list of template names to be used for the request. Must return
a list. May not be called if render_to_response is overridden.
|
Returns a list of template names to be used for the request. Must return
a list. May not be called if render_to_response is overridden.
| def get_template_names(self):
"""
Returns a list of template names to be used for the request. Must return
a list. May not be called if render_to_response is overridden.
"""
if self.template_name is None:
raise ImproperlyConfigured(
"TemplateResponseMi... | [
"def",
"get_template_names",
"(",
"self",
")",
":",
"if",
"self",
".",
"template_name",
"is",
"None",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"TemplateResponseMixin requires either a definition of \"",
"\"'template_name' or an implementation of 'get_template_names()'\"",
")"... | [
134,
4
] | [
144,
39
] | python | en | ['en', 'error', 'th'] | False |
RedirectView.get_redirect_url | (self, *args, **kwargs) |
Return the URL redirect to. Keyword arguments from the
URL pattern match generating the redirect request
are provided as kwargs to this method.
|
Return the URL redirect to. Keyword arguments from the
URL pattern match generating the redirect request
are provided as kwargs to this method.
| def get_redirect_url(self, *args, **kwargs):
"""
Return the URL redirect to. Keyword arguments from the
URL pattern match generating the redirect request
are provided as kwargs to this method.
"""
if self.url:
url = self.url % kwargs
elif self.pattern_... | [
"def",
"get_redirect_url",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"url",
":",
"url",
"=",
"self",
".",
"url",
"%",
"kwargs",
"elif",
"self",
".",
"pattern_name",
":",
"try",
":",
"url",
"=",
"reverse",
... | [
166,
4
] | [
185,
18
] | python | en | ['en', 'error', 'th'] | False |
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 |
lookup_needs_distinct | (opts, lookup_path) |
Returns True if 'distinct()' should be used to query the given lookup path.
|
Returns True if 'distinct()' should be used to query the given lookup path.
| def lookup_needs_distinct(opts, lookup_path):
"""
Returns True if 'distinct()' should be used to query the given lookup path.
"""
field_name = lookup_path.split('__', 1)[0]
field = opts.get_field_by_name(field_name)[0]
if hasattr(field, 'get_path_info') and any(path.m2m for path in field.get_pat... | [
"def",
"lookup_needs_distinct",
"(",
"opts",
",",
"lookup_path",
")",
":",
"field_name",
"=",
"lookup_path",
".",
"split",
"(",
"'__'",
",",
"1",
")",
"[",
"0",
"]",
"field",
"=",
"opts",
".",
"get_field_by_name",
"(",
"field_name",
")",
"[",
"0",
"]",
... | [
21,
0
] | [
29,
16
] | python | en | ['en', 'error', 'th'] | False |
prepare_lookup_value | (key, value) |
Returns a lookup value prepared to be used in queryset filtering.
|
Returns a lookup value prepared to be used in queryset filtering.
| def prepare_lookup_value(key, value):
"""
Returns a lookup value prepared to be used in queryset filtering.
"""
# if key ends with __in, split parameter into separate values
if key.endswith('__in'):
value = value.split(',')
# if key ends with __isnull, special case '' and the string lite... | [
"def",
"prepare_lookup_value",
"(",
"key",
",",
"value",
")",
":",
"# if key ends with __in, split parameter into separate values",
"if",
"key",
".",
"endswith",
"(",
"'__in'",
")",
":",
"value",
"=",
"value",
".",
"split",
"(",
"','",
")",
"# if key ends with __isn... | [
32,
0
] | [
45,
16
] | python | en | ['en', 'error', 'th'] | False |
quote | (s) |
Ensure that primary key values do not confuse the admin URLs by escaping
any '/', '_' and ':' and similarly problematic characters.
Similar to urllib.quote, except that the quoting is slightly different so
that it doesn't get automatically unquoted by the Web browser.
|
Ensure that primary key values do not confuse the admin URLs by escaping
any '/', '_' and ':' and similarly problematic characters.
Similar to urllib.quote, except that the quoting is slightly different so
that it doesn't get automatically unquoted by the Web browser.
| def quote(s):
"""
Ensure that primary key values do not confuse the admin URLs by escaping
any '/', '_' and ':' and similarly problematic characters.
Similar to urllib.quote, except that the quoting is slightly different so
that it doesn't get automatically unquoted by the Web browser.
"""
i... | [
"def",
"quote",
"(",
"s",
")",
":",
"if",
"not",
"isinstance",
"(",
"s",
",",
"six",
".",
"string_types",
")",
":",
"return",
"s",
"res",
"=",
"list",
"(",
"s",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"res",
")",
")",
":",
"c",
"=",
... | [
48,
0
] | [
62,
23
] | python | en | ['en', 'error', 'th'] | False |
unquote | (s) |
Undo the effects of quote(). Based heavily on urllib.unquote().
|
Undo the effects of quote(). Based heavily on urllib.unquote().
| def unquote(s):
"""
Undo the effects of quote(). Based heavily on urllib.unquote().
"""
mychr = chr
myatoi = int
list = s.split('_')
res = [list[0]]
myappend = res.append
del list[0]
for item in list:
if item[1:2]:
try:
myappend(mychr(myatoi(it... | [
"def",
"unquote",
"(",
"s",
")",
":",
"mychr",
"=",
"chr",
"myatoi",
"=",
"int",
"list",
"=",
"s",
".",
"split",
"(",
"'_'",
")",
"res",
"=",
"[",
"list",
"[",
"0",
"]",
"]",
"myappend",
"=",
"res",
".",
"append",
"del",
"list",
"[",
"0",
"]"... | [
65,
0
] | [
83,
23
] | python | en | ['en', 'error', 'th'] | False |
flatten | (fields) | Returns a list which is a single level of flattening of the
original list. | Returns a list which is a single level of flattening of the
original list. | def flatten(fields):
"""Returns a list which is a single level of flattening of the
original list."""
flat = []
for field in fields:
if isinstance(field, (list, tuple)):
flat.extend(field)
else:
flat.append(field)
return flat | [
"def",
"flatten",
"(",
"fields",
")",
":",
"flat",
"=",
"[",
"]",
"for",
"field",
"in",
"fields",
":",
"if",
"isinstance",
"(",
"field",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"flat",
".",
"extend",
"(",
"field",
")",
"else",
":",
"flat",... | [
86,
0
] | [
95,
15
] | python | en | ['en', 'en', 'en'] | True |
flatten_fieldsets | (fieldsets) | Returns a list of field names from an admin fieldsets structure. | Returns a list of field names from an admin fieldsets structure. | def flatten_fieldsets(fieldsets):
"""Returns a list of field names from an admin fieldsets structure."""
field_names = []
for name, opts in fieldsets:
field_names.extend(
flatten(opts['fields'])
)
return field_names | [
"def",
"flatten_fieldsets",
"(",
"fieldsets",
")",
":",
"field_names",
"=",
"[",
"]",
"for",
"name",
",",
"opts",
"in",
"fieldsets",
":",
"field_names",
".",
"extend",
"(",
"flatten",
"(",
"opts",
"[",
"'fields'",
"]",
")",
")",
"return",
"field_names"
] | [
98,
0
] | [
105,
22
] | python | en | ['en', 'en', 'en'] | True |
get_deleted_objects | (objs, opts, user, admin_site, using) |
Find all objects related to ``objs`` that should also be deleted. ``objs``
must be a homogeneous iterable of objects (e.g. a QuerySet).
Returns a nested list of strings suitable for display in the
template with the ``unordered_list`` filter.
|
Find all objects related to ``objs`` that should also be deleted. ``objs``
must be a homogeneous iterable of objects (e.g. a QuerySet). | def get_deleted_objects(objs, opts, user, admin_site, using):
"""
Find all objects related to ``objs`` that should also be deleted. ``objs``
must be a homogeneous iterable of objects (e.g. a QuerySet).
Returns a nested list of strings suitable for display in the
template with the ``unordered_list``... | [
"def",
"get_deleted_objects",
"(",
"objs",
",",
"opts",
",",
"user",
",",
"admin_site",
",",
"using",
")",
":",
"collector",
"=",
"NestedObjects",
"(",
"using",
"=",
"using",
")",
"collector",
".",
"collect",
"(",
"objs",
")",
"perms_needed",
"=",
"set",
... | [
108,
0
] | [
157,
68
] | python | en | ['en', 'error', 'th'] | False |
model_format_dict | (obj) |
Return a `dict` with keys 'verbose_name' and 'verbose_name_plural',
typically for use with string formatting.
`obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance.
|
Return a `dict` with keys 'verbose_name' and 'verbose_name_plural',
typically for use with string formatting. | def model_format_dict(obj):
"""
Return a `dict` with keys 'verbose_name' and 'verbose_name_plural',
typically for use with string formatting.
`obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance.
"""
if isinstance(obj, (models.Model, models.base.ModelBase)):
opts =... | [
"def",
"model_format_dict",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"models",
".",
"Model",
",",
"models",
".",
"base",
".",
"ModelBase",
")",
")",
":",
"opts",
"=",
"obj",
".",
"_meta",
"elif",
"isinstance",
"(",
"obj",
",",
... | [
224,
0
] | [
241,
5
] | python | en | ['en', 'error', 'th'] | False |
model_ngettext | (obj, n=None) |
Return the appropriate `verbose_name` or `verbose_name_plural` value for
`obj` depending on the count `n`.
`obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance.
If `obj` is a `QuerySet` instance, `n` is optional and the length of the
`QuerySet` is used.
|
Return the appropriate `verbose_name` or `verbose_name_plural` value for
`obj` depending on the count `n`. | def model_ngettext(obj, n=None):
"""
Return the appropriate `verbose_name` or `verbose_name_plural` value for
`obj` depending on the count `n`.
`obj` may be a `Model` instance, `Model` subclass, or `QuerySet` instance.
If `obj` is a `QuerySet` instance, `n` is optional and the length of the
`Qu... | [
"def",
"model_ngettext",
"(",
"obj",
",",
"n",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"models",
".",
"query",
".",
"QuerySet",
")",
":",
"if",
"n",
"is",
"None",
":",
"n",
"=",
"obj",
".",
"count",
"(",
")",
"obj",
"=",
"ob... | [
244,
0
] | [
260,
46
] | python | en | ['en', 'error', 'th'] | False |
label_for_field | (name, model, model_admin=None, return_attr=False) |
Returns a sensible label for a field name. The name can be a callable,
property (but not created with @property decorator) or the name of an
object's attribute, as well as a genuine fields. If return_attr is
True, the resolved attribute (which could be a callable) is also returned.
This will be Non... |
Returns a sensible label for a field name. The name can be a callable,
property (but not created with | def label_for_field(name, model, model_admin=None, return_attr=False):
"""
Returns a sensible label for a field name. The name can be a callable,
property (but not created with @property decorator) or the name of an
object's attribute, as well as a genuine fields. If return_attr is
True, the resolve... | [
"def",
"label_for_field",
"(",
"name",
",",
"model",
",",
"model_admin",
"=",
"None",
",",
"return_attr",
"=",
"False",
")",
":",
"attr",
"=",
"None",
"try",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field_by_name",
"(",
"name",
")",
"[",
"0"... | [
292,
0
] | [
344,
20
] | python | en | ['en', 'error', 'th'] | False |
reverse_field_path | (model, path) | Create a reversed field path.
E.g. Given (Order, "user__groups"),
return (Group, "user__order").
Final field must be a related model, not a data field.
| Create a reversed field path. | def reverse_field_path(model, path):
""" Create a reversed field path.
E.g. Given (Order, "user__groups"),
return (Group, "user__order").
Final field must be a related model, not a data field.
"""
reversed_path = []
parent = model
pieces = path.split(LOOKUP_SEP)
for piece in piece... | [
"def",
"reverse_field_path",
"(",
"model",
",",
"path",
")",
":",
"reversed_path",
"=",
"[",
"]",
"parent",
"=",
"model",
"pieces",
"=",
"path",
".",
"split",
"(",
"LOOKUP_SEP",
")",
"for",
"piece",
"in",
"pieces",
":",
"field",
",",
"model",
",",
"dir... | [
413,
0
] | [
440,
51
] | python | en | ['en', 'co', 'en'] | True |
get_fields_from_path | (model, path) | Return list of Fields given path relative to model.
e.g. (ModelX, "user__groups__name") -> [
<django.db.models.fields.related.ForeignKey object at 0x...>,
<django.db.models.fields.related.ManyToManyField object at 0x...>,
<django.db.models.fields.CharField object at 0x...>,
]
| Return list of Fields given path relative to model. | def get_fields_from_path(model, path):
""" Return list of Fields given path relative to model.
e.g. (ModelX, "user__groups__name") -> [
<django.db.models.fields.related.ForeignKey object at 0x...>,
<django.db.models.fields.related.ManyToManyField object at 0x...>,
<django.db.models.fiel... | [
"def",
"get_fields_from_path",
"(",
"model",
",",
"path",
")",
":",
"pieces",
"=",
"path",
".",
"split",
"(",
"LOOKUP_SEP",
")",
"fields",
"=",
"[",
"]",
"for",
"piece",
"in",
"pieces",
":",
"if",
"fields",
":",
"parent",
"=",
"get_model_from_relation",
... | [
443,
0
] | [
460,
17
] | python | en | ['en', 'en', 'en'] | True |
remove_trailing_data_field | (fields) | Discard trailing non-relation field if extant. | Discard trailing non-relation field if extant. | def remove_trailing_data_field(fields):
""" Discard trailing non-relation field if extant. """
try:
get_model_from_relation(fields[-1])
except NotRelationField:
fields = fields[:-1]
return fields | [
"def",
"remove_trailing_data_field",
"(",
"fields",
")",
":",
"try",
":",
"get_model_from_relation",
"(",
"fields",
"[",
"-",
"1",
"]",
")",
"except",
"NotRelationField",
":",
"fields",
"=",
"fields",
"[",
":",
"-",
"1",
"]",
"return",
"fields"
] | [
463,
0
] | [
469,
17
] | python | en | ['en', 'en', 'en'] | True |
get_limit_choices_to_from_path | (model, path) | Return Q object for limiting choices if applicable.
If final model in path is linked via a ForeignKey or ManyToManyField which
has a ``limit_choices_to`` attribute, return it as a Q object.
| Return Q object for limiting choices if applicable. | def get_limit_choices_to_from_path(model, path):
""" Return Q object for limiting choices if applicable.
If final model in path is linked via a ForeignKey or ManyToManyField which
has a ``limit_choices_to`` attribute, return it as a Q object.
"""
fields = get_fields_from_path(model, path)
field... | [
"def",
"get_limit_choices_to_from_path",
"(",
"model",
",",
"path",
")",
":",
"fields",
"=",
"get_fields_from_path",
"(",
"model",
",",
"path",
")",
"fields",
"=",
"remove_trailing_data_field",
"(",
"fields",
")",
"get_limit_choices_to",
"=",
"(",
"fields",
"and",... | [
472,
0
] | [
489,
43
] | python | en | ['en', 'en', 'en'] | True |
NestedObjects.nested | (self, format_callback=None) |
Return the graph as a nested list.
|
Return the graph as a nested list. | def nested(self, format_callback=None):
"""
Return the graph as a nested list.
"""
seen = set()
roots = []
for root in self.edges.get(None, ()):
roots.extend(self._nested(root, seen, format_callback))
return roots | [
"def",
"nested",
"(",
"self",
",",
"format_callback",
"=",
"None",
")",
":",
"seen",
"=",
"set",
"(",
")",
"roots",
"=",
"[",
"]",
"for",
"root",
"in",
"self",
".",
"edges",
".",
"get",
"(",
"None",
",",
"(",
")",
")",
":",
"roots",
".",
"exten... | [
205,
4
] | [
214,
20
] | python | en | ['en', 'error', 'th'] | False |
NestedObjects.can_fast_delete | (self, *args, **kwargs) |
We always want to load the objects into memory so that we can display
them to the user in confirm page.
|
We always want to load the objects into memory so that we can display
them to the user in confirm page.
| def can_fast_delete(self, *args, **kwargs):
"""
We always want to load the objects into memory so that we can display
them to the user in confirm page.
"""
return False | [
"def",
"can_fast_delete",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"False"
] | [
216,
4
] | [
221,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseEmailBackend.open | (self) |
Open a network connection.
This method can be overwritten by backend implementations to
open a network connection.
It's up to the backend implementation to track the status of
a network connection if it's needed by the backend.
This method can be called by application... |
Open a network connection. | def open(self):
"""
Open a network connection.
This method can be overwritten by backend implementations to
open a network connection.
It's up to the backend implementation to track the status of
a network connection if it's needed by the backend.
This method c... | [
"def",
"open",
"(",
"self",
")",
":",
"pass"
] | [
19,
4
] | [
36,
12
] | python | en | ['en', 'error', 'th'] | False |
BaseEmailBackend.close | (self) | Close a network connection. | Close a network connection. | def close(self):
"""Close a network connection."""
pass | [
"def",
"close",
"(",
"self",
")",
":",
"pass"
] | [
38,
4
] | [
40,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseEmailBackend.send_messages | (self, email_messages) |
Send one or more EmailMessage objects and return the number of email
messages sent.
|
Send one or more EmailMessage objects and return the number of email
messages sent.
| def send_messages(self, email_messages):
"""
Send one or more EmailMessage objects and return the number of email
messages sent.
"""
raise NotImplementedError('subclasses of BaseEmailBackend must override send_messages() method') | [
"def",
"send_messages",
"(",
"self",
",",
"email_messages",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseEmailBackend must override send_messages() method'",
")"
] | [
53,
4
] | [
58,
104
] | python | en | ['en', 'error', 'th'] | False |
DatabaseValidation.check_field | (self, field, **kwargs) |
MySQL has the following field length restriction:
No character (varchar) fields can have a length exceeding 255
characters if they have a unique index on them.
|
MySQL has the following field length restriction:
No character (varchar) fields can have a length exceeding 255
characters if they have a unique index on them.
| def check_field(self, field, **kwargs):
"""
MySQL has the following field length restriction:
No character (varchar) fields can have a length exceeding 255
characters if they have a unique index on them.
"""
from django.db import connection
errors = super(Databas... | [
"def",
"check_field",
"(",
"self",
",",
"field",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"django",
".",
"db",
"import",
"connection",
"errors",
"=",
"super",
"(",
"DatabaseValidation",
",",
"self",
")",
".",
"check_field",
"(",
"field",
",",
"*",
"*... | [
5,
4
] | [
34,
21
] | python | en | ['en', 'error', 'th'] | False |
Queries1Tests.test_order_by_join_unref | (self) |
This test is related to the above one, testing that there aren't
old JOINs in the query.
|
This test is related to the above one, testing that there aren't
old JOINs in the query.
| def test_order_by_join_unref(self):
"""
This test is related to the above one, testing that there aren't
old JOINs in the query.
"""
qs = Celebrity.objects.order_by('greatest_fan__fan_of')
self.assertIn('OUTER JOIN', str(qs.query))
qs = qs.order_by('id')
s... | [
"def",
"test_order_by_join_unref",
"(",
"self",
")",
":",
"qs",
"=",
"Celebrity",
".",
"objects",
".",
"order_by",
"(",
"'greatest_fan__fan_of'",
")",
"self",
".",
"assertIn",
"(",
"'OUTER JOIN'",
",",
"str",
"(",
"qs",
".",
"query",
")",
")",
"qs",
"=",
... | [
268,
4
] | [
276,
53
] | python | en | ['en', 'error', 'th'] | False |
Queries1Tests.test_ticket17429 | (self) |
Ensure that Meta.ordering=None works the same as Meta.ordering=[]
|
Ensure that Meta.ordering=None works the same as Meta.ordering=[]
| def test_ticket17429(self):
"""
Ensure that Meta.ordering=None works the same as Meta.ordering=[]
"""
original_ordering = Tag._meta.ordering
Tag._meta.ordering = None
try:
self.assertQuerysetEqual(
Tag.objects.all(),
['<Tag: t1>... | [
"def",
"test_ticket17429",
"(",
"self",
")",
":",
"original_ordering",
"=",
"Tag",
".",
"_meta",
".",
"ordering",
"Tag",
".",
"_meta",
".",
"ordering",
"=",
"None",
"try",
":",
"self",
".",
"assertQuerysetEqual",
"(",
"Tag",
".",
"objects",
".",
"all",
"... | [
860,
4
] | [
873,
50
] | python | en | ['en', 'error', 'th'] | False |
CloneTests.test_evaluated_queryset_as_argument | (self) | #13227 -- If a queryset is already evaluated, it can still be used as a query arg | #13227 -- If a queryset is already evaluated, it can still be used as a query arg | def test_evaluated_queryset_as_argument(self):
"#13227 -- If a queryset is already evaluated, it can still be used as a query arg"
n = Note(note='Test1', misc='misc')
n.save()
e = ExtraInfo(info='good', note=n)
e.save()
n_list = Note.objects.all()
# Evaluate the ... | [
"def",
"test_evaluated_queryset_as_argument",
"(",
"self",
")",
":",
"n",
"=",
"Note",
"(",
"note",
"=",
"'Test1'",
",",
"misc",
"=",
"'misc'",
")",
"n",
".",
"save",
"(",
")",
"e",
"=",
"ExtraInfo",
"(",
"info",
"=",
"'good'",
",",
"note",
"=",
"n",... | [
2028,
4
] | [
2040,
83
] | python | en | ['en', 'en', 'en'] | True |
CloneTests.test_no_model_options_cloning | (self) |
Test that cloning a queryset does not get out of hand. While complete
testing is impossible, this is a sanity check against invalid use of
deepcopy. refs #16759.
|
Test that cloning a queryset does not get out of hand. While complete
testing is impossible, this is a sanity check against invalid use of
deepcopy. refs #16759.
| def test_no_model_options_cloning(self):
"""
Test that cloning a queryset does not get out of hand. While complete
testing is impossible, this is a sanity check against invalid use of
deepcopy. refs #16759.
"""
opts_class = type(Note._meta)
note_deepcopy = getattr... | [
"def",
"test_no_model_options_cloning",
"(",
"self",
")",
":",
"opts_class",
"=",
"type",
"(",
"Note",
".",
"_meta",
")",
"note_deepcopy",
"=",
"getattr",
"(",
"opts_class",
",",
"\"__deepcopy__\"",
",",
"None",
")",
"opts_class",
".",
"__deepcopy__",
"=",
"la... | [
2042,
4
] | [
2057,
55
] | python | en | ['en', 'error', 'th'] | False |
CloneTests.test_no_fields_cloning | (self) |
Test that cloning a queryset does not get out of hand. While complete
testing is impossible, this is a sanity check against invalid use of
deepcopy. refs #16759.
|
Test that cloning a queryset does not get out of hand. While complete
testing is impossible, this is a sanity check against invalid use of
deepcopy. refs #16759.
| def test_no_fields_cloning(self):
"""
Test that cloning a queryset does not get out of hand. While complete
testing is impossible, this is a sanity check against invalid use of
deepcopy. refs #16759.
"""
opts_class = type(Note._meta.get_field_by_name("misc")[0])
n... | [
"def",
"test_no_fields_cloning",
"(",
"self",
")",
":",
"opts_class",
"=",
"type",
"(",
"Note",
".",
"_meta",
".",
"get_field_by_name",
"(",
"\"misc\"",
")",
"[",
"0",
"]",
")",
"note_deepcopy",
"=",
"getattr",
"(",
"opts_class",
",",
"\"__deepcopy__\"",
","... | [
2059,
4
] | [
2074,
55
] | python | en | ['en', 'error', 'th'] | False |
QuerySetSupportsPythonIdioms.test_slicing_negative_indexing_not_supported_for_single_element | (self) | hint: inverting your ordering might do what you need | hint: inverting your ordering might do what you need | def test_slicing_negative_indexing_not_supported_for_single_element(self):
"""hint: inverting your ordering might do what you need"""
six.assertRaisesRegex(
self,
AssertionError,
"Negative indexing is not supported.",
lambda: Article.objects.all()[-1]
... | [
"def",
"test_slicing_negative_indexing_not_supported_for_single_element",
"(",
"self",
")",
":",
"six",
".",
"assertRaisesRegex",
"(",
"self",
",",
"AssertionError",
",",
"\"Negative indexing is not supported.\"",
",",
"lambda",
":",
"Article",
".",
"objects",
".",
"all",... | [
2282,
4
] | [
2289,
9
] | python | en | ['en', 'en', 'en'] | True |
QuerySetSupportsPythonIdioms.test_slicing_negative_indexing_not_supported_for_range | (self) | hint: inverting your ordering might do what you need | hint: inverting your ordering might do what you need | def test_slicing_negative_indexing_not_supported_for_range(self):
"""hint: inverting your ordering might do what you need"""
six.assertRaisesRegex(
self,
AssertionError,
"Negative indexing is not supported.",
lambda: Article.objects.all()[0:-5]
) | [
"def",
"test_slicing_negative_indexing_not_supported_for_range",
"(",
"self",
")",
":",
"six",
".",
"assertRaisesRegex",
"(",
"self",
",",
"AssertionError",
",",
"\"Negative indexing is not supported.\"",
",",
"lambda",
":",
"Article",
".",
"objects",
".",
"all",
"(",
... | [
2291,
4
] | [
2298,
9
] | 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 |
wait_for_write | (sock, timeout=None) | Waits for writing to be available on a given socket.
Returns True if the socket is readable, or False if the timeout expired.
| Waits for writing to be available on a given socket.
Returns True if the socket is readable, or False if the timeout expired.
| def wait_for_write(sock, timeout=None):
""" Waits for writing 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, write=True, timeout=timeout) | [
"def",
"wait_for_write",
"(",
"sock",
",",
"timeout",
"=",
"None",
")",
":",
"return",
"wait_for_socket",
"(",
"sock",
",",
"write",
"=",
"True",
",",
"timeout",
"=",
"timeout",
")"
] | [
148,
0
] | [
152,
61
] | python | en | ['en', 'en', 'en'] | True |
newer | (source, target) | Return true if 'source' exists and is more recently modified than
'target', or if 'source' exists and 'target' doesn't. Return false if
both exist and 'target' is the same age or younger than 'source'.
Raise DistutilsFileError if 'source' does not exist.
| Return true if 'source' exists and is more recently modified than
'target', or if 'source' exists and 'target' doesn't. Return false if
both exist and 'target' is the same age or younger than 'source'.
Raise DistutilsFileError if 'source' does not exist.
| def newer (source, target):
"""Return true if 'source' exists and is more recently modified than
'target', or if 'source' exists and 'target' doesn't. Return false if
both exist and 'target' is the same age or younger than 'source'.
Raise DistutilsFileError if 'source' does not exist.
"""
if no... | [
"def",
"newer",
"(",
"source",
",",
"target",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"source",
")",
":",
"raise",
"DistutilsFileError",
"(",
"\"file '%s' does not exist\"",
"%",
"os",
".",
"path",
".",
"abspath",
"(",
"source",
")"... | [
10,
0
] | [
26,
26
] | python | en | ['en', 'en', 'en'] | True |
newer_pairwise | (sources, targets) | Walk two filename lists in parallel, testing if each source is newer
than its corresponding target. Return a pair of lists (sources,
targets) where source is newer than target, according to the semantics
of 'newer()'.
| Walk two filename lists in parallel, testing if each source is newer
than its corresponding target. Return a pair of lists (sources,
targets) where source is newer than target, according to the semantics
of 'newer()'.
| def newer_pairwise (sources, targets):
"""Walk two filename lists in parallel, testing if each source is newer
than its corresponding target. Return a pair of lists (sources,
targets) where source is newer than target, according to the semantics
of 'newer()'.
"""
if len(sources) != len(targets)... | [
"def",
"newer_pairwise",
"(",
"sources",
",",
"targets",
")",
":",
"if",
"len",
"(",
"sources",
")",
"!=",
"len",
"(",
"targets",
")",
":",
"raise",
"ValueError",
"(",
"\"'sources' and 'targets' must be same length\"",
")",
"# build a pair of lists (sources, targets) ... | [
31,
0
] | [
48,
33
] | python | en | ['en', 'en', 'en'] | True |
newer_group | (sources, target, missing='error') | Return true if 'target' is out-of-date with respect to any file
listed in 'sources'. In other words, if 'target' exists and is newer
than every file in 'sources', return false; otherwise return true.
'missing' controls what we do when a source file is missing; the
default ("error") is to blow up with a... | Return true if 'target' is out-of-date with respect to any file
listed in 'sources'. In other words, if 'target' exists and is newer
than every file in 'sources', return false; otherwise return true.
'missing' controls what we do when a source file is missing; the
default ("error") is to blow up with a... | def newer_group (sources, target, missing='error'):
"""Return true if 'target' is out-of-date with respect to any file
listed in 'sources'. In other words, if 'target' exists and is newer
than every file in 'sources', return false; otherwise return true.
'missing' controls what we do when a source file... | [
"def",
"newer_group",
"(",
"sources",
",",
"target",
",",
"missing",
"=",
"'error'",
")",
":",
"# If the target doesn't even exist, then it's definitely out-of-date.",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"target",
")",
":",
"return",
"1",
"# Otherw... | [
53,
0
] | [
89,
16
] | python | en | ['en', 'en', 'en'] | True |
AdminSeleniumWebDriverTestCase.wait_until | (self, callback, timeout=10) |
Helper function that blocks the execution of the tests until the
specified callback returns a value that is not falsy. This function can
be called, for example, after clicking a link or submitting a form.
See the other public methods that call this function for more details.
|
Helper function that blocks the execution of the tests until the
specified callback returns a value that is not falsy. This function can
be called, for example, after clicking a link or submitting a form.
See the other public methods that call this function for more details.
| def wait_until(self, callback, timeout=10):
"""
Helper function that blocks the execution of the tests until the
specified callback returns a value that is not falsy. This function can
be called, for example, after clicking a link or submitting a form.
See the other public method... | [
"def",
"wait_until",
"(",
"self",
",",
"callback",
",",
"timeout",
"=",
"10",
")",
":",
"from",
"selenium",
".",
"webdriver",
".",
"support",
".",
"wait",
"import",
"WebDriverWait",
"WebDriverWait",
"(",
"self",
".",
"selenium",
",",
"timeout",
")",
".",
... | [
37,
4
] | [
45,
61
] | python | en | ['en', 'error', 'th'] | False |
AdminSeleniumWebDriverTestCase.wait_loaded_tag | (self, tag_name, timeout=10) |
Helper function that blocks until the element with the given tag name
is found on the page.
|
Helper function that blocks until the element with the given tag name
is found on the page.
| def wait_loaded_tag(self, tag_name, timeout=10):
"""
Helper function that blocks until the element with the given tag name
is found on the page.
"""
self.wait_for(tag_name, timeout) | [
"def",
"wait_loaded_tag",
"(",
"self",
",",
"tag_name",
",",
"timeout",
"=",
"10",
")",
":",
"self",
".",
"wait_for",
"(",
"tag_name",
",",
"timeout",
")"
] | [
47,
4
] | [
52,
40
] | python | en | ['en', 'error', 'th'] | False |
AdminSeleniumWebDriverTestCase.wait_for | (self, css_selector, timeout=10) |
Helper function that blocks until a CSS selector is found on the page.
|
Helper function that blocks until a CSS selector is found on the page.
| def wait_for(self, css_selector, timeout=10):
"""
Helper function that blocks until a CSS selector is found on the page.
"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
self.wait_until(
ec.presen... | [
"def",
"wait_for",
"(",
"self",
",",
"css_selector",
",",
"timeout",
"=",
"10",
")",
":",
"from",
"selenium",
".",
"webdriver",
".",
"common",
".",
"by",
"import",
"By",
"from",
"selenium",
".",
"webdriver",
".",
"support",
"import",
"expected_conditions",
... | [
54,
4
] | [
63,
9
] | python | en | ['en', 'error', 'th'] | False |
AdminSeleniumWebDriverTestCase.wait_for_text | (self, css_selector, text, timeout=10) |
Helper function that blocks until the text is found in the CSS selector.
|
Helper function that blocks until the text is found in the CSS selector.
| def wait_for_text(self, css_selector, text, timeout=10):
"""
Helper function that blocks until the text is found in the CSS selector.
"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
self.wait_until(
... | [
"def",
"wait_for_text",
"(",
"self",
",",
"css_selector",
",",
"text",
",",
"timeout",
"=",
"10",
")",
":",
"from",
"selenium",
".",
"webdriver",
".",
"common",
".",
"by",
"import",
"By",
"from",
"selenium",
".",
"webdriver",
".",
"support",
"import",
"e... | [
65,
4
] | [
75,
9
] | python | en | ['en', 'error', 'th'] | False |
AdminSeleniumWebDriverTestCase.wait_for_value | (self, css_selector, text, timeout=10) |
Helper function that blocks until the value is found in the CSS selector.
|
Helper function that blocks until the value is found in the CSS selector.
| def wait_for_value(self, css_selector, text, timeout=10):
"""
Helper function that blocks until the value is found in the CSS selector.
"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
self.wait_until(
... | [
"def",
"wait_for_value",
"(",
"self",
",",
"css_selector",
",",
"text",
",",
"timeout",
"=",
"10",
")",
":",
"from",
"selenium",
".",
"webdriver",
".",
"common",
".",
"by",
"import",
"By",
"from",
"selenium",
".",
"webdriver",
".",
"support",
"import",
"... | [
77,
4
] | [
87,
9
] | python | en | ['en', 'error', 'th'] | False |
AdminSeleniumWebDriverTestCase.wait_page_loaded | (self) |
Block until page has started to load.
|
Block until page has started to load.
| def wait_page_loaded(self):
"""
Block until page has started to load.
"""
from selenium.common.exceptions import TimeoutException
try:
# Wait for the next page to be loaded
self.wait_loaded_tag('body')
except TimeoutException:
# IE7 occ... | [
"def",
"wait_page_loaded",
"(",
"self",
")",
":",
"from",
"selenium",
".",
"common",
".",
"exceptions",
"import",
"TimeoutException",
"try",
":",
"# Wait for the next page to be loaded",
"self",
".",
"wait_loaded_tag",
"(",
"'body'",
")",
"except",
"TimeoutException",... | [
89,
4
] | [
101,
16
] | python | en | ['en', 'error', 'th'] | False |
AdminSeleniumWebDriverTestCase.admin_login | (self, username, password, login_url='/admin/') |
Helper function to log into the admin.
|
Helper function to log into the admin.
| def admin_login(self, username, password, login_url='/admin/'):
"""
Helper function to log into the admin.
"""
self.selenium.get('%s%s' % (self.live_server_url, login_url))
username_input = self.selenium.find_element_by_name('username')
username_input.send_keys(username)
... | [
"def",
"admin_login",
"(",
"self",
",",
"username",
",",
"password",
",",
"login_url",
"=",
"'/admin/'",
")",
":",
"self",
".",
"selenium",
".",
"get",
"(",
"'%s%s'",
"%",
"(",
"self",
".",
"live_server_url",
",",
"login_url",
")",
")",
"username_input",
... | [
103,
4
] | [
115,
31
] | python | en | ['en', 'error', 'th'] | False |
AdminSeleniumWebDriverTestCase.get_css_value | (self, selector, attribute) |
Helper function that returns the value for the CSS attribute of an
DOM element specified by the given selector. Uses the jQuery that ships
with Django.
|
Helper function that returns the value for the CSS attribute of an
DOM element specified by the given selector. Uses the jQuery that ships
with Django.
| def get_css_value(self, selector, attribute):
"""
Helper function that returns the value for the CSS attribute of an
DOM element specified by the given selector. Uses the jQuery that ships
with Django.
"""
return self.selenium.execute_script(
'return django.jQ... | [
"def",
"get_css_value",
"(",
"self",
",",
"selector",
",",
"attribute",
")",
":",
"return",
"self",
".",
"selenium",
".",
"execute_script",
"(",
"'return django.jQuery(\"%s\").css(\"%s\")'",
"%",
"(",
"selector",
",",
"attribute",
")",
")"
] | [
117,
4
] | [
124,
75
] | python | en | ['en', 'error', 'th'] | False |
AdminSeleniumWebDriverTestCase.get_select_option | (self, selector, value) |
Returns the <OPTION> with the value `value` inside the <SELECT> widget
identified by the CSS selector `selector`.
|
Returns the <OPTION> with the value `value` inside the <SELECT> widget
identified by the CSS selector `selector`.
| def get_select_option(self, selector, value):
"""
Returns the <OPTION> with the value `value` inside the <SELECT> widget
identified by the CSS selector `selector`.
"""
from selenium.common.exceptions import NoSuchElementException
options = self.selenium.find_elements_by_c... | [
"def",
"get_select_option",
"(",
"self",
",",
"selector",
",",
"value",
")",
":",
"from",
"selenium",
".",
"common",
".",
"exceptions",
"import",
"NoSuchElementException",
"options",
"=",
"self",
".",
"selenium",
".",
"find_elements_by_css_selector",
"(",
"'%s > o... | [
126,
4
] | [
136,
89
] | python | en | ['en', 'error', 'th'] | False |
AdminSeleniumWebDriverTestCase.assertSelectOptions | (self, selector, values) |
Asserts that the <SELECT> widget identified by `selector` has the
options with the given `values`.
|
Asserts that the <SELECT> widget identified by `selector` has the
options with the given `values`.
| def assertSelectOptions(self, selector, values):
"""
Asserts that the <SELECT> widget identified by `selector` has the
options with the given `values`.
"""
options = self.selenium.find_elements_by_css_selector('%s > option' % selector)
actual_values = []
for optio... | [
"def",
"assertSelectOptions",
"(",
"self",
",",
"selector",
",",
"values",
")",
":",
"options",
"=",
"self",
".",
"selenium",
".",
"find_elements_by_css_selector",
"(",
"'%s > option'",
"%",
"selector",
")",
"actual_values",
"=",
"[",
"]",
"for",
"option",
"in... | [
138,
4
] | [
147,
47
] | python | en | ['en', 'error', 'th'] | False |
AdminSeleniumWebDriverTestCase.has_css_class | (self, selector, klass) |
Returns True if the element identified by `selector` has the CSS class
`klass`.
|
Returns True if the element identified by `selector` has the CSS class
`klass`.
| def has_css_class(self, selector, klass):
"""
Returns True if the element identified by `selector` has the CSS class
`klass`.
"""
return (self.selenium.find_element_by_css_selector(selector)
.get_attribute('class').find(klass) != -1) | [
"def",
"has_css_class",
"(",
"self",
",",
"selector",
",",
"klass",
")",
":",
"return",
"(",
"self",
".",
"selenium",
".",
"find_element_by_css_selector",
"(",
"selector",
")",
".",
"get_attribute",
"(",
"'class'",
")",
".",
"find",
"(",
"klass",
")",
"!="... | [
149,
4
] | [
155,
58
] | python | en | ['en', 'error', 'th'] | False |
easter | (year, method=EASTER_WESTERN) |
This method was ported from the work done by GM Arts,
on top of the algorithm by Claus Tondering, which was
based in part on the algorithm of Ouding (1940), as
quoted in "Explanatory Supplement to the Astronomical
Almanac", P. Kenneth Seidelmann, editor.
This algorithm implements three differ... |
This method was ported from the work done by GM Arts,
on top of the algorithm by Claus Tondering, which was
based in part on the algorithm of Ouding (1940), as
quoted in "Explanatory Supplement to the Astronomical
Almanac", P. Kenneth Seidelmann, editor. | def easter(year, method=EASTER_WESTERN):
"""
This method was ported from the work done by GM Arts,
on top of the algorithm by Claus Tondering, which was
based in part on the algorithm of Ouding (1940), as
quoted in "Explanatory Supplement to the Astronomical
Almanac", P. Kenneth Seidelmann, edi... | [
"def",
"easter",
"(",
"year",
",",
"method",
"=",
"EASTER_WESTERN",
")",
":",
"if",
"not",
"(",
"1",
"<=",
"method",
"<=",
"3",
")",
":",
"raise",
"ValueError",
",",
"\"invalid method\"",
"# g - Golden year - 1",
"# c - Century",
"# h - (23 - Epact) mod 30",
"# ... | [
17,
0
] | [
90,
46
] | python | en | ['en', 'error', 'th'] | False |
get_flatpages | (parser, token) |
Retrieves all flatpage objects available for the current site and
visible to the specific user (or visible to all users if no user is
specified). Populates the template context with them in a variable
whose name is defined by the ``as`` clause.
An optional ``for`` clause can be used to control the... |
Retrieves all flatpage objects available for the current site and
visible to the specific user (or visible to all users if no user is
specified). Populates the template context with them in a variable
whose name is defined by the ``as`` clause. | def get_flatpages(parser, token):
"""
Retrieves all flatpage objects available for the current site and
visible to the specific user (or visible to all users if no user is
specified). Populates the template context with them in a variable
whose name is defined by the ``as`` clause.
An optional ... | [
"def",
"get_flatpages",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"syntax_message",
"=",
"(",
"\"%(tag_name)s expects a syntax of %(tag_name)s \"",
"\"['url_starts_with'] [for user] as context_name\"",
"%",
"dict",
"(",
... | [
46,
0
] | [
101,
58
] | python | en | ['en', 'error', 'th'] | False |
do_get_available_languages | (parser, token) |
Store a list of available languages in the context.
Usage::
{% get_available_languages as languages %}
{% for language in languages %}
...
{% endfor %}
This puts settings.LANGUAGES into the named variable.
|
Store a list of available languages in the context. | def do_get_available_languages(parser, token):
"""
Store a list of available languages in the context.
Usage::
{% get_available_languages as languages %}
{% for language in languages %}
...
{% endfor %}
This puts settings.LANGUAGES into the named variable.
"""
... | [
"def",
"do_get_available_languages",
"(",
"parser",
",",
"token",
")",
":",
"# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments",
"args",
"=",
"token",
".",
"contents",
".",
"split",
"(",
")",
"if",
"len",
"(",
"args",
")",
... | [
189,
0
] | [
206,
45
] | python | en | ['en', 'error', 'th'] | False |
do_get_language_info | (parser, token) |
Store the language information dictionary for the given language code in a
context variable.
Usage::
{% get_language_info for LANGUAGE_CODE as l %}
{{ l.code }}
{{ l.name }}
{{ l.name_translated }}
{{ l.name_local }}
{{ l.bidi|yesno:"bi-directional,uni-dire... |
Store the language information dictionary for the given language code in a
context variable. | def do_get_language_info(parser, token):
"""
Store the language information dictionary for the given language code in a
context variable.
Usage::
{% get_language_info for LANGUAGE_CODE as l %}
{{ l.code }}
{{ l.name }}
{{ l.name_translated }}
{{ l.name_local }}
... | [
"def",
"do_get_language_info",
"(",
"parser",
",",
"token",
")",
":",
"args",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"args",
")",
"!=",
"5",
"or",
"args",
"[",
"1",
"]",
"!=",
"'for'",
"or",
"args",
"[",
"3",
"]",
"!=",
... | [
210,
0
] | [
227,
71
] | python | en | ['en', 'error', 'th'] | False |
do_get_language_info_list | (parser, token) |
Store a list of language information dictionaries for the given language
codes in a context variable. The language codes can be specified either as
a list of strings or a settings.LANGUAGES style list (or any sequence of
sequences whose first items are language codes).
Usage::
{% get_lang... |
Store a list of language information dictionaries for the given language
codes in a context variable. The language codes can be specified either as
a list of strings or a settings.LANGUAGES style list (or any sequence of
sequences whose first items are language codes). | def do_get_language_info_list(parser, token):
"""
Store a list of language information dictionaries for the given language
codes in a context variable. The language codes can be specified either as
a list of strings or a settings.LANGUAGES style list (or any sequence of
sequences whose first items a... | [
"def",
"do_get_language_info_list",
"(",
"parser",
",",
"token",
")",
":",
"args",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"args",
")",
"!=",
"5",
"or",
"args",
"[",
"1",
"]",
"!=",
"'for'",
"or",
"args",
"[",
"3",
"]",
"!=... | [
231,
0
] | [
252,
75
] | python | en | ['en', 'error', 'th'] | False |
do_get_current_language | (parser, token) |
Store the current language in the context.
Usage::
{% get_current_language as language %}
This fetches the currently active language and puts its value into the
``language`` context variable.
|
Store the current language in the context. | def do_get_current_language(parser, token):
"""
Store the current language in the context.
Usage::
{% get_current_language as language %}
This fetches the currently active language and puts its value into the
``language`` context variable.
"""
# token.split_contents() isn't useful... | [
"def",
"do_get_current_language",
"(",
"parser",
",",
"token",
")",
":",
"# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments",
"args",
"=",
"token",
".",
"contents",
".",
"split",
"(",
")",
"if",
"len",
"(",
"args",
")",
"!=... | [
277,
0
] | [
292,
42
] | python | en | ['en', 'error', 'th'] | False |
do_get_current_language_bidi | (parser, token) |
Store the current language layout in the context.
Usage::
{% get_current_language_bidi as bidi %}
This fetches the currently active language's layout and puts its value into
the ``bidi`` context variable. True indicates right-to-left layout,
otherwise left-to-right.
|
Store the current language layout in the context. | def do_get_current_language_bidi(parser, token):
"""
Store the current language layout in the context.
Usage::
{% get_current_language_bidi as bidi %}
This fetches the currently active language's layout and puts its value into
the ``bidi`` context variable. True indicates right-to-left la... | [
"def",
"do_get_current_language_bidi",
"(",
"parser",
",",
"token",
")",
":",
"# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments",
"args",
"=",
"token",
".",
"contents",
".",
"split",
"(",
")",
"if",
"len",
"(",
"args",
")",
... | [
296,
0
] | [
312,
46
] | python | en | ['en', 'error', 'th'] | False |
do_translate | (parser, token) |
Mark a string for translation and translate the string for the current
language.
Usage::
{% trans "this is a test" %}
This marks the string for translation so it will be pulled out by
makemessages into the .po files and runs the string through the translation
engine.
There is a ... |
Mark a string for translation and translate the string for the current
language. | def do_translate(parser, token):
"""
Mark a string for translation and translate the string for the current
language.
Usage::
{% trans "this is a test" %}
This marks the string for translation so it will be pulled out by
makemessages into the .po files and runs the string through the ... | [
"def",
"do_translate",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
"<",
"2",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes at least one argument\"",
"%",
"bits",
"[",
... | [
316,
0
] | [
405,
70
] | python | en | ['en', 'error', 'th'] | False |
do_block_translate | (parser, token) |
Translate a block of text with parameters.
Usage::
{% blocktrans with bar=foo|filter boo=baz|filter %}
This is {{ bar }} and {{ boo }}.
{% endblocktrans %}
Additionally, this supports pluralization::
{% blocktrans count count=var|length %}
There is {{ count }} ob... |
Translate a block of text with parameters. | def do_block_translate(parser, token):
"""
Translate a block of text with parameters.
Usage::
{% blocktrans with bar=foo|filter boo=baz|filter %}
This is {{ bar }} and {{ boo }}.
{% endblocktrans %}
Additionally, this supports pluralization::
{% blocktrans count count... | [
"def",
"do_block_translate",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"options",
"=",
"{",
"}",
"remaining_bits",
"=",
"bits",
"[",
"1",
":",
"]",
"asvar",
"=",
"None",
"while",
"remaining_bits",
":",
... | [
409,
0
] | [
527,
42
] | python | en | ['en', 'error', 'th'] | False |
language | (parser, token) |
Enable the given language just for this block.
Usage::
{% language "de" %}
This is {{ bar }} and {{ boo }}.
{% endlanguage %}
|
Enable the given language just for this block. | def language(parser, token):
"""
Enable the given language just for this block.
Usage::
{% language "de" %}
This is {{ bar }} and {{ boo }}.
{% endlanguage %}
"""
bits = token.split_contents()
if len(bits) != 2:
raise TemplateSyntaxError("'%s' takes one argu... | [
"def",
"language",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"if",
"len",
"(",
"bits",
")",
"!=",
"2",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"'%s' takes one argument (language)\"",
"%",
"bits",
"[",
... | [
531,
0
] | [
547,
43
] | python | en | ['en', 'error', 'th'] | False |
test_confidence_report | () |
Test that we can make a confidence report, put an entry in it, and get
that entry back out
|
Test that we can make a confidence report, put an entry in it, and get
that entry back out
| def test_confidence_report():
"""
Test that we can make a confidence report, put an entry in it, and get
that entry back out
"""
report = ConfidenceReport()
entry = ConfidenceReportEntry(
correctness=np.array([True, False]), confidence=np.array([0.9, 0.1])
)
report["clean"] = ent... | [
"def",
"test_confidence_report",
"(",
")",
":",
"report",
"=",
"ConfidenceReport",
"(",
")",
"entry",
"=",
"ConfidenceReportEntry",
"(",
"correctness",
"=",
"np",
".",
"array",
"(",
"[",
"True",
",",
"False",
"]",
")",
",",
"confidence",
"=",
"np",
".",
... | [
19,
0
] | [
29,
35
] | python | en | ['en', 'error', 'th'] | False |
test_make_confidence_report_bundled | () |
A very simple test that just makes sure make_confidence_report_bundled can run without crashing
|
A very simple test that just makes sure make_confidence_report_bundled can run without crashing
| def test_make_confidence_report_bundled():
"""
A very simple test that just makes sure make_confidence_report_bundled can run without crashing
"""
sess = tf.Session()
try:
nb_classes = 3
nb_features = 2
batch_size = 5
nb_test_examples = batch_size * 2
layer =... | [
"def",
"test_make_confidence_report_bundled",
"(",
")",
":",
"sess",
"=",
"tf",
".",
"Session",
"(",
")",
"try",
":",
"nb_classes",
"=",
"3",
"nb_features",
"=",
"2",
"batch_size",
"=",
"5",
"nb_test_examples",
"=",
"batch_size",
"*",
"2",
"layer",
"=",
"L... | [
32,
0
] | [
94,
20
] | python | en | ['en', 'error', 'th'] | False |
test_save_load_confidence_report | () |
Test that a confidence report can be loaded and saved.
|
Test that a confidence report can be loaded and saved.
| def test_save_load_confidence_report():
"""
Test that a confidence report can be loaded and saved.
"""
report = ConfidenceReport()
num_examples = 2
clean_correctness = np.zeros((num_examples,), dtype=np.bool)
clean_confidence = np.zeros((num_examples,), dtype=np.float32)
adv_correctness ... | [
"def",
"test_save_load_confidence_report",
"(",
")",
":",
"report",
"=",
"ConfidenceReport",
"(",
")",
"num_examples",
"=",
"2",
"clean_correctness",
"=",
"np",
".",
"zeros",
"(",
"(",
"num_examples",
",",
")",
",",
"dtype",
"=",
"np",
".",
"bool",
")",
"c... | [
97,
0
] | [
112,
34
] | python | en | ['en', 'error', 'th'] | False |
Polygon.__init__ | (self, *args, **kwargs) |
Initialize on an exterior ring and a sequence of holes (both
instances may be either LinearRing instances, or a tuple/list
that may be constructed into a LinearRing).
Examples of initialization, where shell, hole1, and hole2 are
valid LinearRing geometries:
>>> from dja... |
Initialize on an exterior ring and a sequence of holes (both
instances may be either LinearRing instances, or a tuple/list
that may be constructed into a LinearRing). | def __init__(self, *args, **kwargs):
"""
Initialize on an exterior ring and a sequence of holes (both
instances may be either LinearRing instances, or a tuple/list
that may be constructed into a LinearRing).
Examples of initialization, where shell, hole1, and hole2 are
v... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"args",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"self",
".",
"_create_polygon",
"(",
"0",
",",
"None",
")",
",",
"*",
"*",
"kwargs",
")",
"r... | [
11,
4
] | [
46,
43
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.