hierarchy is set to empty string if no parents

This commit is contained in:
Jakub Trllo 2019-02-06 19:59:00 +01:00
parent d679756360
commit f43b1d8cde
5 changed files with 23 additions and 13 deletions

View file

@ -406,7 +406,9 @@ def get_data(entity, session, custom_attributes):
{'type': 'asset', 'name': parName}
)['_id']
hierarchy = os.path.sep.join(folderStruct)
hierarchy = ""
if len(folderStruct) > 0:
hierarchy = os.path.sep.join(folderStruct)
data['visualParent'] = parentId
data['parents'] = folderStruct

View file

@ -180,13 +180,14 @@ class AppAction(BaseHandler):
os.environ["AVALON_APP_NAME"] = self.identifier
anatomy = pype.Anatomy
hierarchy = database[project_name].find_one({
hierarchy = ""
parents = database[project_name].find_one({
"type": 'asset',
"name": entity['parent']['name']
})['data']['parents']
if hierarchy:
hierarchy = os.path.join(*hierarchy)
if parents:
hierarchy = os.path.join(*parents)
data = {"project": {"name": entity['project']['full_name'],
"code": entity['project']['name']},

View file

@ -141,10 +141,14 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
# \|________|
#
root = api.registered_root()
hierarchy = io.find_one({"type": 'asset', "name": ASSET})['data']['parents']
if hierarchy:
hierarchy = ""
parents = io.find_one({
"type": 'asset',
"name": ASSET
})['data']['parents']
if parents and len(parents) > 0:
# hierarchy = os.path.sep.join(hierarchy)
hierarchy = os.path.join(*hierarchy)
hierarchy = os.path.join(*parents)
template_data = {"root": root,
"project": {"name": PROJECT,

View file

@ -139,11 +139,12 @@ class IntegrateFrames(pyblish.api.InstancePlugin):
# \|________|
#
root = api.registered_root()
hierarchy = io.find_one({"type": 'asset', "name": ASSET})[
hierarchy = ""
parents = io.find_one({"type": 'asset', "name": ASSET})[
'data']['parents']
if hierarchy:
if parents and len(parents) > 0:
# hierarchy = os.path.sep.join(hierarchy)
hierarchy = os.path.join(*hierarchy)
hierarchy = os.path.join(*parents)
template_data = {"root": root,
"project": {"name": PROJECT,

View file

@ -167,14 +167,16 @@ def get_hierarchy():
string: asset hierarchy path
"""
hierarchy = io.find_one({
parents = io.find_one({
"type": 'asset',
"name": get_asset()}
)['data']['parents']
if hierarchy:
hierarchy = ""
if parents and len(parents) > 0:
# hierarchy = os.path.sep.join(hierarchy)
return os.path.join(*hierarchy).replace("\\", "/")
hierarchy = os.path.join(*parents).replace("\\", "/")
return hierarchy
def set_hierarchy(hierarchy):