From c64040413db7bf18714a7dfd2a022e09a046cf81 Mon Sep 17 00:00:00 2001 From: aardschok Date: Tue, 27 Jun 2017 13:49:01 +0200 Subject: [PATCH] removed redundant modules --- .../plugins/maya/publish/collect_metadata.py | 39 ------- .../maya/publish/validate_latest_versions.py | 108 ------------------ 2 files changed, 147 deletions(-) delete mode 100644 colorbleed/plugins/maya/publish/collect_metadata.py delete mode 100644 colorbleed/plugins/maya/publish/validate_latest_versions.py diff --git a/colorbleed/plugins/maya/publish/collect_metadata.py b/colorbleed/plugins/maya/publish/collect_metadata.py deleted file mode 100644 index b5924c25de..0000000000 --- a/colorbleed/plugins/maya/publish/collect_metadata.py +++ /dev/null @@ -1,39 +0,0 @@ -import pyblish.api -import copy - - -class CollectMetadata(pyblish.api.ContextPlugin): - """Transfer context metadata to the instance. - - This applies a copy of the `context.data['metadata']` to the - `instance.data['metadata']` for the following metadata: - - Provides: - { - "topic": "topic", - "author": "user", - "date": "date", - "filename": "currentFile" - } - - - """ - order = pyblish.api.CollectorOrder + 0.2 - label = "Metadata" - - mapping = {"topic": "topic", - "author": "user", - "date": "date", - "filename": "currentFile"} - - def process(self, context): - - metadata = {} - for key, source in self.mapping.iteritems(): - if source in context.data: - metadata[key] = context.data.get(source) - - for instance in context: - instance.data["metadata"] = copy.deepcopy(metadata) - - self.log.info("Collected {0}".format(metadata)) diff --git a/colorbleed/plugins/maya/publish/validate_latest_versions.py b/colorbleed/plugins/maya/publish/validate_latest_versions.py deleted file mode 100644 index 0b7d2dd826..0000000000 --- a/colorbleed/plugins/maya/publish/validate_latest_versions.py +++ /dev/null @@ -1,108 +0,0 @@ -import os - -from maya import cmds - -import pyblish.api -import colorbleed.api - -import cbra.lib -from cb.utils.python.decorators import memorize - - -def is_latest_version(path): - """Return whether path is the latest version. - - Args: - path (str): Full path to published file. - - Returns: - bool: Whether the path belongs to the latest version. - - """ - - ctx = cbra.lib.parse_context(path) - versions = cbra.lib.list_versions(ctx) - highest = cbra.lib.find_highest_version(versions) - - if ctx.get('version', None) != highest: - return False - else: - return True - - -@memorize -def is_latest_version_cached(path): - """Memorized cached wrapper to `is_latest_version`""" - return is_latest_version(path) - - -class ValidateLatestVersions(pyblish.api.InstancePlugin): - """Validates content included is using latest published versions. - - If published contents are out of date they can be easily updated to the - latest version using the scripts > pyblish > utilities > update_xxx for - the corresponding node type. - - """ - - order = colorbleed.api.ValidateContentsOrder - families = ['colorbleed.layout'] - label = "Latest Versions" - actions = [colorbleed.api.SelectInvalidAction] - optional = True - - # (node_type, attribute) that are non-referenced to check paths for - LOCAL_CHECKS = { - "gpuCache": "cacheFileName", - "VRayMesh": "fileName2" - } - - @classmethod - def get_invalid(cls, instance): - - all_nodes = instance[:] - invalid = list() - - # check non-referenced nodes - for node_type, attr in cls.LOCAL_CHECKS.iteritems(): - - nodes = cmds.ls(all_nodes, type=node_type, long=True) - referenced = cmds.ls(nodes, referencedNodes=True, long=True) - non_referenced = [n for n in nodes if n not in referenced] - - for node in non_referenced: - - path = cmds.getAttr("{0}.{1}".format(node, attr)) - path = os.path.normpath(path) - if not is_latest_version_cached(path): - invalid.append(node) - - # reference nodes related to this isntance - referenced = cmds.ls(all_nodes, long=True, referencedNodes=True) - referenced_nodes = set(cmds.referenceQuery(reference, referenceNode=True) - for reference in referenced) - - for reference in referenced_nodes: - path = cmds.referenceQuery(reference, - filename=True, - withoutCopyNumber=True) - path = os.path.normpath(path) - if not is_latest_version_cached(path): - invalid.append(reference) - - return invalid - - def process(self, instance): - - # Clear cache only once per publish. So we store a value on - # the context on the first instance so we clear only once. - name = self.__class__.__name__ - key = "_plugin_{0}_processed".format(name) - if not instance.context.data.get(key, False): - is_latest_version_cached.cache.clear() - instance.context.data[key] = True - - invalid = self.get_invalid(instance) - if invalid: - raise RuntimeError("Used Items are not updated to latest versions:" - "{0}".format(invalid)) \ No newline at end of file