-
Notifications
You must be signed in to change notification settings - Fork 19
/
export.py
46 lines (37 loc) · 1.14 KB
/
export.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
import re
import os
# run this from the addon root, not from inside bpy_amb
addon_name = None
print("Running export...")
# try:
# print("Current zip version:", [i for i in os.listdir(".") if i.endswith(".zip")][0])
# except IndexError:
# print(".zip doesn't exist yet")
with open("__init__.py", "r") as f:
data = f.read()
m = re.search('"version": (?P<version>\(.+\))', data)
version_number = tuple(m.group("version")[1:-1].split(", "))
m = re.search('"name": "(?P<name>.+)"', data)
addon_name = "".join(m.group("name"))
# result = eval(compile(data, '', 'exec'))
# print(dir(result))
from pathlib import Path
dir_path = Path.cwd().stem
addon_name = addon_name.replace(" ", "_")
version_number = ".".join(version_number)
print("name: {}, version:{}".format(addon_name, version_number))
command = (
"7z a {}_{}.{} ../{}/"
' -xr!"__pycache__"'
' -xr!"export"'
' -xr!".*"'
' -xr!"*.bat"'
' -xr!"*.txt"'
' -xr!"*.7z"'
' -xr!"psutil"'
' -xr!"ignored"'
' -xr!"export.py"'
' -xr!"*.zip"'.format(addon_name, version_number, "zip", dir_path)
)
os.system(command)
print("Finished export.")