-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtasks.py
40 lines (32 loc) · 1.13 KB
/
tasks.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
from invoke import task
import os
import shutil
import zipfile
@task
def update(c, blender_version="3.5"):
"""
Installs the latest version of the addon to the default Blender addons directory
"""
user_dir = os.path.expanduser('~')
# Set directory paths
dir1 = './qar'
dir2 = f"{user_dir}/AppData/Roaming/Blender Foundation/Blender/{blender_version}/scripts/addons/qar"
if os.path.exists(dir2):
shutil.rmtree(dir2)
# Loop through each file and copy it to directory2
shutil.copytree(dir1, dir2)
@task
def zip(c):
"""
Creates a zip file of the addon
"""
dir1 = './qar'
# Create a zip file with the same name as the last part of dir1
zip_name = os.path.basename(dir1)
with zipfile.ZipFile(zip_name + '.zip', 'w') as zip_file:
for foldername, subfolders, filenames in os.walk(dir1):
for filename in filenames:
# Create the full filepath by using os.path.join()
filepath = os.path.join(foldername, filename)
# Add the file to the zip file
zip_file.write(filepath, os.path.relpath(filepath, dir1))