From 85a03bd2d7f41dddbeeb6e367d6760a65dd455f1 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Fri, 19 Mar 2021 14:54:22 +0100 Subject: [PATCH] implemented method that can convert changes string to value --- .../event_sync_to_avalon.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pype/modules/ftrack/event_handlers_server/event_sync_to_avalon.py b/pype/modules/ftrack/event_handlers_server/event_sync_to_avalon.py index a9e1f4282d..443e428c01 100644 --- a/pype/modules/ftrack/event_handlers_server/event_sync_to_avalon.py +++ b/pype/modules/ftrack/event_handlers_server/event_sync_to_avalon.py @@ -1,6 +1,7 @@ import os import collections import copy +import json import queue import time import datetime @@ -10,6 +11,7 @@ import traceback from bson.objectid import ObjectId from pymongo import UpdateOne +import arrow import ftrack_api from avalon import schema @@ -1860,6 +1862,41 @@ class SyncToAvalonEvent(BaseEvent): ) ) + def convert_value_by_cust_attr_conf(self, value, cust_attr_conf): + type_id = cust_attr_conf["type_id"] + cust_attr_type_name = self.cust_attr_types_by_id[type_id]["name"] + ignored = ( + "expression", "notificationtype", "dynamic enumerator" + ) + if cust_attr_type_name in ignored: + return None + + if cust_attr_type_name == "text": + return value + + if cust_attr_type_name == "boolean": + if value == "1": + return True + if value == "0": + return False + return bool(value) + + if cust_attr_type_name == "date": + return arrow.get(value) + + cust_attr_config = json.loads(cust_attr_conf["config"]) + + if cust_attr_type_name == "number": + if cust_attr_config["isdecimal"]: + return float(value) + return int(value) + + if cust_attr_type_name == "enumerator": + if not cust_attr_config["multiSelect"]: + return value + return value.split(", ") + return value + def process_hier_cleanup(self): if ( not self.moved_in_avalon and