mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-27 06:12:19 +01:00
cleanup and constans variables are with camel case
This commit is contained in:
parent
e2663fff89
commit
05e60fd3de
8 changed files with 35 additions and 38 deletions
|
|
@ -6,7 +6,7 @@ import arrow
|
|||
import logging
|
||||
import ftrack_api
|
||||
from pype.ftrack import BaseAction
|
||||
from pype.ftrack.lib.avalon_sync import cust_attr_id_key
|
||||
from pype.ftrack.lib.avalon_sync import CustAttrIdKey
|
||||
from pypeapp import config
|
||||
from ftrack_api.exception import NoResultFoundError
|
||||
|
||||
|
|
@ -207,7 +207,7 @@ class CustomAttributes(BaseAction):
|
|||
group = self.get_group('avalon')
|
||||
|
||||
data = {}
|
||||
data['key'] = cust_attr_id_key
|
||||
data['key'] = CustAttrIdKey
|
||||
data['label'] = cust_attr_label
|
||||
data['type'] = custom_attribute_type
|
||||
data['default'] = ''
|
||||
|
|
|
|||
|
|
@ -2,13 +2,10 @@ import os
|
|||
import json
|
||||
|
||||
from ruamel import yaml
|
||||
import ftrack_api
|
||||
from pype.ftrack import BaseAction
|
||||
from pypeapp import config
|
||||
from pype.ftrack.lib.avalon_sync import get_avalon_attr
|
||||
|
||||
from ftrack_api import session as fa_session
|
||||
|
||||
|
||||
class PrepareProject(BaseAction):
|
||||
'''Edit meta data action.'''
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from pype.ftrack.lib import avalon_sync, BaseEvent
|
||||
from pype.ftrack.lib import BaseEvent
|
||||
from pype.ftrack.lib.avalon_sync import CustAttrIdKey
|
||||
from pype.ftrack.events.event_sync_to_avalon import SyncToAvalonEvent
|
||||
|
||||
|
||||
|
|
@ -28,7 +29,7 @@ class DelAvalonIdFromNew(BaseEvent):
|
|||
|
||||
elif (
|
||||
entity.get('action', None) == 'update' and
|
||||
avalon_sync.cust_attr_id_key in entity['keys'] and
|
||||
CustAttrIdKey in entity['keys'] and
|
||||
entity_id in created
|
||||
):
|
||||
ftrack_entity = session.get(
|
||||
|
|
@ -37,13 +38,11 @@ class DelAvalonIdFromNew(BaseEvent):
|
|||
)
|
||||
|
||||
cust_attr = ftrack_entity['custom_attributes'][
|
||||
avalon_sync.cust_attr_id_key
|
||||
CustAttrIdKey
|
||||
]
|
||||
|
||||
if cust_attr != '':
|
||||
ftrack_entity['custom_attributes'][
|
||||
avalon_sync.cust_attr_id_key
|
||||
] = ''
|
||||
ftrack_entity['custom_attributes'][CustAttrIdKey] = ''
|
||||
session.commit()
|
||||
|
||||
except Exception:
|
||||
|
|
@ -53,5 +52,4 @@ class DelAvalonIdFromNew(BaseEvent):
|
|||
|
||||
def register(session, plugins_presets):
|
||||
'''Register plugin. Called when used as an plugin.'''
|
||||
|
||||
DelAvalonIdFromNew(session, plugins_presets).register()
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ from pype.ftrack import BaseEvent
|
|||
|
||||
class SyncAllAutoSyncProjects(BaseEvent):
|
||||
ignore_me = True
|
||||
"""Trigger sychronization of each project where auto sync is set."""
|
||||
|
||||
def register(self):
|
||||
'''Registers the event, subscribing the discover and launch topics.'''
|
||||
"""Registers the event, subscribing the discover and launch topics."""
|
||||
self.session.event_hub.subscribe(
|
||||
'topic=pype.storer.started',
|
||||
"topic=pype.storer.started",
|
||||
self.launch
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from avalon import schema
|
|||
|
||||
from pype.ftrack.lib import avalon_sync
|
||||
from pype.ftrack.lib.avalon_sync import (
|
||||
cust_attr_id_key, cust_attr_auto_sync, entity_schemas
|
||||
CustAttrIdKey, CustAttrAutoSync, EntitySchemas
|
||||
)
|
||||
import ftrack_api
|
||||
from ftrack_api import session as fa_session
|
||||
|
|
@ -515,10 +515,10 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
continue
|
||||
|
||||
changes = ent_info["changes"]
|
||||
if cust_attr_auto_sync not in changes:
|
||||
if CustAttrAutoSync not in changes:
|
||||
continue
|
||||
|
||||
auto_sync = changes[cust_attr_auto_sync]["new"]
|
||||
auto_sync = changes[CustAttrAutoSync]["new"]
|
||||
if auto_sync == "1":
|
||||
# Trigger sync to avalon action if auto sync was turned on
|
||||
ft_project = self.cur_project
|
||||
|
|
@ -552,17 +552,17 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
|
||||
ft_project = self.cur_project
|
||||
# Check if auto-sync custom attribute exists
|
||||
if cust_attr_auto_sync not in ft_project["custom_attributes"]:
|
||||
if CustAttrAutoSync not in ft_project["custom_attributes"]:
|
||||
# TODO should we sent message to someone?
|
||||
# TODO report
|
||||
self.log.error((
|
||||
"Custom attribute \"{}\" is not created or user \"{}\" used"
|
||||
" for Event server don't have permissions to access it!"
|
||||
).format(cust_attr_auto_sync, self.session.api_user))
|
||||
).format(CustAttrAutoSync, self.session.api_user))
|
||||
return True
|
||||
|
||||
# Skip if auto-sync is not set
|
||||
auto_sync = ft_project["custom_attributes"][cust_attr_auto_sync]
|
||||
auto_sync = ft_project["custom_attributes"][CustAttrAutoSync]
|
||||
if auto_sync is not True:
|
||||
self.log.debug("Auto sync is not turned on")
|
||||
return True
|
||||
|
|
@ -746,7 +746,7 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
|
||||
new_entity["custom_attributes"][key] = val
|
||||
|
||||
new_entity["custom_attributes"][cust_attr_id_key] = (
|
||||
new_entity["custom_attributes"][CustAttrIdKey] = (
|
||||
str(avalon_entity["_id"])
|
||||
)
|
||||
try:
|
||||
|
|
@ -951,7 +951,7 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
"_id": mongo_id,
|
||||
"name": name,
|
||||
"type": "asset",
|
||||
"schema": entity_schemas["asset"],
|
||||
"schema": EntitySchemas["asset"],
|
||||
"parent": proj["_id"],
|
||||
"data": {
|
||||
"ftrackId": ftrack_ent["id"],
|
||||
|
|
@ -993,7 +993,7 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
if not replaced:
|
||||
self.dbcon.insert_one(final_entity)
|
||||
|
||||
ftrack_ent["custom_attributes"][cust_attr_id_key] = str(mongo_id)
|
||||
ftrack_ent["custom_attributes"][CustAttrIdKey] = str(mongo_id)
|
||||
try:
|
||||
self.process_session.commit()
|
||||
except Exception:
|
||||
|
|
@ -1259,7 +1259,7 @@ class SyncToAvalonEvent(BaseEvent):
|
|||
configuration_id = None
|
||||
for attr in cust_attrs:
|
||||
key = attr["key"]
|
||||
if key == cust_attr_id_key:
|
||||
if key == CustAttrIdKey:
|
||||
configuration_id = attr["id"]
|
||||
break
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import ftrack_api
|
||||
from pype.ftrack import BaseEvent
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
import ftrack_api
|
||||
from pype.ftrack import BaseEvent
|
||||
from pype.ftrack.lib import avalon_sync
|
||||
from pype.ftrack.lib.io_nonsingleton import DbConnector
|
||||
from bson.objectid import ObjectId
|
||||
from pypeapp import config
|
||||
from pypeapp import Anatomy
|
||||
import subprocess
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from pype.ftrack import BaseEvent
|
||||
from pype.ftrack.lib.avalon_sync import CustAttrIdKey
|
||||
from pype.ftrack.lib.io_nonsingleton import DbConnector
|
||||
|
||||
from bson.objectid import ObjectId
|
||||
|
||||
from pypeapp import config
|
||||
from pypeapp import Anatomy
|
||||
|
||||
|
||||
class UserAssigmentEvent(BaseEvent):
|
||||
|
|
@ -37,7 +39,6 @@ class UserAssigmentEvent(BaseEvent):
|
|||
"""
|
||||
|
||||
db_con = DbConnector()
|
||||
ca_mongoid = avalon_sync.cust_attr_id_key
|
||||
|
||||
def error(self, *err):
|
||||
for e in err:
|
||||
|
|
@ -106,7 +107,7 @@ class UserAssigmentEvent(BaseEvent):
|
|||
self.db_con.Session['AVALON_PROJECT'] = task['project']['full_name']
|
||||
|
||||
avalon_entity = None
|
||||
parent_id = parent['custom_attributes'].get(self.ca_mongoid)
|
||||
parent_id = parent['custom_attributes'].get(CustAttrIdKey)
|
||||
if parent_id:
|
||||
parent_id = ObjectId(parent_id)
|
||||
avalon_entity = self.db_con.find_one({
|
||||
|
|
|
|||
|
|
@ -20,15 +20,15 @@ log = Logger().get_logger(__name__)
|
|||
|
||||
|
||||
# Current schemas for avalon types
|
||||
entity_schemas = {
|
||||
EntitySchemas = {
|
||||
"project": "avalon-core:project-2.0",
|
||||
"asset": "avalon-core:asset-3.0",
|
||||
"config": "avalon-core:config-1.0"
|
||||
}
|
||||
|
||||
# name of Custom attribute that stores mongo_id from avalon db
|
||||
cust_attr_id_key = "avalon_mongo_id"
|
||||
cust_attr_auto_sync = "avalon_auto_sync"
|
||||
CustAttrIdKey = "avalon_mongo_id"
|
||||
CustAttrAutoSync = "avalon_auto_sync"
|
||||
|
||||
|
||||
def check_regex(name, entity_type, in_schema=None, schema_patterns=None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue