-
Notifications
You must be signed in to change notification settings - Fork 5
/
makezip.py
65 lines (49 loc) · 1.59 KB
/
makezip.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
55
56
57
58
59
60
61
62
63
64
#
# makezip.py
#
# Package the FlexTools folder into a zip file for distribution.
#
# Copyright Craig Farrow, 2022
#
import sys
sys.path.append("FlexTools/scripts/")
from Version import Version
import pathlib
from zipfile import ZipFile, ZIP_DEFLATED
# FlexTools\ contains the following files that we need to package up:
# - .vbs, .bat & .py scripts, including the scripts\ folder
# - flextools.ini - a default configuration
# - Modules and Collections folders
#
FTPath = pathlib.Path("FlexTools")
ZIPFILE_NAME = f"dist\\FlexTools_{Version}.zip"
PATH_PATTERNS = (
"../LICENSE.txt",
"../history.txt",
"*.vbs",
"*.sh",
"scripts/*",
"Modules/**/*", # "**" = recursive
"Collections/Chinese processors.ini",
"Collections/Duplicates.ini",
"Collections/Examples.ini",
"Collections/Exporters.ini",
"Collections/Reports.ini",
)
FILTERED_SUFFIXES = (".pyd", ".pyc", ".bak", ".log", ".doc", ".tmp")
#-----------------------------------------------------------
def includeFile(path):
if path.stem == "__pycache__":
return False
# Filter out the Archive folder in the Chinese modules
if path.name == "Archive":
return False
if path.is_file() and path.parent.name == "Archive":
return False
return not path.suffix in FILTERED_SUFFIXES
print (f"Creating archive {ZIPFILE_NAME}")
with ZipFile(ZIPFILE_NAME, 'w', ZIP_DEFLATED) as z:
for pathPattern in PATH_PATTERNS:
for fn in filter(includeFile, FTPath.glob(pathPattern)):
print(f"adding '{fn}'")
z.write(fn)