forked from sachera/factorio-deadlocks-stacking-for-pyanodon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
executable file
·21 lines (18 loc) · 771 Bytes
/
build.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python
import os
import zipfile
import json
def zip(src, dst, version):
zf = zipfile.ZipFile("{}.zip".format(dst), "w", zipfile.ZIP_DEFLATED)
abs_src = os.path.abspath(src)
for dirname, subdirs, files in os.walk(src):
for filename in files:
absname = os.path.abspath(os.path.join(dirname, filename))
arcname = os.path.join(dst, absname[len(abs_src) + 1:].replace("x.y.z", version))
print('zipping {} as {}'.format(os.path.join(dirname, filename), arcname))
zf.write(absname, arcname)
zf.close()
with open('src/info.json') as json_data:
modInfo = json.load(json_data)
zip("src", "{}_{}".format(modInfo['name'], modInfo['version']), modInfo['version'])
json_data.close()