start removing conform

This commit is contained in:
“christopheseux”
2022-12-28 17:44:15 +01:00
parent 92f275fcea
commit ab72a15a2c
6 changed files with 35 additions and 37 deletions
+14 -18
View File
@@ -1,5 +1,5 @@
from asset_library.common.functions import (norm_asset_datas,)
#from asset_library.common.functions import (norm_asset_datas,)
from asset_library.common.bl_utils import get_addon_prefs, load_datablocks
from asset_library.common.file_utils import read_file, write_file
from asset_library.common.template import Template
@@ -57,7 +57,7 @@ class AssetLibraryAdapter(PropertyGroup):
if self.is_conform:
return self.library.conform.directory
return self.library.bundle_dir
return self.library.bundle_directory
@property
def blend_depth(self):
@@ -359,16 +359,10 @@ class AssetLibraryAdapter(PropertyGroup):
print(f'Read cache from {self.cache_file}')
return self.read_file(self.cache_file)
def norm_asset_datas(self, asset_file_datas):
''' Return a new flat list of asset data
the filepath keys are merge with the assets keys
'''
return norm_asset_datas(asset_file_datas)
def write_cache(self, asset_datas):
path = self.cache_file
print(f'cache file writen to {path}')
return write_file(path, list(asset_datas))
def write_cache(self, asset_descriptions):
cache_path = self.cache_file
print(f'cache file writen to {cache_path}')
return write_file(cache_path, list(asset_descriptions))
def prop_rel_path(self, path, prop):
'''Get a filepath relative to a property of the adapter'''
@@ -686,13 +680,14 @@ class AssetLibraryAdapter(PropertyGroup):
self.generate_previews(asset_descriptions)
#print()
#print(cache)
#raise Exception()
elif isinstance(cache_diff, (Path, str)):
cache_diff = json.loads(Path(cache_diff).read_text(encoding='utf-8'))
if self.blend_depth == 0:
raise Exception('Blender depth must be 1 at min')
#groups = [(cache_diff)]
@@ -777,7 +772,7 @@ class AssetLibraryAdapter(PropertyGroup):
bpy.ops.wm.save_as_mainfile(filepath=str(blend_path), compress=True)
if write_cache:
self.write_cache(cache)
self.write_cache(asset_descriptions)
self.write_catalog(catalog_data)
@@ -851,10 +846,11 @@ class AssetLibraryAdapter(PropertyGroup):
def format_path(self, template, **kargs):
params = dict(self.to_dict(),
params = dict(
bundle_dir=Path(self.library.bundle_directory),
conform_dir=Path(self.library.conform.directory),
**kargs
**kargs,
**self.to_dict(),
)
return Template(template).format(params).resolve()
+2 -2
View File
@@ -19,9 +19,9 @@ class CopyFolderLibrary(AssetLibraryAdapter):
includes : StringProperty()
excludes : StringProperty()
def bundle(self):
def bundle(self, cache_diff=None):
src = expandvars(self.source_directory)
dst = expandvars(self.library_path)
dst = expandvars(self.target_directory)
includes = [inc.strip() for inc in self.includes.split(',')]
excludes = [ex.strip() for ex in self.excludes.split(',')]
+8 -7
View File
@@ -27,6 +27,7 @@ class KitsuLibrary(AssetLibraryAdapter):
name = "Kitsu"
template_name : StringProperty()
template_file : StringProperty()
source_directory : StringProperty(subtype='DIR_PATH')
url: StringProperty()
login: StringProperty()
@@ -65,15 +66,15 @@ class KitsuLibrary(AssetLibraryAdapter):
directory = directory or self.source_directory
return Path(directory, self.get_asset_relative_path(name, catalog))
def get_asset_description(self, data, path):
def get_asset_description(self, data, asset_path):
modified = time.time_ns()
catalog = data['entity_type_name']
asset_path = Path(path)
asset_name = self.norm_file_name(data['name'])
asset_path = self.prop_rel_path(asset_path, 'source_directory')
#asset_name = self.norm_file_name(data['name'])
asset_description = dict(
filepath=asset_path.as_posix(),
filepath=asset_path,
modified=modified,
library_id=self.library.id,
assets=[dict(
@@ -82,8 +83,8 @@ class KitsuLibrary(AssetLibraryAdapter):
description=data['description'],
tags=[],
type=self.data_type,
image=str(self.template_image.format(name=asset_name)),
video=str(self.template_video.format(name=asset_name)),
image=self.template_image.raw,
video=self.template_video.raw,
name=data['name'])
]
)
@@ -125,7 +126,7 @@ class KitsuLibrary(AssetLibraryAdapter):
asset_data['entity_type_name'] = entity_types_ids[asset_data.pop('entity_type_id')]
asset_name = asset_data['name']
asset_field_data = dict(name=asset_name, type=asset_data['entity_type_name'])
asset_field_data = dict(name=asset_name, type=asset_data['entity_type_name'], source_directory=self.source_directory)
try:
asset_field_data.update(template_name.parse(asset_name))