本文整理汇总了Python中ShotgunORM类的典型用法代码示例。如果您正苦于以下问题:Python ShotgunORM类的具体用法?Python ShotgunORM怎么用?Python ShotgunORM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ShotgunORM类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fromSg
def fromSg(cls, sgSchema, sgEntityName, sgEntityLabel, sgFieldSchemas):
'''
From the passed Shotgun schema info a new SgEntitySchemaInfo is returned.
'''
fieldInfos = {}
fieldInfosUnsupported = {}
for fieldName, schemaData in sgFieldSchemas.items():
if fieldName.startswith('step_'):
continue
fieldInfo = ShotgunORM.SgFieldSchemaInfo.fromSg(sgEntityName, sgEntityLabel, fieldName, schemaData)
# Skip fields that have an unsupported return type!
if fieldInfo.returnType() == ShotgunORM.SgField.RETURN_TYPE_UNSUPPORTED:
ShotgunORM.LoggerSchema.warn(
'ignoring unsupported return type "%s", %s.%s' % (
fieldInfo.returnTypeName(),
sgEntityName, fieldInfo.name()
)
)
fieldInfosUnsupported[fieldName] = fieldInfo
else:
fieldInfos[fieldName] = fieldInfo
result = cls(sgSchema, sgEntityName, sgEntityLabel, fieldInfos, fieldInfosUnsupported)
try:
ShotgunORM.onEntitySchemaInfoCreate(result)
except Exception, e:
ShotgunORM.LoggerORM.warn(e)
示例2: changed
def changed(self):
'''
Called whenever the schemas info changes.
Calls SgSchema._changed() and then ShotgunORM.onSchemaChanged() callback.
'''
self._changed()
ShotgunORM.onSchemaChanged(self)
示例3: _sg_find_one
def _sg_find_one(
self,
entity_type,
filters=[],
fields=None,
order=None,
filter_operator=None,
retired_only=False,
):
'''
Calls the Shotgun Python API find_one function.
This will lock the global Shotgun Python API lock.
'''
if fields != None:
fields = list(fields)
with ShotgunORM.SHOTGUN_API_LOCK:
result = self.connection().find_one(
entity_type,
filters,
fields,
order,
filter_operator,
retired_only,
)
return ShotgunORM.onSearchResult(
self,
entity_type,
fields,
[result]
)[0]
示例4: toLogicalOp
def toLogicalOp(self, sgConnection, operator='and'):
'''
Returns a SgLogicalOp of this search filter.
'''
if operator != 'and' and operator != 'or':
raise ValueError('invalid operator name "%s"' % operator)
logical_op = ShotgunORM.SgLogicalOp()
e_info = sgConnection.schema().entityInfo(self._entity_type)
filters = self.toSearchFilters()
for i in self._filters:
if i.isLogicalOp() == True:
logical_op.appendCondition(i)
else:
op_cond = ShotgunORM.convertToLogicalOpCond(
e_info,
i.toFilter()
)
logical_op.appendCondition(
ShotgunORM.SgLogicalOpCondition(**op_cond)
)
return logical_op
示例5: fromFieldData
def fromFieldData(self, sgData):
'''
Sets the fields value from data returned by a Shotgun query.
Returns True on success.
Args:
* (dict) sgData:
Dict of Shotgun formatted Entity field values.
'''
with self:
ShotgunORM.LoggerField.debug('%(sgField)s.fromFieldData()', {'sgField': self})
ShotgunORM.LoggerField.debug(' * sgData: %(sgData)s', {'sgData': sgData})
parent = self.parentEntity()
if not self.isEditable():
raise RuntimeError('%s is not editable!' % ShotgunORM.mkEntityFieldString(self))
if not ShotgunORM.config.DISABLE_FIELD_VALIDATE_ON_SET_VALUE:
self.validate(forReal=True)
result = self._fromFieldData(sgData)
if not result:
return False
self.setValid(True)
self.setHasCommit(True)
self.changed()
return True
示例6: facility
def facility(self):
'''
Returns the facility name from the Shotgun url.
'''
if self._facility == None:
self._facility = ShotgunORM.facilityNameFromUrl(self._url)
return self._facility
示例7: fromXML
def fromXML(cls, sgSchema, sgXmlElement):
'''
From the passed XML data a new SgEntitySchemaInfo is returned.
'''
if sgXmlElement.tag != 'SgEntity':
raise RuntimeError('invalid tag "%s"' % sgXmlElement.tag)
entityFieldInfos = {}
entityFieldInfosUnsupported = {}
fields = sgXmlElement.find('fields')
if fields == None:
raise RuntimeError('could not find fields element')
entityName = sgXmlElement.attrib.get('name')
entityLabel = sgXmlElement.attrib.get('label')
for field in fields:
# Skip fields that have an unsupported return type!
fieldInfo = ShotgunORM.SgFieldSchemaInfo.fromXML(entityName, entityLabel, field)
if fieldInfo.returnType() == ShotgunORM.SgField.RETURN_TYPE_UNSUPPORTED:
ShotgunORM.LoggerEntity.warning('field %s.%s ignored because of return type unsupported' % (fieldInfo.name(), entityName))
entityFieldInfosUnsupported[fieldInfo.name()] = fieldInfo
else:
entityFieldInfos[fieldInfo.name()] = fieldInfo
result = cls(
sgSchema,
entityName,
entityLabel,
entityFieldInfos,
entityFieldInfosUnsupported
)
try:
ShotgunORM.onEntitySchemaInfoCreate(result)
except Exception, e:
ShotgunORM.LoggerORM.warn(e)
示例8: searchIterator
def searchIterator(
self,
sgEntityType,
sgSearchExp,
sgFields=None,
sgSearchArgs=[],
order=None,
filter_operator=None,
limit=100,
retired_only=False,
page=1,
include_archived_projects=True,
additional_filter_presets=None,
buffered=False
):
'''
Returns a SgSearchIterator which is used to iterate over the search filter
by page.
'''
schema = self.schema()
sgEntityType = schema.entityApiName(sgEntityType)
sgFilters = ShotgunORM.parseToLogicalOp(
schema.entityInfo(sgEntityType),
sgSearchExp,
sgSearchArgs
)
sgFilters = self._flattenFilters(sgFilters)
iterClass = None
if buffered:
iterClass = ShotgunORM.SgBufferedSearchIterator
else:
iterClass = ShotgunORM.SgSearchIterator
return iterClass(
self,
sgEntityType,
sgFilters,
sgFields,
order,
filter_operator,
limit,
retired_only,
page,
include_archived_projects,
additional_filter_presets
)
示例9: fieldChanged
def fieldChanged(self, sgField):
'''
Called when a field changes values.
If SgEntity.widget() is not None then SgEntity.widget().fieldChanged()
will be called as well.
Args:
* (SgField) sgField:
Field that changed.
'''
ShotgunORM.LoggerEntity.debug('%(entity)s.fieldChanged("%(sgField)s")', {'entity': self, 'sgField': sgField.name()})
self._fieldChanged(sgField)
w = self.widget()
if w != None:
w.fieldChanged(sgField)
if not self.isBuildingFields():
ShotgunORM.onFieldChanged(sgField)
示例10: formatMessage
def formatMessage(self, sgEvent):
'''
Returns a formatted string for the event.
Subclasses can override this function to return custom msgs.
Args:
* (SgEvent) sgEvent:
Event to build message for.
'''
return (
ShotgunORM.formatSerializable(
sgEvent.event().fieldValues()
) + '\n'
)
示例11: createEntity
def createEntity(self, sgEntityType, sgData):
'''
Creates a new Entity object of type sgEntityType.
'''
entityClass = self._classCache.get(sgEntityType, None)
if entityClass == None:
raise RuntimeError('unknown Entity type "%s"' % sgEntityType)
sgData = ShotgunORM.beforeEntityCreate(self.connection(), sgEntityType, sgData)
result = entityClass()
result.buildFields()
result._fromFieldData(sgData)
return result
示例12: searchAsync
def searchAsync(
self,
sgEntityType,
sgSearchExp,
sgFields=None,
sgSearchArgs=[],
order=None,
filter_operator=None,
limit=100,
retired_only=False,
page=1,
include_archived_projects=True,
additional_filter_presets=None
):
'''
Performs an async search().
See search() for a more detailed description.
'''
schema = self.schema()
sgEntityType = schema.entityApiName(sgEntityType)
sgFilters = ShotgunORM.parseToLogicalOp(
schema.entityInfo(sgEntityType),
sgSearchExp,
sgSearchArgs
)
sgFilters = self._flattenFilters(sgFilters)
return self.__asyncEngine.appendSearchToQueue(
sgEntityType,
sgFilters,
sgFields,
order,
filter_operator,
limit,
retired_only,
page,
include_archived_projects,
additional_filter_presets
)
示例13: _sg_find
def _sg_find(
self,
entity_type,
filters,
fields=None,
order=None,
filter_operator=None,
limit=0,
retired_only=False,
page=0,
include_archived_projects=True,
additional_filter_presets=None
):
'''
Calls the Shotgun Python API find function.
This will lock the global Shotgun Python API lock.
'''
if fields != None:
fields = list(fields)
with ShotgunORM.SHOTGUN_API_LOCK:
result = self.connection().find(
entity_type,
filters,
fields,
order,
filter_operator,
limit,
retired_only,
page,
include_archived_projects,
additional_filter_presets
)
return ShotgunORM.onSearchResult(
self,
entity_type,
fields,
result
)
示例14: searchOneAsync
def searchOneAsync(
self,
sgEntityType,
sgSearchExp,
sgFields=None,
sgSearchArgs=[],
order=None,
filter_operator=None,
retired_only=False
):
'''
Performs an async searchOne().
See searchOne() for a more detailed description.
'''
schema = self.schema()
sgEntityType = schema.entityApiName(sgEntityType)
sgFilters = ShotgunORM.parseToLogicalOp(
schema.entityInfo(sgEntityType),
sgSearchExp,
sgSearchArgs
)
sgFilters = self._flattenFilters(sgFilters)
return self.__asyncEngine.appendSearchToQueue(
sgEntityType,
sgFilters,
sgFields,
order,
filter_operator,
0,
retired_only,
0,
isSingle=True
)
示例15: setValue
def setValue(self, sgData):
'''
Set the value of the field.
Returns True on success.
Args:
* (object) sgData:
New field value.
'''
with self:
ShotgunORM.LoggerField.debug('%(sgField)s.setValue(...)', {'sgField': self})
ShotgunORM.LoggerField.debug(' * sgData: %(sgData)s', {'sgData': sgData})
if not self.isEditable():
raise RuntimeError('%s is not editable!' % ShotgunORM.mkEntityFieldString(self))
if not ShotgunORM.config.DISABLE_FIELD_VALIDATE_ON_SET_VALUE:
self.validate(forReal=True)
if sgData == None:
sgData = self.defaultValue()
updateResult = self._setValue(sgData)
if not updateResult:
if not self.isValid():
self.setValid(True)
return False
self.setValid(True)
self.setHasCommit(True)
self.changed()
return True