mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
renamed 'attributes' to 'required_keys' and 'optional_attributes' to 'optional_keys'
This commit is contained in:
parent
8b7531b977
commit
2d7910a264
2 changed files with 28 additions and 15 deletions
|
|
@ -98,11 +98,11 @@ class MayaPlaceholder(AbstractPlaceholder):
|
|||
"""Concrete implementation of AbstractPlaceholder for maya
|
||||
"""
|
||||
|
||||
optional_attributes = {'asset', 'subset', 'hierarchy'}
|
||||
optional_keys = {'asset', 'subset', 'hierarchy'}
|
||||
|
||||
def get_data(self, node):
|
||||
user_data = dict()
|
||||
for attr in self.attributes.union(self.optional_attributes):
|
||||
for attr in self.required_keys.union(self.optional_keys):
|
||||
attribute_name = '{}.{}'.format(node, attr)
|
||||
if not cmds.attributeQuery(attr, node=node, exists=True):
|
||||
print("{} not found".format(attribute_name))
|
||||
|
|
@ -112,7 +112,9 @@ class MayaPlaceholder(AbstractPlaceholder):
|
|||
asString=True)
|
||||
user_data['parent'] = (
|
||||
cmds.getAttr(node + '.parent', asString=True)
|
||||
or node.rpartition('|')[0] or "")
|
||||
or node.rpartition('|')[0]
|
||||
or ""
|
||||
)
|
||||
user_data['node'] = node
|
||||
if user_data['parent']:
|
||||
siblings = cmds.listRelatives(user_data['parent'], children=True)
|
||||
|
|
|
|||
|
|
@ -377,15 +377,17 @@ class AbstractTemplateLoader:
|
|||
|
||||
@six.add_metaclass(ABCMeta)
|
||||
class AbstractPlaceholder:
|
||||
"""Abstraction of placeholders logic
|
||||
"""Abstraction of placeholders logic.
|
||||
|
||||
Properties:
|
||||
attributes: A list of mandatory attribute to decribe placeholder
|
||||
required_keys: A list of mandatory keys to decribe placeholder
|
||||
and assets to load.
|
||||
optional_attributes: A list of optional attribute to decribe
|
||||
optional_keys: A list of optional keys to decribe
|
||||
placeholder and assets to load
|
||||
loader: Name of linked loader to use while loading assets
|
||||
is_context: Is placeholder linked
|
||||
to context asset (or to linked assets)
|
||||
|
||||
Methods:
|
||||
is_repres_valid:
|
||||
loader:
|
||||
|
|
@ -395,9 +397,15 @@ class AbstractPlaceholder:
|
|||
parent_in_hierachy:
|
||||
"""
|
||||
|
||||
attributes = {'builder_type', 'family', 'representation',
|
||||
'order', 'loader', 'loader_args'}
|
||||
optional_attributes = {}
|
||||
required_keys = {
|
||||
"builder_type",
|
||||
"family",
|
||||
"representation",
|
||||
"order",
|
||||
"loader",
|
||||
"loader_args"
|
||||
}
|
||||
optional_keys = {}
|
||||
|
||||
def __init__(self, node):
|
||||
self._log = None
|
||||
|
|
@ -459,15 +467,18 @@ class AbstractPlaceholder:
|
|||
return self.data.get('builder_type') == 'context_asset'
|
||||
|
||||
def is_valid(self):
|
||||
"""Test validity of placeholder
|
||||
i.e.: every attributes exists in placeholder data
|
||||
"""Test validity of placeholder.
|
||||
|
||||
i.e.: every required key exists in placeholder data
|
||||
|
||||
Returns:
|
||||
Bool: True if every attributes are a key of data
|
||||
bool: True if every key is in data
|
||||
"""
|
||||
if set(self.attributes).issubset(self.data.keys()):
|
||||
self.log.debug("Valid placeholder: {}".format(self.data["node"]))
|
||||
|
||||
if set(self.required_keys).issubset(self.data.keys()):
|
||||
self.log.debug("Valid placeholder : {}".format(self.name))
|
||||
return True
|
||||
self.log.info("Placeholder is not valid: {}".format(self.data["node"]))
|
||||
self.log.info("Placeholder is not valid : {}".format(self.name))
|
||||
return False
|
||||
|
||||
@abstractmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue