author | Gregory Szorc <gregory.szorc@gmail.com> |
Thu, 07 Mar 2019 15:42:32 -0800 | |
changeset 41908 | c2237fe1359e |
parent 41907 | 9da97f49d4f4 |
child 41910 | 1440dd6164f2 |
permissions | -rw-r--r-- |
41907
9da97f49d4f4
packaging: establish hgpackaging package
Gregory Szorc <gregory.szorc@gmail.com>
parents:
41853
diff
changeset
|
1 |
# util.py - Common packaging utility code. |
41853
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
2 |
# |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 |
# |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
5 |
# This software may be used and distributed according to the terms of the |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 |
# GNU General Public License version 2 or any later version. |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
7 |
|
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
8 |
# no-check-code because Python 3 native. |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
|
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
10 |
import pathlib |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
11 |
import tarfile |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
12 |
import zipfile |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
13 |
|
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
14 |
|
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
15 |
def extract_tar_to_directory(source: pathlib.Path, dest: pathlib.Path): |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
16 |
with tarfile.open(source, 'r') as tf: |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
17 |
tf.extractall(dest) |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
18 |
|
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
19 |
|
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
20 |
def extract_zip_to_directory(source: pathlib.Path, dest: pathlib.Path): |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
21 |
with zipfile.ZipFile(source, 'r') as zf: |
d7dc4ac1ff84
inno: script to automate building Inno installer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
22 |
zf.extractall(dest) |