Unpacks packedfile into parent_path. Assumes .zip. Returns parent_path
(packedfile, parent_path)
| 64 | return digest.hexdigest() |
| 65 | |
| 66 | def unpack(packedfile, parent_path): |
| 67 | """Unpacks packedfile into parent_path. Assumes .zip. Returns parent_path""" |
| 68 | if zipfile.is_zipfile(packedfile): |
| 69 | with contextlib.closing(zipfile.ZipFile(packedfile, 'r')) as icuzip: |
| 70 | print(' Extracting zipfile: %s' % packedfile) |
| 71 | icuzip.extractall(parent_path) |
| 72 | return parent_path |
| 73 | elif tarfile.is_tarfile(packedfile): |
| 74 | with contextlib.closing(tarfile.TarFile.open(packedfile, 'r')) as icuzip: |
| 75 | print(' Extracting tarfile: %s' % packedfile) |
| 76 | icuzip.extractall(parent_path) |
| 77 | return parent_path |
| 78 | else: |
| 79 | packedsuffix = packedfile.lower().split('.')[-1] # .zip, .tgz etc |
| 80 | raise Exception('Error: Don\'t know how to unpack %s with extension %s' % (packedfile, packedsuffix)) |
| 81 | |
| 82 | # List of possible "--download=" types. |
| 83 | download_types = set(['icu']) |