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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ExFileObject.__iter__ | (self) | Get an iterator over the file's lines.
| Get an iterator over the file's lines.
| def __iter__(self):
"""Get an iterator over the file's lines.
"""
while True:
line = self.readline()
if not line:
break
yield line | [
"def",
"__iter__",
"(",
"self",
")",
":",
"while",
"True",
":",
"line",
"=",
"self",
".",
"readline",
"(",
")",
"if",
"not",
"line",
":",
"break",
"yield",
"line"
] | [
909,
4
] | [
916,
22
] | python | en | ['en', 'en', 'en'] | True |
TarInfo.__init__ | (self, name="") | Construct a TarInfo object. name is the optional name
of the member.
| Construct a TarInfo object. name is the optional name
of the member.
| def __init__(self, name=""):
"""Construct a TarInfo object. name is the optional name
of the member.
"""
self.name = name # member name
self.mode = 0o644 # file permissions
self.uid = 0 # user id
self.gid = 0 # group id
... | [
"def",
"__init__",
"(",
"self",
",",
"name",
"=",
"\"\"",
")",
":",
"self",
".",
"name",
"=",
"name",
"# member name",
"self",
".",
"mode",
"=",
"0o644",
"# file permissions",
"self",
".",
"uid",
"=",
"0",
"# user id",
"self",
".",
"gid",
"=",
"0",
"... | [
936,
4
] | [
958,
29
] | python | en | ['en', 'en', 'en'] | True |
TarInfo.get_info | (self) | Return the TarInfo's attributes as a dictionary.
| Return the TarInfo's attributes as a dictionary.
| def get_info(self):
"""Return the TarInfo's attributes as a dictionary.
"""
info = {
"name": self.name,
"mode": self.mode & 0o7777,
"uid": self.uid,
"gid": self.gid,
"size": self.size,
"mtime": self.... | [
"def",
"get_info",
"(",
"self",
")",
":",
"info",
"=",
"{",
"\"name\"",
":",
"self",
".",
"name",
",",
"\"mode\"",
":",
"self",
".",
"mode",
"&",
"0o7777",
",",
"\"uid\"",
":",
"self",
".",
"uid",
",",
"\"gid\"",
":",
"self",
".",
"gid",
",",
"\"... | [
977,
4
] | [
999,
19
] | python | en | ['en', 'en', 'en'] | True |
TarInfo.tobuf | (self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape") | Return a tar header as a string of 512 byte blocks.
| Return a tar header as a string of 512 byte blocks.
| def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"):
"""Return a tar header as a string of 512 byte blocks.
"""
info = self.get_info()
if format == USTAR_FORMAT:
return self.create_ustar_header(info, encoding, errors)
elif format == GN... | [
"def",
"tobuf",
"(",
"self",
",",
"format",
"=",
"DEFAULT_FORMAT",
",",
"encoding",
"=",
"ENCODING",
",",
"errors",
"=",
"\"surrogateescape\"",
")",
":",
"info",
"=",
"self",
".",
"get_info",
"(",
")",
"if",
"format",
"==",
"USTAR_FORMAT",
":",
"return",
... | [
1001,
4
] | [
1013,
46
] | python | en | ['en', 'cy', 'en'] | True |
TarInfo.create_ustar_header | (self, info, encoding, errors) | Return the object as a ustar header block.
| Return the object as a ustar header block.
| def create_ustar_header(self, info, encoding, errors):
"""Return the object as a ustar header block.
"""
info["magic"] = POSIX_MAGIC
if len(info["linkname"]) > LENGTH_LINK:
raise ValueError("linkname is too long")
if len(info["name"]) > LENGTH_NAME:
info... | [
"def",
"create_ustar_header",
"(",
"self",
",",
"info",
",",
"encoding",
",",
"errors",
")",
":",
"info",
"[",
"\"magic\"",
"]",
"=",
"POSIX_MAGIC",
"if",
"len",
"(",
"info",
"[",
"\"linkname\"",
"]",
")",
">",
"LENGTH_LINK",
":",
"raise",
"ValueError",
... | [
1015,
4
] | [
1026,
72
] | python | en | ['en', 'ga', 'en'] | True |
TarInfo.create_gnu_header | (self, info, encoding, errors) | Return the object as a GNU header block sequence.
| Return the object as a GNU header block sequence.
| def create_gnu_header(self, info, encoding, errors):
"""Return the object as a GNU header block sequence.
"""
info["magic"] = GNU_MAGIC
buf = b""
if len(info["linkname"]) > LENGTH_LINK:
buf += self._create_gnu_long_header(info["linkname"], GNUTYPE_LONGLINK, encoding,... | [
"def",
"create_gnu_header",
"(",
"self",
",",
"info",
",",
"encoding",
",",
"errors",
")",
":",
"info",
"[",
"\"magic\"",
"]",
"=",
"GNU_MAGIC",
"buf",
"=",
"b\"\"",
"if",
"len",
"(",
"info",
"[",
"\"linkname\"",
"]",
")",
">",
"LENGTH_LINK",
":",
"buf... | [
1028,
4
] | [
1040,
76
] | python | en | ['en', 'en', 'en'] | True |
TarInfo.create_pax_header | (self, info, encoding) | Return the object as a ustar header block. If it cannot be
represented this way, prepend a pax extended header sequence
with supplement information.
| Return the object as a ustar header block. If it cannot be
represented this way, prepend a pax extended header sequence
with supplement information.
| def create_pax_header(self, info, encoding):
"""Return the object as a ustar header block. If it cannot be
represented this way, prepend a pax extended header sequence
with supplement information.
"""
info["magic"] = POSIX_MAGIC
pax_headers = self.pax_headers.copy()... | [
"def",
"create_pax_header",
"(",
"self",
",",
"info",
",",
"encoding",
")",
":",
"info",
"[",
"\"magic\"",
"]",
"=",
"POSIX_MAGIC",
"pax_headers",
"=",
"self",
".",
"pax_headers",
".",
"copy",
"(",
")",
"# Test string fields for values that exceed the field length o... | [
1042,
4
] | [
1089,
80
] | python | en | ['en', 'en', 'en'] | True |
TarInfo.create_pax_global_header | (cls, pax_headers) | Return the object as a pax global header block sequence.
| Return the object as a pax global header block sequence.
| def create_pax_global_header(cls, pax_headers):
"""Return the object as a pax global header block sequence.
"""
return cls._create_pax_generic_header(pax_headers, XGLTYPE, "utf8") | [
"def",
"create_pax_global_header",
"(",
"cls",
",",
"pax_headers",
")",
":",
"return",
"cls",
".",
"_create_pax_generic_header",
"(",
"pax_headers",
",",
"XGLTYPE",
",",
"\"utf8\"",
")"
] | [
1092,
4
] | [
1095,
75
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._posix_split_name | (self, name) | Split a name longer than 100 chars into a prefix
and a name part.
| Split a name longer than 100 chars into a prefix
and a name part.
| def _posix_split_name(self, name):
"""Split a name longer than 100 chars into a prefix
and a name part.
"""
prefix = name[:LENGTH_PREFIX + 1]
while prefix and prefix[-1] != "/":
prefix = prefix[:-1]
name = name[len(prefix):]
prefix = prefix[:-1]
... | [
"def",
"_posix_split_name",
"(",
"self",
",",
"name",
")",
":",
"prefix",
"=",
"name",
"[",
":",
"LENGTH_PREFIX",
"+",
"1",
"]",
"while",
"prefix",
"and",
"prefix",
"[",
"-",
"1",
"]",
"!=",
"\"/\"",
":",
"prefix",
"=",
"prefix",
"[",
":",
"-",
"1"... | [
1097,
4
] | [
1110,
27
] | python | en | ['en', 'ht', 'en'] | True |
TarInfo._create_header | (info, format, encoding, errors) | Return a header block. info is a dictionary with file
information, format must be one of the *_FORMAT constants.
| Return a header block. info is a dictionary with file
information, format must be one of the *_FORMAT constants.
| def _create_header(info, format, encoding, errors):
"""Return a header block. info is a dictionary with file
information, format must be one of the *_FORMAT constants.
"""
parts = [
stn(info.get("name", ""), 100, encoding, errors),
itn(info.get("mode", 0) & 0o7... | [
"def",
"_create_header",
"(",
"info",
",",
"format",
",",
"encoding",
",",
"errors",
")",
":",
"parts",
"=",
"[",
"stn",
"(",
"info",
".",
"get",
"(",
"\"name\"",
",",
"\"\"",
")",
",",
"100",
",",
"encoding",
",",
"errors",
")",
",",
"itn",
"(",
... | [
1113,
4
] | [
1138,
18
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._create_payload | (payload) | Return the string payload filled with zero bytes
up to the next 512 byte border.
| Return the string payload filled with zero bytes
up to the next 512 byte border.
| def _create_payload(payload):
"""Return the string payload filled with zero bytes
up to the next 512 byte border.
"""
blocks, remainder = divmod(len(payload), BLOCKSIZE)
if remainder > 0:
payload += (BLOCKSIZE - remainder) * NUL
return payload | [
"def",
"_create_payload",
"(",
"payload",
")",
":",
"blocks",
",",
"remainder",
"=",
"divmod",
"(",
"len",
"(",
"payload",
")",
",",
"BLOCKSIZE",
")",
"if",
"remainder",
">",
"0",
":",
"payload",
"+=",
"(",
"BLOCKSIZE",
"-",
"remainder",
")",
"*",
"NUL... | [
1141,
4
] | [
1148,
22
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._create_gnu_long_header | (cls, name, type, encoding, errors) | Return a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence
for name.
| Return a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence
for name.
| def _create_gnu_long_header(cls, name, type, encoding, errors):
"""Return a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence
for name.
"""
name = name.encode(encoding, errors) + NUL
info = {}
info["name"] = "././@LongLink"
info["type"] = type
info["size"]... | [
"def",
"_create_gnu_long_header",
"(",
"cls",
",",
"name",
",",
"type",
",",
"encoding",
",",
"errors",
")",
":",
"name",
"=",
"name",
".",
"encode",
"(",
"encoding",
",",
"errors",
")",
"+",
"NUL",
"info",
"=",
"{",
"}",
"info",
"[",
"\"name\"",
"]"... | [
1151,
4
] | [
1165,
41
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._create_pax_generic_header | (cls, pax_headers, type, encoding) | Return a POSIX.1-2008 extended or global header sequence
that contains a list of keyword, value pairs. The values
must be strings.
| Return a POSIX.1-2008 extended or global header sequence
that contains a list of keyword, value pairs. The values
must be strings.
| def _create_pax_generic_header(cls, pax_headers, type, encoding):
"""Return a POSIX.1-2008 extended or global header sequence
that contains a list of keyword, value pairs. The values
must be strings.
"""
# Check if one of the fields contains surrogate characters and thereby... | [
"def",
"_create_pax_generic_header",
"(",
"cls",
",",
"pax_headers",
",",
"type",
",",
"encoding",
")",
":",
"# Check if one of the fields contains surrogate characters and thereby",
"# forces hdrcharset=BINARY, see _proc_pax() for more information.",
"binary",
"=",
"False",
"for",... | [
1168,
4
] | [
1216,
44
] | python | en | ['en', 'en', 'en'] | True |
TarInfo.frombuf | (cls, buf, encoding, errors) | Construct a TarInfo object from a 512 byte bytes object.
| Construct a TarInfo object from a 512 byte bytes object.
| def frombuf(cls, buf, encoding, errors):
"""Construct a TarInfo object from a 512 byte bytes object.
"""
if len(buf) == 0:
raise EmptyHeaderError("empty header")
if len(buf) != BLOCKSIZE:
raise TruncatedHeaderError("truncated header")
if buf.count(NUL) == ... | [
"def",
"frombuf",
"(",
"cls",
",",
"buf",
",",
"encoding",
",",
"errors",
")",
":",
"if",
"len",
"(",
"buf",
")",
"==",
"0",
":",
"raise",
"EmptyHeaderError",
"(",
"\"empty header\"",
")",
"if",
"len",
"(",
"buf",
")",
"!=",
"BLOCKSIZE",
":",
"raise"... | [
1219,
4
] | [
1279,
18
] | python | en | ['en', 'en', 'en'] | True |
TarInfo.fromtarfile | (cls, tarfile) | Return the next TarInfo object from TarFile object
tarfile.
| Return the next TarInfo object from TarFile object
tarfile.
| def fromtarfile(cls, tarfile):
"""Return the next TarInfo object from TarFile object
tarfile.
"""
buf = tarfile.fileobj.read(BLOCKSIZE)
obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
obj.offset = tarfile.fileobj.tell() - BLOCKSIZE
return obj._proc_mem... | [
"def",
"fromtarfile",
"(",
"cls",
",",
"tarfile",
")",
":",
"buf",
"=",
"tarfile",
".",
"fileobj",
".",
"read",
"(",
"BLOCKSIZE",
")",
"obj",
"=",
"cls",
".",
"frombuf",
"(",
"buf",
",",
"tarfile",
".",
"encoding",
",",
"tarfile",
".",
"errors",
")",... | [
1282,
4
] | [
1289,
40
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._proc_member | (self, tarfile) | Choose the right processing method depending on
the type and call it.
| Choose the right processing method depending on
the type and call it.
| def _proc_member(self, tarfile):
"""Choose the right processing method depending on
the type and call it.
"""
if self.type in (GNUTYPE_LONGNAME, GNUTYPE_LONGLINK):
return self._proc_gnulong(tarfile)
elif self.type == GNUTYPE_SPARSE:
return self._proc_sp... | [
"def",
"_proc_member",
"(",
"self",
",",
"tarfile",
")",
":",
"if",
"self",
".",
"type",
"in",
"(",
"GNUTYPE_LONGNAME",
",",
"GNUTYPE_LONGLINK",
")",
":",
"return",
"self",
".",
"_proc_gnulong",
"(",
"tarfile",
")",
"elif",
"self",
".",
"type",
"==",
"GN... | [
1302,
4
] | [
1313,
46
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._proc_builtin | (self, tarfile) | Process a builtin type or an unknown type which
will be treated as a regular file.
| Process a builtin type or an unknown type which
will be treated as a regular file.
| def _proc_builtin(self, tarfile):
"""Process a builtin type or an unknown type which
will be treated as a regular file.
"""
self.offset_data = tarfile.fileobj.tell()
offset = self.offset_data
if self.isreg() or self.type not in SUPPORTED_TYPES:
# Skip the f... | [
"def",
"_proc_builtin",
"(",
"self",
",",
"tarfile",
")",
":",
"self",
".",
"offset_data",
"=",
"tarfile",
".",
"fileobj",
".",
"tell",
"(",
")",
"offset",
"=",
"self",
".",
"offset_data",
"if",
"self",
".",
"isreg",
"(",
")",
"or",
"self",
".",
"typ... | [
1315,
4
] | [
1330,
19
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._proc_gnulong | (self, tarfile) | Process the blocks that hold a GNU longname
or longlink member.
| Process the blocks that hold a GNU longname
or longlink member.
| def _proc_gnulong(self, tarfile):
"""Process the blocks that hold a GNU longname
or longlink member.
"""
buf = tarfile.fileobj.read(self._block(self.size))
# Fetch the next header and process it.
try:
next = self.fromtarfile(tarfile)
except HeaderE... | [
"def",
"_proc_gnulong",
"(",
"self",
",",
"tarfile",
")",
":",
"buf",
"=",
"tarfile",
".",
"fileobj",
".",
"read",
"(",
"self",
".",
"_block",
"(",
"self",
".",
"size",
")",
")",
"# Fetch the next header and process it.",
"try",
":",
"next",
"=",
"self",
... | [
1332,
4
] | [
1352,
19
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._proc_sparse | (self, tarfile) | Process a GNU sparse header plus extra headers.
| Process a GNU sparse header plus extra headers.
| def _proc_sparse(self, tarfile):
"""Process a GNU sparse header plus extra headers.
"""
# We already collected some sparse structures in frombuf().
structs, isextended, origsize = self._sparse_structs
del self._sparse_structs
# Collect sparse structures from extended hea... | [
"def",
"_proc_sparse",
"(",
"self",
",",
"tarfile",
")",
":",
"# We already collected some sparse structures in frombuf().",
"structs",
",",
"isextended",
",",
"origsize",
"=",
"self",
".",
"_sparse_structs",
"del",
"self",
".",
"_sparse_structs",
"# Collect sparse struct... | [
1354,
4
] | [
1380,
19
] | python | en | ['en', 'en', 'en'] | True |
TarInfo._proc_pax | (self, tarfile) | Process an extended or global header as described in
POSIX.1-2008.
| Process an extended or global header as described in
POSIX.1-2008.
| def _proc_pax(self, tarfile):
"""Process an extended or global header as described in
POSIX.1-2008.
"""
# Read the header information.
buf = tarfile.fileobj.read(self._block(self.size))
# A pax header stores supplemental information for either
# the following ... | [
"def",
"_proc_pax",
"(",
"self",
",",
"tarfile",
")",
":",
"# Read the header information.",
"buf",
"=",
"tarfile",
".",
"fileobj",
".",
"read",
"(",
"self",
".",
"_block",
"(",
"self",
".",
"size",
")",
")",
"# A pax header stores supplemental information for eit... | [
1382,
4
] | [
1482,
19
] | python | en | ['en', 'en', 'en'] | True |
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 |
TestOutgoingWebhookMessaging.test_empty_string_json_as_response_to_outgoing_webhook_request | (self) |
Verifies that if the response to the request triggered by mentioning the bot
is the json representation of the empty string, the outcome is the same
as {"response_not_required": True} - since this behavior is kept for
backwards-compatibility.
|
Verifies that if the response to the request triggered by mentioning the bot
is the json representation of the empty string, the outcome is the same
as {"response_not_required": True} - since this behavior is kept for
backwards-compatibility.
| def test_empty_string_json_as_response_to_outgoing_webhook_request(self) -> None:
"""
Verifies that if the response to the request triggered by mentioning the bot
is the json representation of the empty string, the outcome is the same
as {"response_not_required": True} - since this behav... | [
"def",
"test_empty_string_json_as_response_to_outgoing_webhook_request",
"(",
"self",
")",
"->",
"None",
":",
"bot_owner",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"bot",
"=",
"self",
".",
"create_outgoing_bot",
"(",
"bot_owner",
")",
"responses",
... | [
514,
4
] | [
543,
60
] | python | en | ['en', 'error', 'th'] | False |
prepare_activation_url | (
email: str,
request: HttpRequest,
realm_creation: bool = False,
streams: Optional[List[Stream]] = None,
invited_as: Optional[int] = None,
) |
Send an email with a confirmation link to the provided e-mail so the user
can complete their registration.
|
Send an email with a confirmation link to the provided e-mail so the user
can complete their registration.
| def prepare_activation_url(
email: str,
request: HttpRequest,
realm_creation: bool = False,
streams: Optional[List[Stream]] = None,
invited_as: Optional[int] = None,
) -> str:
"""
Send an email with a confirmation link to the provided e-mail so the user
can complete their registration.
... | [
"def",
"prepare_activation_url",
"(",
"email",
":",
"str",
",",
"request",
":",
"HttpRequest",
",",
"realm_creation",
":",
"bool",
"=",
"False",
",",
"streams",
":",
"Optional",
"[",
"List",
"[",
"Stream",
"]",
"]",
"=",
"None",
",",
"invited_as",
":",
"... | [
498,
0
] | [
525,
25
] | python | en | ['en', 'error', 'th'] | False |
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 |
SearchScope.create | (
cls,
find_links, # type: List[str]
index_urls, # type: List[str]
) |
Create a SearchScope object after normalizing the `find_links`.
|
Create a SearchScope object after normalizing the `find_links`.
| def create(
cls,
find_links, # type: List[str]
index_urls, # type: List[str]
):
# type: (...) -> SearchScope
"""
Create a SearchScope object after normalizing the `find_links`.
"""
# Build find_links. If an argument starts with ~, it may be
#... | [
"def",
"create",
"(",
"cls",
",",
"find_links",
",",
"# type: List[str]",
"index_urls",
",",
"# type: List[str]",
")",
":",
"# type: (...) -> SearchScope",
"# Build find_links. If an argument starts with ~, it may be",
"# a local file relative to a home directory. So try normalizing",
... | [
29,
4
] | [
67,
9
] | python | en | ['en', 'error', 'th'] | False |
SearchScope.get_index_urls_locations | (self, project_name) | Returns the locations found via self.index_urls
Checks the url_name on the main (first in the list) index and
use this url_name to produce all locations
| Returns the locations found via self.index_urls | def get_index_urls_locations(self, project_name):
# type: (str) -> List[str]
"""Returns the locations found via self.index_urls
Checks the url_name on the main (first in the list) index and
use this url_name to produce all locations
"""
def mkurl_pypi_url(url):
... | [
"def",
"get_index_urls_locations",
"(",
"self",
",",
"project_name",
")",
":",
"# type: (str) -> List[str]",
"def",
"mkurl_pypi_url",
"(",
"url",
")",
":",
"# type: (str) -> str",
"loc",
"=",
"posixpath",
".",
"join",
"(",
"url",
",",
"urllib_parse",
".",
"quote",... | [
112,
4
] | [
134,
63
] | python | en | ['en', 'la', '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 |
get_microversion_for_features | (service, features, wrapper_class,
min_ver, max_ver) | Retrieves that highest known functional microversion for features | Retrieves that highest known functional microversion for features | def get_microversion_for_features(service, features, wrapper_class,
min_ver, max_ver):
"""Retrieves that highest known functional microversion for features"""
feature_versions = get_requested_versions(service, features)
if not feature_versions:
return None
for ... | [
"def",
"get_microversion_for_features",
"(",
"service",
",",
"features",
",",
"wrapper_class",
",",
"min_ver",
",",
"max_ver",
")",
":",
"feature_versions",
"=",
"get_requested_versions",
"(",
"service",
",",
"features",
")",
"if",
"not",
"feature_versions",
":",
... | [
84,
0
] | [
95,
15
] | python | en | ['en', 'en', 'en'] | True |
UpdateProject._update_project | (self, request, data) | Update project info | Update project info | def _update_project(self, request, data):
"""Update project info"""
domain_id = identity.get_domain_id_for_operation(request)
try:
project_id = data['project_id']
# add extra information
if keystone.VERSIONS.active >= 3:
EXTRA_INFO = settings.... | [
"def",
"_update_project",
"(",
"self",
",",
"request",
",",
"data",
")",
":",
"domain_id",
"=",
"identity",
".",
"get_domain_id_for_operation",
"(",
"request",
")",
"try",
":",
"project_id",
"=",
"data",
"[",
"'project_id'",
"]",
"# add extra information",
"if",... | [
680,
4
] | [
708,
18
] | python | en | ['en', 'en', 'en'] | True |
Doctor.examine | (self, root) |
Examine and repair the schema (if necessary).
@param root: A schema root element.
@type root: L{Element}
|
Examine and repair the schema (if necessary).
| def examine(self, root):
"""
Examine and repair the schema (if necessary).
@param root: A schema root element.
@type root: L{Element}
"""
pass | [
"def",
"examine",
"(",
"self",
",",
"root",
")",
":",
"pass"
] | [
33,
4
] | [
39,
12
] | python | en | ['en', 'error', 'th'] | False |
Practice.add | (self, doctor) |
Add a doctor to the practice
@param doctor: A doctor to add.
@type doctor: L{Doctor}
|
Add a doctor to the practice
| def add(self, doctor):
"""
Add a doctor to the practice
@param doctor: A doctor to add.
@type doctor: L{Doctor}
"""
self.doctors.append(doctor) | [
"def",
"add",
"(",
"self",
",",
"doctor",
")",
":",
"self",
".",
"doctors",
".",
"append",
"(",
"doctor",
")"
] | [
52,
4
] | [
58,
35
] | python | en | ['en', 'error', 'th'] | False |
TnsFilter.__init__ | (self, *tns) |
@param tns: A list of target namespaces.
@type tns: [str,...]
| def __init__(self, *tns):
"""
@param tns: A list of target namespaces.
@type tns: [str,...]
"""
self.tns = []
self.add(*tns) | [
"def",
"__init__",
"(",
"self",
",",
"*",
"tns",
")",
":",
"self",
".",
"tns",
"=",
"[",
"]",
"self",
".",
"add",
"(",
"*",
"tns",
")"
] | [
73,
4
] | [
79,
22
] | python | en | ['en', 'error', 'th'] | False | |
TnsFilter.add | (self, *tns) |
Add I{targetNamesapces} to be added.
@param tns: A list of target namespaces.
@type tns: [str,...]
|
Add I{targetNamesapces} to be added.
| def add(self, *tns):
"""
Add I{targetNamesapces} to be added.
@param tns: A list of target namespaces.
@type tns: [str,...]
"""
self.tns += tns | [
"def",
"add",
"(",
"self",
",",
"*",
"tns",
")",
":",
"self",
".",
"tns",
"+=",
"tns"
] | [
81,
4
] | [
87,
23
] | python | en | ['en', 'error', 'th'] | False |
TnsFilter.match | (self, root, ns) |
Match by I{targetNamespace} excluding those that
are equal to the specified namespace to prevent
adding an import to itself.
@param root: A schema root.
@type root: L{Element}
|
Match by I{targetNamespace} excluding those that
are equal to the specified namespace to prevent
adding an import to itself.
| def match(self, root, ns):
"""
Match by I{targetNamespace} excluding those that
are equal to the specified namespace to prevent
adding an import to itself.
@param root: A schema root.
@type root: L{Element}
"""
tns = root.get('targetNamespace')
if ... | [
"def",
"match",
"(",
"self",
",",
"root",
",",
"ns",
")",
":",
"tns",
"=",
"root",
".",
"get",
"(",
"'targetNamespace'",
")",
"if",
"len",
"(",
"self",
".",
"tns",
")",
":",
"matched",
"=",
"(",
"tns",
"in",
"self",
".",
"tns",
")",
"else",
":"... | [
89,
4
] | [
103,
41
] | python | en | ['en', 'error', 'th'] | False |
Import.__init__ | (self, ns, location=None) |
@param ns: An import namespace.
@type ns: str
@param location: An optional I{schemaLocation}.
@type location: str
| def __init__(self, ns, location=None):
"""
@param ns: An import namespace.
@type ns: str
@param location: An optional I{schemaLocation}.
@type location: str
"""
self.ns = ns
self.location = location
self.filter = TnsFilter() | [
"def",
"__init__",
"(",
"self",
",",
"ns",
",",
"location",
"=",
"None",
")",
":",
"self",
".",
"ns",
"=",
"ns",
"self",
".",
"location",
"=",
"location",
"self",
".",
"filter",
"=",
"TnsFilter",
"(",
")"
] | [
122,
4
] | [
131,
33
] | python | en | ['en', 'error', 'th'] | False | |
Import.setfilter | (self, filter) |
Set the filter.
@param filter: A filter to set.
@type filter: L{TnsFilter}
|
Set the filter.
| def setfilter(self, filter):
"""
Set the filter.
@param filter: A filter to set.
@type filter: L{TnsFilter}
"""
self.filter = filter | [
"def",
"setfilter",
"(",
"self",
",",
"filter",
")",
":",
"self",
".",
"filter",
"=",
"filter"
] | [
133,
4
] | [
139,
28
] | python | en | ['en', 'error', 'th'] | False |
Import.apply | (self, root) |
Apply the import (rule) to the specified schema.
If the schema does not already contain an import for the
I{namespace} specified here, it is added.
@param root: A schema root.
@type root: L{Element}
|
Apply the import (rule) to the specified schema.
If the schema does not already contain an import for the
I{namespace} specified here, it is added.
| def apply(self, root):
"""
Apply the import (rule) to the specified schema.
If the schema does not already contain an import for the
I{namespace} specified here, it is added.
@param root: A schema root.
@type root: L{Element}
"""
if not self.filter.match(r... | [
"def",
"apply",
"(",
"self",
",",
"root",
")",
":",
"if",
"not",
"self",
".",
"filter",
".",
"match",
"(",
"root",
",",
"self",
".",
"ns",
")",
":",
"return",
"if",
"self",
".",
"exists",
"(",
"root",
")",
":",
"return",
"node",
"=",
"Element",
... | [
141,
4
] | [
158,
25
] | python | en | ['en', 'error', 'th'] | False |
Import.add | (self, root) |
Add an <xs:import/> to the specified schema root.
@param root: A schema root.
@type root: L{Element}
|
Add an <xs:import/> to the specified schema root.
| def add(self, root):
"""
Add an <xs:import/> to the specified schema root.
@param root: A schema root.
@type root: L{Element}
"""
node = Element('import', ns=self.xsdns)
node.set('namespace', self.ns)
if self.location is not None:
node.set('sch... | [
"def",
"add",
"(",
"self",
",",
"root",
")",
":",
"node",
"=",
"Element",
"(",
"'import'",
",",
"ns",
"=",
"self",
".",
"xsdns",
")",
"node",
".",
"set",
"(",
"'namespace'",
",",
"self",
".",
"ns",
")",
"if",
"self",
".",
"location",
"is",
"not",... | [
160,
4
] | [
171,
25
] | python | en | ['en', 'error', 'th'] | False |
Import.exists | (self, root) |
Check to see if the <xs:import/> already exists
in the specified schema root by matching I{namesapce}.
@param root: A schema root.
@type root: L{Element}
|
Check to see if the <xs:import/> already exists
in the specified schema root by matching I{namesapce}.
| def exists(self, root):
"""
Check to see if the <xs:import/> already exists
in the specified schema root by matching I{namesapce}.
@param root: A schema root.
@type root: L{Element}
"""
for node in root.children:
if node.name != 'import':
... | [
"def",
"exists",
"(",
"self",
",",
"root",
")",
":",
"for",
"node",
"in",
"root",
".",
"children",
":",
"if",
"node",
".",
"name",
"!=",
"'import'",
":",
"continue",
"ns",
"=",
"node",
".",
"get",
"(",
"'namespace'",
")",
"if",
"self",
".",
"ns",
... | [
173,
4
] | [
186,
16
] | python | en | ['en', 'error', 'th'] | False |
ImportDoctor.add | (self, *imports) |
Add a namesapce to be checked.
@param imports: A list of L{Import} objects.
@type imports: [L{Import},..]
|
Add a namesapce to be checked.
| def add(self, *imports):
"""
Add a namesapce to be checked.
@param imports: A list of L{Import} objects.
@type imports: [L{Import},..]
"""
self.imports += imports | [
"def",
"add",
"(",
"self",
",",
"*",
"imports",
")",
":",
"self",
".",
"imports",
"+=",
"imports"
] | [
202,
4
] | [
208,
31
] | python | en | ['en', 'error', 'th'] | False |
get_cache_with_key | (
keyfunc: Callable[..., str],
cache_name: Optional[str] = None,
) |
The main goal of this function getting value from the cache like in the "cache_with_key".
A cache value can contain any data including the "None", so
here used exception for case if value isn't found in the cache.
|
The main goal of this function getting value from the cache like in the "cache_with_key".
A cache value can contain any data including the "None", so
here used exception for case if value isn't found in the cache.
| def get_cache_with_key(
keyfunc: Callable[..., str],
cache_name: Optional[str] = None,
) -> Callable[[FuncT], FuncT]:
"""
The main goal of this function getting value from the cache like in the "cache_with_key".
A cache value can contain any data including the "None", so
here used exception for ... | [
"def",
"get_cache_with_key",
"(",
"keyfunc",
":",
"Callable",
"[",
"...",
",",
"str",
"]",
",",
"cache_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
"->",
"Callable",
"[",
"[",
"FuncT",
"]",
",",
"FuncT",
"]",
":",
"def",
"decorator... | [
131,
0
] | [
158,
20
] | python | en | ['en', 'error', 'th'] | False |
cache_with_key | (
keyfunc: Callable[..., str],
cache_name: Optional[str] = None,
timeout: Optional[int] = None,
with_statsd_key: Optional[str] = None,
) | Decorator which applies Django caching to a function.
Decorator argument is a function which computes a cache key
from the original function's arguments. You are responsible
for avoiding collisions with other uses of this decorator or
other uses of caching. | Decorator which applies Django caching to a function. | def cache_with_key(
keyfunc: Callable[..., str],
cache_name: Optional[str] = None,
timeout: Optional[int] = None,
with_statsd_key: Optional[str] = None,
) -> Callable[[FuncT], FuncT]:
"""Decorator which applies Django caching to a function.
Decorator argument is a function which computes a cach... | [
"def",
"cache_with_key",
"(",
"keyfunc",
":",
"Callable",
"[",
"...",
",",
"str",
"]",
",",
"cache_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"timeout",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"with_statsd_key",
":",
"Option... | [
161,
0
] | [
211,
20
] | python | en | ['en', 'en', 'en'] | True |
safe_cache_get_many | (keys: List[str], cache_name: Optional[str] = None) | Variant of cache_get_many that drops any keys that fail
validation, rather than throwing an exception visible to the
caller. | Variant of cache_get_many that drops any keys that fail
validation, rather than throwing an exception visible to the
caller. | def safe_cache_get_many(keys: List[str], cache_name: Optional[str] = None) -> Dict[str, Any]:
"""Variant of cache_get_many that drops any keys that fail
validation, rather than throwing an exception visible to the
caller."""
try:
# Almost always the keys will all be correct, so we just try
... | [
"def",
"safe_cache_get_many",
"(",
"keys",
":",
"List",
"[",
"str",
"]",
",",
"cache_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"try",
":",
"# Almost always the keys will all be correct, so we j... | [
277,
0
] | [
291,
52
] | python | en | ['en', 'en', 'en'] | True |
safe_cache_set_many | (
items: Dict[str, Any], cache_name: Optional[str] = None, timeout: Optional[int] = None
) | Variant of cache_set_many that drops saving any keys that fail
validation, rather than throwing an exception visible to the
caller. | Variant of cache_set_many that drops saving any keys that fail
validation, rather than throwing an exception visible to the
caller. | def safe_cache_set_many(
items: Dict[str, Any], cache_name: Optional[str] = None, timeout: Optional[int] = None
) -> None:
"""Variant of cache_set_many that drops saving any keys that fail
validation, rather than throwing an exception visible to the
caller."""
try:
# Almost always the keys w... | [
"def",
"safe_cache_set_many",
"(",
"items",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"cache_name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"timeout",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
"->",
"None",
":",
"try",
":... | [
308,
0
] | [
326,
62
] | python | en | ['en', 'en', 'en'] | True |
ignore_unhashable_lru_cache | (
maxsize: int = 128, typed: bool = False
) |
This is a wrapper over lru_cache function. It adds following features on
top of lru_cache:
* It will not cache result of functions with unhashable arguments.
* It will clear cache whenever zerver.lib.cache.KEY_PREFIX changes.
|
This is a wrapper over lru_cache function. It adds following features on
top of lru_cache: | def ignore_unhashable_lru_cache(
maxsize: int = 128, typed: bool = False
) -> Callable[[FuncT], FuncT]:
"""
This is a wrapper over lru_cache function. It adds following features on
top of lru_cache:
* It will not cache result of functions with unhashable arguments.
* It will clear cache... | [
"def",
"ignore_unhashable_lru_cache",
"(",
"maxsize",
":",
"int",
"=",
"128",
",",
"typed",
":",
"bool",
"=",
"False",
")",
"->",
"Callable",
"[",
"[",
"FuncT",
"]",
",",
"FuncT",
"]",
":",
"internal_decorator",
"=",
"lru_cache",
"(",
"maxsize",
"=",
"ma... | [
747,
0
] | [
795,
20
] | python | en | ['en', 'error', 'th'] | False |
dict_to_items_tuple | (user_function: Callable[..., Any]) | Wrapper that converts any dict args to dict item tuples. | Wrapper that converts any dict args to dict item tuples. | def dict_to_items_tuple(user_function: Callable[..., Any]) -> Callable[..., Any]:
"""Wrapper that converts any dict args to dict item tuples."""
def dict_to_tuple(arg: Any) -> Any:
if isinstance(arg, dict):
return tuple(sorted(arg.items()))
return arg
def wrapper(*args: Any, **... | [
"def",
"dict_to_items_tuple",
"(",
"user_function",
":",
"Callable",
"[",
"...",
",",
"Any",
"]",
")",
"->",
"Callable",
"[",
"...",
",",
"Any",
"]",
":",
"def",
"dict_to_tuple",
"(",
"arg",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"isinstance",
"(",
... | [
798,
0
] | [
810,
18
] | python | en | ['en', 'en', 'en'] | True |
items_tuple_to_dict | (user_function: Callable[..., Any]) | Wrapper that converts any dict items tuple args to dicts. | Wrapper that converts any dict items tuple args to dicts. | def items_tuple_to_dict(user_function: Callable[..., Any]) -> Callable[..., Any]:
"""Wrapper that converts any dict items tuple args to dicts."""
def dict_items_to_dict(arg: Any) -> Any:
if isinstance(arg, tuple):
try:
return dict(arg)
except TypeError:
... | [
"def",
"items_tuple_to_dict",
"(",
"user_function",
":",
"Callable",
"[",
"...",
",",
"Any",
"]",
")",
"->",
"Callable",
"[",
"...",
",",
"Any",
"]",
":",
"def",
"dict_items_to_dict",
"(",
"arg",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"isinstance",
"... | [
813,
0
] | [
829,
18
] | python | en | ['en', 'en', 'en'] | True |
ExtraRoutesTable.get_object_display | (self, datum) | Display ExtraRoutes when deleted. | Display ExtraRoutes when deleted. | def get_object_display(self, datum):
"""Display ExtraRoutes when deleted."""
return (super(ExtraRoutesTable, self).get_object_display(datum) or
datum.destination + " -> " + datum.nexthop) | [
"def",
"get_object_display",
"(",
"self",
",",
"datum",
")",
":",
"return",
"(",
"super",
"(",
"ExtraRoutesTable",
",",
"self",
")",
".",
"get_object_display",
"(",
"datum",
")",
"or",
"datum",
".",
"destination",
"+",
"\" -> \"",
"+",
"datum",
".",
"nexth... | [
67,
4
] | [
70,
59
] | python | en | ['en', 'en', 'en'] | True |
show_test_item | (item) | Show test function, parameters and the fixtures of the test item. | Show test function, parameters and the fixtures of the test item. | def show_test_item(item):
"""Show test function, parameters and the fixtures of the test item."""
tw = item.config.get_terminal_writer()
tw.line()
tw.write(' ' * 8)
tw.write(item._nodeid)
used_fixtures = sorted(item._fixtureinfo.name2fixturedefs.keys())
if used_fixtures:
tw.write(' (... | [
"def",
"show_test_item",
"(",
"item",
")",
":",
"tw",
"=",
"item",
".",
"config",
".",
"get_terminal_writer",
"(",
")",
"tw",
".",
"line",
"(",
")",
"tw",
".",
"write",
"(",
"' '",
"*",
"8",
")",
"tw",
".",
"write",
"(",
"item",
".",
"_nodeid",
"... | [
89,
0
] | [
97,
74
] | python | en | ['en', 'en', 'en'] | True |
_update_current_test_var | (item, when) |
Update PYTEST_CURRENT_TEST to reflect the current item and stage.
If ``when`` is None, delete PYTEST_CURRENT_TEST from the environment.
|
Update PYTEST_CURRENT_TEST to reflect the current item and stage. | def _update_current_test_var(item, when):
"""
Update PYTEST_CURRENT_TEST to reflect the current item and stage.
If ``when`` is None, delete PYTEST_CURRENT_TEST from the environment.
"""
var_name = 'PYTEST_CURRENT_TEST'
if when:
value = '{0} ({1})'.format(item.nodeid, when)
# don... | [
"def",
"_update_current_test_var",
"(",
"item",
",",
"when",
")",
":",
"var_name",
"=",
"'PYTEST_CURRENT_TEST'",
"if",
"when",
":",
"value",
"=",
"'{0} ({1})'",
".",
"format",
"(",
"item",
".",
"nodeid",
",",
"when",
")",
"# don't allow null bytes on environment v... | [
126,
0
] | [
139,
32
] | python | en | ['en', 'error', 'th'] | False |
BaseReport.longreprtext | (self) |
Read-only property that returns the full string representation
of ``longrepr``.
.. versionadded:: 3.0
|
Read-only property that returns the full string representation
of ``longrepr``. | def longreprtext(self):
"""
Read-only property that returns the full string representation
of ``longrepr``.
.. versionadded:: 3.0
"""
tw = py.io.TerminalWriter(stringio=True)
tw.hasmarkup = False
self.toterminal(tw)
exc = tw.stringio.getvalue()
... | [
"def",
"longreprtext",
"(",
"self",
")",
":",
"tw",
"=",
"py",
".",
"io",
".",
"TerminalWriter",
"(",
"stringio",
"=",
"True",
")",
"tw",
".",
"hasmarkup",
"=",
"False",
"self",
".",
"toterminal",
"(",
"tw",
")",
"exc",
"=",
"tw",
".",
"stringio",
... | [
245,
4
] | [
256,
26
] | python | en | ['en', 'error', 'th'] | False |
BaseReport.capstdout | (self) | Return captured text from stdout, if capturing is enabled
.. versionadded:: 3.0
| Return captured text from stdout, if capturing is enabled | def capstdout(self):
"""Return captured text from stdout, if capturing is enabled
.. versionadded:: 3.0
"""
return ''.join(content for (prefix, content) in self.get_sections('Captured stdout')) | [
"def",
"capstdout",
"(",
"self",
")",
":",
"return",
"''",
".",
"join",
"(",
"content",
"for",
"(",
"prefix",
",",
"content",
")",
"in",
"self",
".",
"get_sections",
"(",
"'Captured stdout'",
")",
")"
] | [
259,
4
] | [
264,
93
] | python | en | ['en', 'en', 'en'] | True |
BaseReport.capstderr | (self) | Return captured text from stderr, if capturing is enabled
.. versionadded:: 3.0
| Return captured text from stderr, if capturing is enabled | def capstderr(self):
"""Return captured text from stderr, if capturing is enabled
.. versionadded:: 3.0
"""
return ''.join(content for (prefix, content) in self.get_sections('Captured stderr')) | [
"def",
"capstderr",
"(",
"self",
")",
":",
"return",
"''",
".",
"join",
"(",
"content",
"for",
"(",
"prefix",
",",
"content",
")",
"in",
"self",
".",
"get_sections",
"(",
"'Captured stderr'",
")",
")"
] | [
267,
4
] | [
272,
93
] | 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.