forked from Dominexis/Project-Run-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathData Pack Zipper.py
54 lines (34 loc) · 1.13 KB
/
Data Pack Zipper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Import things
from pathlib import Path
import shutil
import sys
import os
# Check that correct Python version is running
if not (
(sys.version_info[0] == 3 and sys.version_info[1] >= 9)
or
(sys.version_info[0] > 3)
):
print("\n\nERROR: Data Pack Zipper requires Python 3.9 or newer!")
input()
exit()
# Initialize variables
PROGRAM_PATH = Path(__file__).parent
def program():
# Return if the folder doesn't exist
if not (PROGRAM_PATH / "Data Packs").exists():
print("ERROR: The folder 'Data Packs' doesn't exist!")
return
# Wipe output directory
shutil.rmtree(PROGRAM_PATH / "Zipped Data Packs")
(PROGRAM_PATH / "Zipped Data Packs").mkdir(exist_ok=True, parents=True)
# Iterate through packs
for data_pack_path in (PROGRAM_PATH / "Data Packs").iterdir():
if not data_pack_path.is_dir():
continue
data_pack = data_pack_path.name
print("Zipping " + data_pack)
shutil.make_archive(data_pack_path.parent.parent / "Zipped Data Packs" / data_pack, "zip", data_pack_path)
print("Data packs zipped")
program()
input()