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
def setLogicalOp(self, logicalOp): ''' Sets the logical operator ''' if isinstance(logicalOp, SgSearchFilterLogicalOp): self._op = logicalOp._op.copy() else: self._op = ShotgunORM.SgLogicalOp(logicalOp)