forked from L0laapk3/FactorioMaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeZip.py
51 lines (41 loc) · 1.07 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
import tempfile
import os
from shutil import rmtree, copy, make_archive
import shutil
from updateLib import update as updateLib
folderName = os.path.basename(os.path.realpath("."))
tempPath = os.path.join(tempfile.gettempdir(), folderName)
try:
rmtree(tempPath)
except (FileNotFoundError, NotADirectoryError):
pass
try:
rmtree(os.path.join("..", folderName + ".zip"))
except (FileNotFoundError, NotADirectoryError):
pass
os.mkdir(tempPath)
excludeDirs = (
".git",
".vscode",
"__pycache__",
"API_ExampleMod_0.0.1",
)
excludeFiles = (
".gitignore",
".gitattributes",
"makezip.py",
)
updateLib(False)
for root, dirs, files in os.walk("."):
dirs[:] = [d for d in dirs if d not in excludeDirs]
for file in files:
if file[-4:].lower() == ".pyc":
continue
if file.lower() in excludeFiles:
continue
src = os.path.normpath(os.path.join(root, file))
dest = os.path.normpath(os.path.join(tempPath, folderName, root, file))
os.makedirs(os.path.dirname(dest), exist_ok=True)
print(src, dest)
copy(src, dest)
make_archive(os.path.join("..", folderName), "zip", tempPath)