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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
FootballEnvTest.test__memory_usage | (self) | Make sure memory usage is low when not recording videos. | Make sure memory usage is low when not recording videos. | def test__memory_usage(self):
"""Make sure memory usage is low when not recording videos."""
# This test has to go first, so that memory usage is not affected.
if 'UNITTEST_IN_DOCKER' in os.environ:
# Forge doesn't support rendering.
return
cfg = config.Config({'write_video': False})
env... | [
"def",
"test__memory_usage",
"(",
"self",
")",
":",
"# This test has to go first, so that memory usage is not affected.",
"if",
"'UNITTEST_IN_DOCKER'",
"in",
"os",
".",
"environ",
":",
"# Forge doesn't support rendering.",
"return",
"cfg",
"=",
"config",
".",
"Config",
"(",... | [
254,
2
] | [
269,
51
] | python | en | ['en', 'en', 'en'] | True |
FootballEnvTest.test_player_order_invariant | (self) | Checks that environment behaves the same regardless of players order. | Checks that environment behaves the same regardless of players order. | def test_player_order_invariant(self):
"""Checks that environment behaves the same regardless of players order."""
players = ['agent:right_players=1', 'lazy:left_players=11']
cfg = config.Config({
'level': 'tests.11_vs_11_hard_deterministic',
'players': players
})
env = football_env.... | [
"def",
"test_player_order_invariant",
"(",
"self",
")",
":",
"players",
"=",
"[",
"'agent:right_players=1'",
",",
"'lazy:left_players=11'",
"]",
"cfg",
"=",
"config",
".",
"Config",
"(",
"{",
"'level'",
":",
"'tests.11_vs_11_hard_deterministic'",
",",
"'players'",
"... | [
271,
2
] | [
289,
15
] | python | en | ['en', 'en', 'en'] | True |
FootballEnvTest.test_setstate | (self, seed) | Checks setState functionality. | Checks setState functionality. | def test_setstate(self, seed):
"""Checks setState functionality."""
cfg1 = config.Config({
'level': 'tests.symmetric',
'game_engine_random_seed': seed,
'reverse_team_processing' : False
})
cfg2 = config.Config({
'level': 'tests.symmetric',
'game_engine_random_seed... | [
"def",
"test_setstate",
"(",
"self",
",",
"seed",
")",
":",
"cfg1",
"=",
"config",
".",
"Config",
"(",
"{",
"'level'",
":",
"'tests.symmetric'",
",",
"'game_engine_random_seed'",
":",
"seed",
",",
"'reverse_team_processing'",
":",
"False",
"}",
")",
"cfg2",
... | [
292,
2
] | [
333,
16
] | python | en | ['en', 'sn', 'en'] | True |
FootballEnvTest.test_symmetry | (self, seed) | Checks game symmetry. | Checks game symmetry. | def test_symmetry(self, seed):
"""Checks game symmetry."""
processes = []
cfg1 = config.Config({
'level': 'tests.symmetric',
'game_engine_random_seed': seed,
'players': ['agent:left_players=1,right_players=1'],
'reverse_team_processing': False,
})
cfg2 = config.Config... | [
"def",
"test_symmetry",
"(",
"self",
",",
"seed",
")",
":",
"processes",
"=",
"[",
"]",
"cfg1",
"=",
"config",
".",
"Config",
"(",
"{",
"'level'",
":",
"'tests.symmetric'",
",",
"'game_engine_random_seed'",
":",
"seed",
",",
"'players'",
":",
"[",
"'agent:... | [
336,
2
] | [
371,
18
] | python | en | ['lt', 'ht', 'en'] | False |
FootballEnvTest.test_render_state_equals_norender | (self, seed) | Checks that rendering game state is the same as non-rendering. | Checks that rendering game state is the same as non-rendering. | def test_render_state_equals_norender(self, seed):
"""Checks that rendering game state is the same as non-rendering."""
if 'UNITTEST_IN_DOCKER' in os.environ:
# Forge doesn't support rendering.
return
processes = []
cfg1 = config.Config({
'level': 'tests.symmetric',
'game_eng... | [
"def",
"test_render_state_equals_norender",
"(",
"self",
",",
"seed",
")",
":",
"if",
"'UNITTEST_IN_DOCKER'",
"in",
"os",
".",
"environ",
":",
"# Forge doesn't support rendering.",
"return",
"processes",
"=",
"[",
"]",
"cfg1",
"=",
"config",
".",
"Config",
"(",
... | [
477,
2
] | [
514,
18
] | python | en | ['en', 'en', 'en'] | True |
configure | (self, config) |
Merge config into engine, setup provisioning,
setup execution and settings attributes for executor.
:return:
|
Merge config into engine, setup provisioning,
setup execution and settings attributes for executor. | def configure(self, config):
"""
Merge config into engine, setup provisioning,
setup execution and settings attributes for executor.
:return:
"""
path = os.path.join(RESOURCES_DIR, "jmeter/jmeter-loader" + EXE_SUFFIX)
self.obj.settings.merge({
'path':... | [
"def",
"configure",
"(",
"self",
",",
"config",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"RESOURCES_DIR",
",",
"\"jmeter/jmeter-loader\"",
"+",
"EXE_SUFFIX",
")",
"self",
".",
"obj",
".",
"settings",
".",
"merge",
"(",
"{",
"'path'",
... | [
43,
4
] | [
65,
60
] | python | en | ['en', 'error', 'th'] | False |
test_cookiemanager_3_2_bug_requests | (self) | specify implementation of CookieManager for case of generation from requests | specify implementation of CookieManager for case of generation from requests | def test_cookiemanager_3_2_bug_requests(self):
""" specify implementation of CookieManager for case of generation from requests """
self.configure({
'execution': {
'hold-for': '1s',
'concurrency': 10,
'scenario': {
'requests... | [
"def",
"test_cookiemanager_3_2_bug_requests",
"(",
"self",
")",
":",
"self",
".",
"configure",
"(",
"{",
"'execution'",
":",
"{",
"'hold-for'",
":",
"'1s'",
",",
"'concurrency'",
":",
"10",
",",
"'scenario'",
":",
"{",
"'requests'",
":",
"[",
"'http://blazedem... | [
550,
4
] | [
564,
71
] | python | en | ['en', 'en', 'en'] | True |
test_cookiemanager_3_2_bug_jmx | (self) | specify implementation of CookieManager for existing jmx | specify implementation of CookieManager for existing jmx | def test_cookiemanager_3_2_bug_jmx(self):
""" specify implementation of CookieManager for existing jmx """
self.configure({
'execution': {
'hold-for': '1s',
'concurrency': 10,
'scenario': {
'script': RESOURCES_DIR + '/jmeter... | [
"def",
"test_cookiemanager_3_2_bug_jmx",
"(",
"self",
")",
":",
"self",
".",
"configure",
"(",
"{",
"'execution'",
":",
"{",
"'hold-for'",
":",
"'1s'",
",",
"'concurrency'",
":",
"10",
",",
"'scenario'",
":",
"{",
"'script'",
":",
"RESOURCES_DIR",
"+",
"'/jm... | [
566,
4
] | [
582,
82
] | python | en | ['en', 'en', 'en'] | True |
test_resource_files_paths | (self) |
Check whether JMeter.resource_files() modifies filenames in JMX carefully
:return:
|
Check whether JMeter.resource_files() modifies filenames in JMX carefully
:return:
| def test_resource_files_paths(self):
"""
Check whether JMeter.resource_files() modifies filenames in JMX carefully
:return:
"""
self.obj.execution.merge({"scenario": {"script": RESOURCES_DIR + "/jmeter/jmx/files_paths.jmx"}})
file_in_home = get_full_path('~/file-in-home.... | [
"def",
"test_resource_files_paths",
"(",
"self",
")",
":",
"self",
".",
"obj",
".",
"execution",
".",
"merge",
"(",
"{",
"\"scenario\"",
":",
"{",
"\"script\"",
":",
"RESOURCES_DIR",
"+",
"\"/jmeter/jmx/files_paths.jmx\"",
"}",
"}",
")",
"file_in_home",
"=",
"... | [
604,
4
] | [
630,
66
] | python | en | ['en', 'error', 'th'] | False |
test_jmx_paths_local_prov | (self) | Ensures that file paths in JMX are not changed during local prov | Ensures that file paths in JMX are not changed during local prov | def test_jmx_paths_local_prov(self):
"Ensures that file paths in JMX are not changed during local prov"
script = RESOURCES_DIR + "/jmeter/jmx/csvs.jmx"
self.configure({
'execution': {
'iterations': 1,
'scenario': {
"script": script}... | [
"def",
"test_jmx_paths_local_prov",
"(",
"self",
")",
":",
"script",
"=",
"RESOURCES_DIR",
"+",
"\"/jmeter/jmx/csvs.jmx\"",
"self",
".",
"configure",
"(",
"{",
"'execution'",
":",
"{",
"'iterations'",
":",
"1",
",",
"'scenario'",
":",
"{",
"\"script\"",
":",
"... | [
1656,
4
] | [
1670,
56
] | python | en | ['en', 'en', 'en'] | True |
test_jmx_paths_remote_prov | (self) | Ensures that file paths in JMX are modified during remote prov | Ensures that file paths in JMX are modified during remote prov | def test_jmx_paths_remote_prov(self):
"Ensures that file paths in JMX are modified during remote prov"
script = RESOURCES_DIR + "/jmeter/jmx/csvs.jmx"
self.configure({
'execution': {
'iterations': 1,
'scenario': {
"script": script}}... | [
"def",
"test_jmx_paths_remote_prov",
"(",
"self",
")",
":",
"script",
"=",
"RESOURCES_DIR",
"+",
"\"/jmeter/jmx/csvs.jmx\"",
"self",
".",
"configure",
"(",
"{",
"'execution'",
":",
"{",
"'iterations'",
":",
"1",
",",
"'scenario'",
":",
"{",
"\"script\"",
":",
... | [
1672,
4
] | [
1690,
80
] | python | en | ['en', 'en', 'en'] | True |
stn | (s, length, encoding, errors) | Convert a string to a null-terminated bytes object.
| Convert a string to a null-terminated bytes object.
| def stn(s, length, encoding, errors):
"""Convert a string to a null-terminated bytes object.
"""
s = s.encode(encoding, errors)
return s[:length] + (length - len(s)) * NUL | [
"def",
"stn",
"(",
"s",
",",
"length",
",",
"encoding",
",",
"errors",
")",
":",
"s",
"=",
"s",
".",
"encode",
"(",
"encoding",
",",
"errors",
")",
"return",
"s",
"[",
":",
"length",
"]",
"+",
"(",
"length",
"-",
"len",
"(",
"s",
")",
")",
"*... | [
184,
0
] | [
188,
47
] | python | en | ['en', 'en', 'en'] | True |
nts | (s, encoding, errors) | Convert a null-terminated bytes object to a string.
| Convert a null-terminated bytes object to a string.
| def nts(s, encoding, errors):
"""Convert a null-terminated bytes object to a string.
"""
p = s.find(b"\0")
if p != -1:
s = s[:p]
return s.decode(encoding, errors) | [
"def",
"nts",
"(",
"s",
",",
"encoding",
",",
"errors",
")",
":",
"p",
"=",
"s",
".",
"find",
"(",
"b\"\\0\"",
")",
"if",
"p",
"!=",
"-",
"1",
":",
"s",
"=",
"s",
"[",
":",
"p",
"]",
"return",
"s",
".",
"decode",
"(",
"encoding",
",",
"erro... | [
190,
0
] | [
196,
37
] | python | en | ['en', 'en', 'en'] | True |
nti | (s) | Convert a number field to a python number.
| Convert a number field to a python number.
| def nti(s):
"""Convert a number field to a python number.
"""
# There are two possible encodings for a number field, see
# itn() below.
if s[0] != chr(0o200):
try:
n = int(nts(s, "ascii", "strict") or "0", 8)
except ValueError:
raise InvalidHeaderError("invali... | [
"def",
"nti",
"(",
"s",
")",
":",
"# There are two possible encodings for a number field, see",
"# itn() below.",
"if",
"s",
"[",
"0",
"]",
"!=",
"chr",
"(",
"0o200",
")",
":",
"try",
":",
"n",
"=",
"int",
"(",
"nts",
"(",
"s",
",",
"\"ascii\"",
",",
"\"... | [
198,
0
] | [
213,
12
] | python | en | ['en', 'en', 'en'] | True |
itn | (n, digits=8, format=DEFAULT_FORMAT) | Convert a python number to a number field.
| Convert a python number to a number field.
| def itn(n, digits=8, format=DEFAULT_FORMAT):
"""Convert a python number to a number field.
"""
# POSIX 1003.1-1988 requires numbers to be encoded as a string of
# octal digits followed by a null-byte, this allows values up to
# (8**(digits-1))-1. GNU tar allows storing numbers greater than
# tha... | [
"def",
"itn",
"(",
"n",
",",
"digits",
"=",
"8",
",",
"format",
"=",
"DEFAULT_FORMAT",
")",
":",
"# POSIX 1003.1-1988 requires numbers to be encoded as a string of",
"# octal digits followed by a null-byte, this allows values up to",
"# (8**(digits-1))-1. GNU tar allows storing numbe... | [
215,
0
] | [
240,
12
] | python | en | ['en', 'en', 'en'] | True |
calc_chksums | (buf) | Calculate the checksum for a member's header by summing up all
characters except for the chksum field which is treated as if
it was filled with spaces. According to the GNU tar sources,
some tars (Sun and NeXT) calculate chksum with signed char,
which will be different if there are chars in ... | Calculate the checksum for a member's header by summing up all
characters except for the chksum field which is treated as if
it was filled with spaces. According to the GNU tar sources,
some tars (Sun and NeXT) calculate chksum with signed char,
which will be different if there are chars in ... | def calc_chksums(buf):
"""Calculate the checksum for a member's header by summing up all
characters except for the chksum field which is treated as if
it was filled with spaces. According to the GNU tar sources,
some tars (Sun and NeXT) calculate chksum with signed char,
which will be di... | [
"def",
"calc_chksums",
"(",
"buf",
")",
":",
"unsigned_chksum",
"=",
"256",
"+",
"sum",
"(",
"struct",
".",
"unpack",
"(",
"\"148B\"",
",",
"buf",
"[",
":",
"148",
"]",
")",
"+",
"struct",
".",
"unpack",
"(",
"\"356B\"",
",",
"buf",
"[",
"156",
":"... | [
242,
0
] | [
253,
41
] | python | en | ['en', 'en', 'en'] | True |
copyfileobj | (src, dst, length=None) | Copy length bytes from fileobj src to fileobj dst.
If length is None, copy the entire content.
| Copy length bytes from fileobj src to fileobj dst.
If length is None, copy the entire content.
| def copyfileobj(src, dst, length=None):
"""Copy length bytes from fileobj src to fileobj dst.
If length is None, copy the entire content.
"""
if length == 0:
return
if length is None:
while True:
buf = src.read(16*1024)
if not buf:
break
... | [
"def",
"copyfileobj",
"(",
"src",
",",
"dst",
",",
"length",
"=",
"None",
")",
":",
"if",
"length",
"==",
"0",
":",
"return",
"if",
"length",
"is",
"None",
":",
"while",
"True",
":",
"buf",
"=",
"src",
".",
"read",
"(",
"16",
"*",
"1024",
")",
... | [
255,
0
] | [
282,
10
] | python | en | ['en', 'pt', 'en'] | True |
filemode | (mode) | Convert a file's mode to a string of the form
-rwxrwxrwx.
Used by TarFile.list()
| Convert a file's mode to a string of the form
-rwxrwxrwx.
Used by TarFile.list()
| def filemode(mode):
"""Convert a file's mode to a string of the form
-rwxrwxrwx.
Used by TarFile.list()
"""
perm = []
for table in filemode_table:
for bit, char in table:
if mode & bit == bit:
perm.append(char)
break
else:
... | [
"def",
"filemode",
"(",
"mode",
")",
":",
"perm",
"=",
"[",
"]",
"for",
"table",
"in",
"filemode_table",
":",
"for",
"bit",
",",
"char",
"in",
"table",
":",
"if",
"mode",
"&",
"bit",
"==",
"bit",
":",
"perm",
".",
"append",
"(",
"char",
")",
"bre... | [
311,
0
] | [
324,
24
] | python | en | ['en', 'en', 'en'] | True |
is_tarfile | (name) | Return True if name points to a tar archive that we
are able to handle, else return False.
| Return True if name points to a tar archive that we
are able to handle, else return False.
| def is_tarfile(name):
"""Return True if name points to a tar archive that we
are able to handle, else return False.
"""
try:
t = open(name)
t.close()
return True
except TarError:
return False | [
"def",
"is_tarfile",
"(",
"name",
")",
":",
"try",
":",
"t",
"=",
"open",
"(",
"name",
")",
"t",
".",
"close",
"(",
")",
"return",
"True",
"except",
"TarError",
":",
"return",
"False"
] | [
2594,
0
] | [
2603,
20
] | python | en | ['en', 'en', 'en'] | True |
_Stream.__init__ | (self, name, mode, comptype, fileobj, bufsize) | Construct a _Stream object.
| Construct a _Stream object.
| def __init__(self, name, mode, comptype, fileobj, bufsize):
"""Construct a _Stream object.
"""
self._extfileobj = True
if fileobj is None:
fileobj = _LowLevelFile(name, mode)
self._extfileobj = False
if comptype == '*':
# Enable transparent co... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"mode",
",",
"comptype",
",",
"fileobj",
",",
"bufsize",
")",
":",
"self",
".",
"_extfileobj",
"=",
"True",
"if",
"fileobj",
"is",
"None",
":",
"fileobj",
"=",
"_LowLevelFile",
"(",
"name",
",",
"mode",... | [
398,
4
] | [
448,
17
] | python | en | ['en', 'en', 'en'] | True |
_Stream._init_write_gz | (self) | Initialize for writing with gzip compression.
| Initialize for writing with gzip compression.
| def _init_write_gz(self):
"""Initialize for writing with gzip compression.
"""
self.cmp = self.zlib.compressobj(9, self.zlib.DEFLATED,
-self.zlib.MAX_WBITS,
self.zlib.DEF_MEM_LEVEL,
... | [
"def",
"_init_write_gz",
"(",
"self",
")",
":",
"self",
".",
"cmp",
"=",
"self",
".",
"zlib",
".",
"compressobj",
"(",
"9",
",",
"self",
".",
"zlib",
".",
"DEFLATED",
",",
"-",
"self",
".",
"zlib",
".",
"MAX_WBITS",
",",
"self",
".",
"zlib",
".",
... | [
454,
4
] | [
466,
69
] | python | en | ['en', 'en', 'en'] | True |
_Stream.write | (self, s) | Write string s to the stream.
| Write string s to the stream.
| def write(self, s):
"""Write string s to the stream.
"""
if self.comptype == "gz":
self.crc = self.zlib.crc32(s, self.crc)
self.pos += len(s)
if self.comptype != "tar":
s = self.cmp.compress(s)
self.__write(s) | [
"def",
"write",
"(",
"self",
",",
"s",
")",
":",
"if",
"self",
".",
"comptype",
"==",
"\"gz\"",
":",
"self",
".",
"crc",
"=",
"self",
".",
"zlib",
".",
"crc32",
"(",
"s",
",",
"self",
".",
"crc",
")",
"self",
".",
"pos",
"+=",
"len",
"(",
"s"... | [
468,
4
] | [
476,
23
] | python | en | ['en', 'en', 'en'] | True |
_Stream.__write | (self, s) | Write string s to the stream if a whole new block
is ready to be written.
| Write string s to the stream if a whole new block
is ready to be written.
| def __write(self, s):
"""Write string s to the stream if a whole new block
is ready to be written.
"""
self.buf += s
while len(self.buf) > self.bufsize:
self.fileobj.write(self.buf[:self.bufsize])
self.buf = self.buf[self.bufsize:] | [
"def",
"__write",
"(",
"self",
",",
"s",
")",
":",
"self",
".",
"buf",
"+=",
"s",
"while",
"len",
"(",
"self",
".",
"buf",
")",
">",
"self",
".",
"bufsize",
":",
"self",
".",
"fileobj",
".",
"write",
"(",
"self",
".",
"buf",
"[",
":",
"self",
... | [
478,
4
] | [
485,
46
] | python | en | ['en', 'en', 'en'] | True |
_Stream.close | (self) | Close the _Stream object. No operation should be
done on it afterwards.
| Close the _Stream object. No operation should be
done on it afterwards.
| def close(self):
"""Close the _Stream object. No operation should be
done on it afterwards.
"""
if self.closed:
return
if self.mode == "w" and self.comptype != "tar":
self.buf += self.cmp.flush()
if self.mode == "w" and self.buf:
s... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"closed",
":",
"return",
"if",
"self",
".",
"mode",
"==",
"\"w\"",
"and",
"self",
".",
"comptype",
"!=",
"\"tar\"",
":",
"self",
".",
"buf",
"+=",
"self",
".",
"cmp",
".",
"flush",
"(",
")... | [
487,
4
] | [
513,
26
] | python | en | ['en', 'en', 'en'] | True |
_Stream._init_read_gz | (self) | Initialize for reading a gzip compressed fileobj.
| Initialize for reading a gzip compressed fileobj.
| def _init_read_gz(self):
"""Initialize for reading a gzip compressed fileobj.
"""
self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS)
self.dbuf = b""
# taken from gzip.GzipFile with some alterations
if self.__read(2) != b"\037\213":
raise ReadError("not ... | [
"def",
"_init_read_gz",
"(",
"self",
")",
":",
"self",
".",
"cmp",
"=",
"self",
".",
"zlib",
".",
"decompressobj",
"(",
"-",
"self",
".",
"zlib",
".",
"MAX_WBITS",
")",
"self",
".",
"dbuf",
"=",
"b\"\"",
"# taken from gzip.GzipFile with some alterations",
"i... | [
515,
4
] | [
544,
26
] | python | en | ['en', 'en', 'pt'] | True |
_Stream.tell | (self) | Return the stream's file pointer position.
| Return the stream's file pointer position.
| def tell(self):
"""Return the stream's file pointer position.
"""
return self.pos | [
"def",
"tell",
"(",
"self",
")",
":",
"return",
"self",
".",
"pos"
] | [
546,
4
] | [
549,
23
] | python | en | ['en', 'en', 'en'] | True |
_Stream.seek | (self, pos=0) | Set the stream's file pointer to pos. Negative seeking
is forbidden.
| Set the stream's file pointer to pos. Negative seeking
is forbidden.
| def seek(self, pos=0):
"""Set the stream's file pointer to pos. Negative seeking
is forbidden.
"""
if pos - self.pos >= 0:
blocks, remainder = divmod(pos - self.pos, self.bufsize)
for i in range(blocks):
self.read(self.bufsize)
self.... | [
"def",
"seek",
"(",
"self",
",",
"pos",
"=",
"0",
")",
":",
"if",
"pos",
"-",
"self",
".",
"pos",
">=",
"0",
":",
"blocks",
",",
"remainder",
"=",
"divmod",
"(",
"pos",
"-",
"self",
".",
"pos",
",",
"self",
".",
"bufsize",
")",
"for",
"i",
"i... | [
551,
4
] | [
562,
23
] | python | en | ['en', 'en', 'en'] | True |
_Stream.read | (self, size=None) | Return the next size number of bytes from the stream.
If size is not defined, return all bytes of the stream
up to EOF.
| Return the next size number of bytes from the stream.
If size is not defined, return all bytes of the stream
up to EOF.
| def read(self, size=None):
"""Return the next size number of bytes from the stream.
If size is not defined, return all bytes of the stream
up to EOF.
"""
if size is None:
t = []
while True:
buf = self._read(self.bufsize)
... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"t",
"=",
"[",
"]",
"while",
"True",
":",
"buf",
"=",
"self",
".",
"_read",
"(",
"self",
".",
"bufsize",
")",
"if",
"not",
"buf",
":",
"break",
"... | [
564,
4
] | [
580,
18
] | python | en | ['en', 'en', 'en'] | True |
_Stream._read | (self, size) | Return size bytes from the stream.
| Return size bytes from the stream.
| def _read(self, size):
"""Return size bytes from the stream.
"""
if self.comptype == "tar":
return self.__read(size)
c = len(self.dbuf)
while c < size:
buf = self.__read(self.bufsize)
if not buf:
break
try:
... | [
"def",
"_read",
"(",
"self",
",",
"size",
")",
":",
"if",
"self",
".",
"comptype",
"==",
"\"tar\"",
":",
"return",
"self",
".",
"__read",
"(",
"size",
")",
"c",
"=",
"len",
"(",
"self",
".",
"dbuf",
")",
"while",
"c",
"<",
"size",
":",
"buf",
"... | [
582,
4
] | [
601,
18
] | python | en | ['en', 'en', 'en'] | True |
_Stream.__read | (self, size) | Return size bytes from stream. If internal buffer is empty,
read another block from the stream.
| Return size bytes from stream. If internal buffer is empty,
read another block from the stream.
| def __read(self, size):
"""Return size bytes from stream. If internal buffer is empty,
read another block from the stream.
"""
c = len(self.buf)
while c < size:
buf = self.fileobj.read(self.bufsize)
if not buf:
break
self.buf... | [
"def",
"__read",
"(",
"self",
",",
"size",
")",
":",
"c",
"=",
"len",
"(",
"self",
".",
"buf",
")",
"while",
"c",
"<",
"size",
":",
"buf",
"=",
"self",
".",
"fileobj",
".",
"read",
"(",
"self",
".",
"bufsize",
")",
"if",
"not",
"buf",
":",
"b... | [
603,
4
] | [
616,
18
] | python | en | ['en', 'fy', 'en'] | True |
_FileInFile.tell | (self) | Return the current file position.
| Return the current file position.
| def tell(self):
"""Return the current file position.
"""
return self.position | [
"def",
"tell",
"(",
"self",
")",
":",
"return",
"self",
".",
"position"
] | [
741,
4
] | [
744,
28
] | python | en | ['en', 'en', 'en'] | True |
_FileInFile.seek | (self, position) | Seek to a position in the file.
| Seek to a position in the file.
| def seek(self, position):
"""Seek to a position in the file.
"""
self.position = position | [
"def",
"seek",
"(",
"self",
",",
"position",
")",
":",
"self",
".",
"position",
"=",
"position"
] | [
746,
4
] | [
749,
32
] | python | en | ['en', 'en', 'en'] | True |
_FileInFile.read | (self, size=None) | Read data from the file.
| Read data from the file.
| def read(self, size=None):
"""Read data from the file.
"""
if size is None:
size = self.size - self.position
else:
size = min(size, self.size - self.position)
buf = b""
while size > 0:
while True:
data, start, stop, off... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"self",
".",
"size",
"-",
"self",
".",
"position",
"else",
":",
"size",
"=",
"min",
"(",
"size",
",",
"self",
".",
"size",
"-",
"self"... | [
751,
4
] | [
777,
18
] | python | en | ['en', 'en', 'en'] | True |
ExFileObject.read | (self, size=None) | Read at most size bytes from the file. If size is not
present or None, read all data until EOF is reached.
| Read at most size bytes from the file. If size is not
present or None, read all data until EOF is reached.
| def read(self, size=None):
"""Read at most size bytes from the file. If size is not
present or None, read all data until EOF is reached.
"""
if self.closed:
raise ValueError("I/O operation on closed file")
buf = b""
if self.buffer:
if size is N... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"ValueError",
"(",
"\"I/O operation on closed file\"",
")",
"buf",
"=",
"b\"\"",
"if",
"self",
".",
"buffer",
":",
"if",
"size",
"is",
"None",
":... | [
809,
4
] | [
831,
18
] | python | en | ['en', 'en', 'en'] | True |
ExFileObject.readline | (self, size=-1) | Read one entire line from the file. If size is present
and non-negative, return a string with at most that
size, which may be an incomplete line.
| Read one entire line from the file. If size is present
and non-negative, return a string with at most that
size, which may be an incomplete line.
| def readline(self, size=-1):
"""Read one entire line from the file. If size is present
and non-negative, return a string with at most that
size, which may be an incomplete line.
"""
if self.closed:
raise ValueError("I/O operation on closed file")
pos = ... | [
"def",
"readline",
"(",
"self",
",",
"size",
"=",
"-",
"1",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"ValueError",
"(",
"\"I/O operation on closed file\"",
")",
"pos",
"=",
"self",
".",
"buffer",
".",
"find",
"(",
"b\"\\n\"",
")",
"+",
"1",... | [
836,
4
] | [
863,
18
] | python | en | ['en', 'en', 'en'] | True |
ExFileObject.readlines | (self) | Return a list with all remaining lines.
| Return a list with all remaining lines.
| def readlines(self):
"""Return a list with all remaining lines.
"""
result = []
while True:
line = self.readline()
if not line: break
result.append(line)
return result | [
"def",
"readlines",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"while",
"True",
":",
"line",
"=",
"self",
".",
"readline",
"(",
")",
"if",
"not",
"line",
":",
"break",
"result",
".",
"append",
"(",
"line",
")",
"return",
"result"
] | [
865,
4
] | [
873,
21
] | python | en | ['en', 'en', 'en'] | True |
ExFileObject.tell | (self) | Return the current file position.
| Return the current file position.
| def tell(self):
"""Return the current file position.
"""
if self.closed:
raise ValueError("I/O operation on closed file")
return self.position | [
"def",
"tell",
"(",
"self",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"ValueError",
"(",
"\"I/O operation on closed file\"",
")",
"return",
"self",
".",
"position"
] | [
875,
4
] | [
881,
28
] | python | en | ['en', 'en', 'en'] | True |
ExFileObject.seek | (self, pos, whence=os.SEEK_SET) | Seek to a position in the file.
| Seek to a position in the file.
| def seek(self, pos, whence=os.SEEK_SET):
"""Seek to a position in the file.
"""
if self.closed:
raise ValueError("I/O operation on closed file")
if whence == os.SEEK_SET:
self.position = min(max(pos, 0), self.size)
elif whence == os.SEEK_CUR:
... | [
"def",
"seek",
"(",
"self",
",",
"pos",
",",
"whence",
"=",
"os",
".",
"SEEK_SET",
")",
":",
"if",
"self",
".",
"closed",
":",
"raise",
"ValueError",
"(",
"\"I/O operation on closed file\"",
")",
"if",
"whence",
"==",
"os",
".",
"SEEK_SET",
":",
"self",
... | [
883,
4
] | [
902,
40
] | python | en | ['en', 'en', 'en'] | True |
ExFileObject.close | (self) | Close the file object.
| Close the file object.
| def close(self):
"""Close the file object.
"""
self.closed = True | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"closed",
"=",
"True"
] | [
904,
4
] | [
907,
26
] | python | en | ['en', 'en', 'en'] | True |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.