Brushstroke Tools: Initial Version #328
@ -1,9 +1,11 @@
|
|||||||
import os
|
import os, ast
|
||||||
import bpy
|
import bpy
|
||||||
from bpy.app.handlers import persistent
|
from bpy.app.handlers import persistent
|
||||||
import math, shutil, errno
|
import math, shutil, errno
|
||||||
from bpy.app.handlers import persistent
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
|
addon_version = (0,0,0)
|
||||||
|
|
||||||
ng_list = [
|
ng_list = [
|
||||||
".brushstroke_tools.draw_processing",
|
".brushstroke_tools.draw_processing",
|
||||||
".brushstroke_tools.pre_processing",
|
".brushstroke_tools.pre_processing",
|
||||||
@ -184,7 +186,6 @@ def deep_copy_mod_info(source_object, target_object):
|
|||||||
for attr in socket_info.keys():
|
for attr in socket_info.keys():
|
||||||
setattr(socket_info_tgt, attr, getattr(socket_info, attr))
|
setattr(socket_info_tgt, attr, getattr(socket_info, attr))
|
||||||
|
|
||||||
|
|
||||||
def get_addon_directory() -> str:
|
def get_addon_directory() -> str:
|
||||||
"""
|
"""
|
||||||
Returns the path of the addon directory.
|
Returns the path of the addon directory.
|
||||||
@ -219,6 +220,16 @@ def import_resources(ng_names = ng_list):
|
|||||||
if 'brushstroke_tools-resources.blend' in img.library_weak_reference.filepath:
|
if 'brushstroke_tools-resources.blend' in img.library_weak_reference.filepath:
|
||||||
img.pack()
|
img.pack()
|
||||||
|
|
||||||
|
def read_lib_version():
|
||||||
|
resource_dir = f'{get_resource_directory()}'
|
||||||
|
with open(f"{resource_dir}.version", "r") as file:
|
||||||
|
version = ast.literal_eval(file.read())
|
||||||
|
return version
|
||||||
|
|
||||||
|
def write_lib_version():
|
||||||
|
resource_dir = f'{get_resource_directory()}'
|
||||||
|
with open(f"{resource_dir}.version", "w") as file:
|
||||||
|
file.write(str(addon_version))
|
||||||
|
|
||||||
def copy_resources_to_dir(tgt_dir = ''):
|
def copy_resources_to_dir(tgt_dir = ''):
|
||||||
resource_dir = f'{get_addon_directory()}/assets/'
|
resource_dir = f'{get_addon_directory()}/assets/'
|
||||||
@ -227,15 +238,15 @@ def copy_resources_to_dir(tgt_dir = ''):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
shutil.copytree(resource_dir, tgt_dir, dirs_exist_ok=True)
|
shutil.copytree(resource_dir, tgt_dir, dirs_exist_ok=True)
|
||||||
|
write_lib_version()
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
# error caused if the source was not a directory
|
# error caused if the source was not a directory
|
||||||
if err.errno == errno.ENOTDIR:
|
if err.errno == errno.ENOTDIR:
|
||||||
shutil.copy2(resource_dir, tgt_dir)
|
shutil.copy2(resource_dir, tgt_dir)
|
||||||
|
write_lib_version()
|
||||||
else:
|
else:
|
||||||
print("Error: % s" % err)
|
print("Error: % s" % err)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def ensure_resources():
|
def ensure_resources():
|
||||||
ng_missing = set()
|
ng_missing = set()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user