Use extractall instead of extract, as extracall seems to be more error tolerant (according to the documentation of tarfile).

This commit is contained in:
Achim D. Brucker 2017-08-15 22:30:47 +01:00
parent 116c76a719
commit 6167c5f88a
1 changed files with 8 additions and 1 deletions

View File

@ -41,6 +41,13 @@ def helpmsg():
print(" -a=<DIR> archive directory")
def get_tarinfo(members, last):
for tarinfo in members:
if tarinfo.name == last:
yield tarinfo
def main(argv):
"""Main function of the extension crawler."""
basedir = "archive"
@ -87,7 +94,7 @@ def main(argv):
if verbose:
print("Extracting "+os.path.join(output, last))
with tarfile.open(tar, 'r') as archive:
archive.extract(last, output)
archive.extractall(path=output, members=get_tarinfo(archive, last))
if __name__ == "__main__":
main(sys.argv[1:])