From 6914371872f0efa65d33016b03994bdc192f70da Mon Sep 17 00:00:00 2001 From: Ondrej Samohel Date: Wed, 16 Oct 2019 13:10:54 +0200 Subject: [PATCH] fixed cache loader --- pype/plugins/maya/load/load_yeti_cache.py | 21 ++++++++++++------- .../maya/publish/extract_yeti_cache.py | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/pype/plugins/maya/load/load_yeti_cache.py b/pype/plugins/maya/load/load_yeti_cache.py index dc976c0c98..a1793cd67d 100644 --- a/pype/plugins/maya/load/load_yeti_cache.py +++ b/pype/plugins/maya/load/load_yeti_cache.py @@ -39,8 +39,10 @@ class YetiCacheLoader(api.Loader): cmds.loadPlugin("pgYetiMaya", quiet=True) # Get JSON - fname, ext = os.path.splitext(self.fname) - settings_fname = "{}.fursettings".format(fname) + fbase = re.search(r'^(.+)\.(\d+|#+)\.fur', self.fname) + if not fbase: + raise RuntimeError('Cannot determine fursettings file path') + settings_fname = "{}.fursettings".format(fbase.group(1)) with open(settings_fname, "r") as fp: fursettings = json.load(fp) @@ -102,7 +104,6 @@ class YetiCacheLoader(api.Loader): namespace = container["namespace"] container_node = container["objectName"] path = api.get_representation_path(representation) - # Get all node data fname, ext = os.path.splitext(path) settings_fname = "{}.fursettings".format(fname) @@ -151,7 +152,8 @@ class YetiCacheLoader(api.Loader): # Update cache file name file_name = data["name"].replace(":", "_") cache_file_path = "{}.%04d.fur".format(file_name) - data["attrs"]["cacheFileName"] = os.path.join(path, cache_file_path) + data["attrs"]["cacheFileName"] = os.path.join( + path, cache_file_path) if cb_id not in scene_lookup: @@ -284,10 +286,15 @@ class YetiCacheLoader(api.Loader): attributes = node_settings["attrs"] # Check if cache file name is stored + + # get number of # in path and convert it to C prinf format + # like %04d expected by Yeti + fbase = re.search(r'^(.+)\.(\d+|#+)\.fur', self.fname) + if not fbase: + raise RuntimeError('Cannot determine file path') + padding = len(fbase.group(2)) if "cacheFileName" not in attributes: - file_name = original_node.replace(":", "_") - cache_name = "{}.%04d.fur".format(file_name) - cache = os.path.join(self.fname, cache_name) + cache = "{}.%0{}d.fur".format(fbase.group(1), padding) self.validate_cache(cache) attributes["cacheFileName"] = cache diff --git a/pype/plugins/maya/publish/extract_yeti_cache.py b/pype/plugins/maya/publish/extract_yeti_cache.py index 7d57578b14..8cb94021ed 100644 --- a/pype/plugins/maya/publish/extract_yeti_cache.py +++ b/pype/plugins/maya/publish/extract_yeti_cache.py @@ -69,7 +69,7 @@ class ExtractYetiCache(pype.api.Extractor): self.log.info("cache files: {}".format(cache_files[0])) instance.data["representations"].append( { - 'name': cache_files[0].split(".")[0], + 'name': 'fur', 'ext': 'fur', 'files': cache_files[0] if len(cache_files) == 1 else cache_files, 'stagingDir': dirname,