Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Perform process step `process` upon context `context`
Arguments:
process (str): Type of process to apply
context (Context): Context upon which to appy process
Example:
>>> ctx = Context()
>>> process('validators', ctx)
Context([])
"""
assert isinstance(context, Context)
plugins = publish.plugin.discover(type=process)
for instance in context:
family = instance.config.get('family')
log.info("Processing {inst} ({family})".format(
inst=instance, family=family))
# Run tests for pre-defined host and family
for PluginClass in plugins:
plugin = PluginClass(context)
if not current_host() in plugin.hosts:
continue
if not family in plugin.families:
continue
import publish.lib
import publish.config
import publish.plugin
import maya.cmds as cmds
@publish.lib.log
class SelectObjectSet(publish.plugin.Selector):
"""Select instances of node-type 'transform'
Opens up the doors for instances containing nodes of any type,
but lacks the ability to be nested with DAG nodes.
E.g. -> /root/MyCharacter.publishable/an_object_set
"""
hosts = ['maya']
version = (0, 1, 0)
def process(self, context):
for objset in cmds.ls("*." + publish.config.identifier,
objectsOnly=True,
type='objectSet'):
import os
# Publish libraries
import publish.plugin
# Host libraries
from maya import mel
from maya import cmds
# Register accompanying plugins
plugin_path = os.path.join(
os.path.dirname(
publish.plugin.__file__), 'integration', 'maya', 'plugins')
publish.plugin.register_plugin_path(plugin_path)
print "Registered %s" % plugin_path
def eval_append_to_filemenu():
"""Add Publish to file-menu
.. note:: We're going a bit hacky here, probably due to my lack
of understanding for `evalDeferred` or `executeDeferred`,
so if you can think of a better solution, feel free to edit.
"""
# As Maya builds its menus dynamically upon being accessed,
# we force its build here prior to adding our entry using it's
# native mel function call.
mel.eval("evalDeferred buildFileMenu")
# Standard library
import os
# Publish libraries
import publish.plugin
# Host libraries
from maya import mel
from maya import cmds
# Register accompanying plugins
plugin_path = os.path.join(
os.path.dirname(
publish.plugin.__file__), 'integration', 'maya', 'plugins')
publish.plugin.register_plugin_path(plugin_path)
print "Registered %s" % plugin_path
def eval_append_to_filemenu():
"""Add Publish to file-menu
.. note:: We're going a bit hacky here, probably due to my lack
of understanding for `evalDeferred` or `executeDeferred`,
so if you can think of a better solution, feel free to edit.
"""
# As Maya builds its menus dynamically upon being accessed,
# we force its build here prior to adding our entry using it's
import publish.plugin
class ValidateUniqueNames(publish.plugin.Validator):
@property
def families(self):
return ['model', 'animation', 'animRig']
@property
def hosts(self):
return ['maya']
@property
def version(self):
return (0, 1, 0)
def process(self):
pass
import publish.plugin
import publish.config
import maya.cmds as cmds
class SelectTransform(publish.plugin.Selector):
"""Select instances of node-type 'transform'
Opens up the doors for nested instances.
E.g. -> /root/characters_GRP/MyCharacter.publishable
As opposed to -> /root/MyCharacter.publishable
But lacks ability to append non-DAG nodes.
E.g. -> /root/MyCharacter.publishable/an_object_set
"""
@property
def hosts(self):
return ['maya']
import publish.plugin
import pymel.core as pm
class ValidateMeshHistory(publish.plugin.Validator):
"""Check meshes for construction history"""
@property
def families(self):
return ['model']
@property
def hosts(self):
return ['maya']
@property
def version(self):
return (0, 1, 0)
def process(self):
for node in self.instance:
import publish.plugin
from maya import cmds
class ValidateMutedChannels(publish.plugin.Validator):
"""Ensure no muted channels exists in scene
Todo: Ensure no muted channels are associated with involved nodes
At the moment, the entire scene is checked.
"""
@property
def families(self):
return ['model']
@property
def hosts(self):
return ['maya']
@property