2022-12-24 15:30:32 +01:00
|
|
|
|
|
|
|
"""
|
|
|
|
Adapter for making an asset library of all blender file found in a folder
|
|
|
|
"""
|
|
|
|
|
|
|
|
from os.path import expandvars
|
2024-05-27 17:22:45 +02:00
|
|
|
|
2022-12-30 23:36:09 +01:00
|
|
|
import bpy
|
2024-05-27 17:22:45 +02:00
|
|
|
from bpy.props import StringProperty
|
|
|
|
|
2024-07-04 11:53:58 +02:00
|
|
|
from asset_library.plugins.library_plugin import LibraryPlugin
|
|
|
|
from asset_library.core.file_utils import copy_dir
|
2024-05-27 17:22:45 +02:00
|
|
|
|
|
|
|
|
2022-12-24 15:30:32 +01:00
|
|
|
|
|
|
|
|
2024-05-27 17:22:45 +02:00
|
|
|
class CopyFolder(LibraryPlugin):
|
2022-12-24 15:30:32 +01:00
|
|
|
"""Copy library folder from a server to a local disk for better performance"""
|
|
|
|
|
|
|
|
name = "Copy Folder"
|
|
|
|
source_directory : StringProperty()
|
|
|
|
|
|
|
|
includes : StringProperty()
|
|
|
|
excludes : StringProperty()
|
|
|
|
|
2022-12-28 17:44:15 +01:00
|
|
|
def bundle(self, cache_diff=None):
|
2022-12-24 15:30:32 +01:00
|
|
|
src = expandvars(self.source_directory)
|
2022-12-30 23:36:09 +01:00
|
|
|
dst = expandvars(self.bundle_directory)
|
2022-12-24 15:30:32 +01:00
|
|
|
|
|
|
|
includes = [inc.strip() for inc in self.includes.split(',')]
|
|
|
|
excludes = [ex.strip() for ex in self.excludes.split(',')]
|
|
|
|
|
|
|
|
print(f'Copy Folder from {src} to {dst}...')
|
|
|
|
copy_dir(
|
|
|
|
src, dst, only_recent=True,
|
|
|
|
excludes=excludes, includes=includes
|
|
|
|
)
|
2022-12-30 23:36:09 +01:00
|
|
|
|
|
|
|
def filter_prop(self, prop):
|
2023-01-17 18:05:22 +01:00
|
|
|
if prop in ('template_info', 'template_video', 'template_image', 'blend_depth'):
|
2022-12-30 23:36:09 +01:00
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
# def draw_prop(self, layout, prop):
|
2023-01-17 18:05:22 +01:00
|
|
|
# if prop in ('template_info', 'template_video', 'template_image', 'blend_depth'):
|
2022-12-30 23:36:09 +01:00
|
|
|
# return
|
|
|
|
|
|
|
|
# super().draw_prop(layout)
|