本文整理匯總了Python中shotgun_api3.Shotgun.batch方法的典型用法代碼示例。如果您正苦於以下問題:Python Shotgun.batch方法的具體用法?Python Shotgun.batch怎麽用?Python Shotgun.batch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類shotgun_api3.Shotgun
的用法示例。
在下文中一共展示了Shotgun.batch方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: shotgun
# 需要導入模塊: from shotgun_api3 import Shotgun [as 別名]
# 或者: from shotgun_api3.Shotgun import batch [as 別名]
#find all the users that have skype-id's
users= sg.find("HumanUser",filters,fields)
#initialize an empty list to contain shotgun update requests
batch_data = []
#process all users checking to see if button data is correct for the user name
# (this is in case a skype user name changes) or if there is not a button
for user in users:
# put skype user name into template to create button html code
skype_button_text = button_template.safe_substitute(skype_id=user[SKYPE_ID_FIELD])
skype_contact_text = contact_template.safe_substitute(skype_id=user[SKYPE_ID_FIELD])
if user[SKYPE_BUTTON_FIELD] <> skype_button_text:
#set the skype button html into the user container
user[SKYPE_BUTTON_FIELD] = skype_button_text
user[SKYPE_ADD_CONTACT_FIELD] = skype_contact_text
#remove extraneous data from user so that it can put into an update request
user_id = user.pop('id')
dummy = user.pop('type')
#append the update to the batch list
batch_data.append( {'request_type':'update' , 'entity_type':'HumanUser' , 'entity_id': user_id , 'data':user})
# when done, process the updates to the users with a single call to shotgun (if necessary)
if batch_data:
sg.batch(batch_data)