Mercurial > hg
view contrib/packaging/hgpackaging/util.py @ 41908:c2237fe1359e
packaging: split downloading code into own module
As we will introduce more code to support packaging, it will be
useful to have download code in its own module.
Differential Revision: https://phab.mercurial-scm.org/D6084
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 07 Mar 2019 15:42:32 -0800 |
parents | 9da97f49d4f4 |
children | 1440dd6164f2 |
line wrap: on
line source
# util.py - Common packaging utility code. # # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> # # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. # no-check-code because Python 3 native. import pathlib import tarfile import zipfile def extract_tar_to_directory(source: pathlib.Path, dest: pathlib.Path): with tarfile.open(source, 'r') as tf: tf.extractall(dest) def extract_zip_to_directory(source: pathlib.Path, dest: pathlib.Path): with zipfile.ZipFile(source, 'r') as zf: zf.extractall(dest)