Python operator 模块,is_() 实例源码

我们从Python开源项目中,提取了以下42个代码示例,用于说明如何使用operator.is_()

项目:Flask_Blog    作者:sugarguo    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:QXSConsolas    作者:qxsch    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:ShelbySearch    作者:Agentscreech    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:Price-Comparator    作者:Thejas-1    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        with test_support.check_py3k_warnings():
            self.assertIs(operator.isCallable(0), False)
            self.assertIs(operator.isCallable(len), True)
        self.assertIs(operator.isNumberType(None), False)
        self.assertIs(operator.isNumberType(0), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.isSequenceType(0), False)
        self.assertIs(operator.isSequenceType([]), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.isMappingType(1), False)
        self.assertIs(operator.isMappingType({}), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        with test_support.check_py3k_warnings():
            self.assertIs(operator.isCallable(0), False)
            self.assertIs(operator.isCallable(len), True)
        self.assertIs(operator.isNumberType(None), False)
        self.assertIs(operator.isNumberType(0), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.isSequenceType(0), False)
        self.assertIs(operator.isSequenceType([]), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.isMappingType(1), False)
        self.assertIs(operator.isMappingType({}), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True)
项目:pudzu    作者:Udzu    | 项目源码 | 文件源码
def number_of_args(fn):
    """Return the number of positional arguments for a function, or None if the number is variable.
    Looks inside any decorated functions."""
    try:
        if hasattr(fn, '__wrapped__'):
            return number_of_args(fn.__wrapped__)
        if any(p.kind == p.VAR_POSITIONAL for p in signature(fn).parameters.values()):
            return None
        else:
            return sum(p.kind in (p.POSITIONAL_ONLY, p.POSITIONAL_OR_KEYWORD) for p in signature(fn).parameters.values())
    except ValueError:
        # signatures don't work for built-in operators, so check for a few explicitly
        UNARY_OPS = [len, op.not_, op.truth, op.abs, op.index, op.inv, op.invert, op.neg, op.pos]
        BINARY_OPS = [op.lt, op.le, op.gt, op.ge, op.eq, op.ne, op.is_, op.is_not, op.add, op.and_, op.floordiv, op.lshift, op.mod, op.mul, op.or_, op.pow, op.rshift, op.sub, op.truediv, op.xor, op.concat, op.contains, op.countOf, op.delitem, op.getitem, op.indexOf]
        TERNARY_OPS = [op.setitem]
        if fn in UNARY_OPS:
            return 1
        elif fn in BINARY_OPS:
            return 2
        elif fn in TERNARY_OPS:
            return 3
        else:
            raise NotImplementedError("Bult-in operator {} not supported".format(fn))
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:Flask-NvRay-Blog    作者:rui7157    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:Callandtext    作者:iaora    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:python_ddd_flask    作者:igorvinnicius    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:webapp    作者:superchilli    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        with test_support.check_py3k_warnings():
            self.assertIs(operator.isCallable(0), False)
            self.assertIs(operator.isCallable(len), True)
        self.assertIs(operator.isNumberType(None), False)
        self.assertIs(operator.isNumberType(0), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.isSequenceType(0), False)
        self.assertIs(operator.isSequenceType([]), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.isMappingType(1), False)
        self.assertIs(operator.isMappingType({}), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        with test_support.check_py3k_warnings():
            self.assertIs(operator.isCallable(0), False)
            self.assertIs(operator.isCallable(len), True)
        self.assertIs(operator.isNumberType(None), False)
        self.assertIs(operator.isNumberType(0), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.isSequenceType(0), False)
        self.assertIs(operator.isSequenceType([]), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.isMappingType(1), False)
        self.assertIs(operator.isMappingType({}), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True)
项目:QualquerMerdaAPI    作者:tiagovizoto    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:gardenbot    作者:GoestaO    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:flask-zhenai-mongo-echarts    作者:Fretice    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:Data-visualization    作者:insta-code1    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:micro-blog    作者:nickChenyx    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:aireamhan    作者:neal-o-r    | 项目源码 | 文件源码
def add_globals(self):
    "Add some Scheme standard procedures."
    import math, cmath, operator as op
    from functools import reduce
    self.update(vars(math))
    self.update(vars(cmath))
    self.update({
     '+':op.add, '-':op.sub, '*':op.mul, '/':op.itruediv, 'níl':op.not_, 'agus':op.and_,
     '>':op.gt, '<':op.lt, '>=':op.ge, '<=':op.le, '=':op.eq, 'mod':op.mod, 
     'frmh':cmath.sqrt, 'dearbhluach':abs, 'uas':max, 'íos':min,
     'cothrom_le?':op.eq, 'ionann?':op.is_, 'fad':len, 'cons':cons,
     'ceann':lambda x:x[0], 'tóin':lambda x:x[1:], 'iarcheangail':op.add,  
     'liosta':lambda *x:list(x), 'liosta?': lambda x:isa(x,list),
     'folamh?':lambda x: x == [], 'adamh?':lambda x: not((isa(x, list)) or (x == None)),
     'boole?':lambda x: isa(x, bool), 'scag':lambda f, x: list(filter(f, x)),
     'cuir_le':lambda proc,l: proc(*l), 'mapáil':lambda p, x: list(map(p, x)), 
     'lódáil':lambda fn: load(fn), 'léigh':lambda f: f.read(),
     'oscail_comhad_ionchuir':open,'dún_comhad_ionchuir':lambda p: p.file.close(), 
     'oscail_comhad_aschur':lambda f:open(f,'w'), 'dún_comhad_aschur':lambda p: p.close(),
     'dac?':lambda x:x is eof_object, 'luacháil':lambda x: evaluate(x),
     'scríobh':lambda x,port=sys.stdout:port.write(to_string(x) + '\n')})
    return self
项目:python-flask-security    作者:weinbergdavid    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:watcher    作者:nosmokingbandit    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:Lixiang_zhaoxin    作者:hejaxian    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:flask    作者:bobohope    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:Chorus    作者:DonaldBough    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:Hawkeye    作者:tozhengxq    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:Alfred    作者:jkachhadia    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:ngx_status    作者:YoYoAdorkable    | 项目源码 | 文件源码
def _validate_query_state(self):
        for attr, methname, notset, op in (
            ('_limit', 'limit()', None, operator.is_),
            ('_offset', 'offset()', None, operator.is_),
            ('_order_by', 'order_by()', False, operator.is_),
            ('_group_by', 'group_by()', False, operator.is_),
            ('_distinct', 'distinct()', False, operator.is_),
            (
                '_from_obj',
                'join(), outerjoin(), select_from(), or from_self()',
                (), operator.eq)
        ):
            if not op(getattr(self.query, attr), notset):
                raise sa_exc.InvalidRequestError(
                    "Can't call Query.update() or Query.delete() "
                    "when %s has been called" %
                    (methname, )
                )
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_is(self):
        a = b = 'xyzpdq'
        c = a[:3] + b[3:]
        self.assertRaises(TypeError, operator.is_)
        self.assertTrue(operator.is_(a, b))
        self.assertFalse(operator.is_(a,c))
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def test_is(self):
        a = b = 'xyzpdq'
        c = a[:3] + b[3:]
        self.assertRaises(TypeError, operator.is_)
        self.assertTrue(operator.is_(a, b))
        self.assertFalse(operator.is_(a,c))
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def test_is(self):
        a = b = 'xyzpdq'
        c = a[:3] + b[3:]
        self.assertRaises(TypeError, operator.is_)
        self.assertTrue(operator.is_(a, b))
        self.assertFalse(operator.is_(a,c))
项目:pudzu    作者:Udzu    | 项目源码 | 文件源码
def exclude_tags(tags, excluded, relation=operator.is_):
    """Filter out tags that are related to at least one of the excluded set."""
    return [t for t in make_bs4_iterable(tags) if not any(relation(t, s) for s in make_bs4_iterable(excluded))]
项目:pudzu    作者:Udzu    | 项目源码 | 文件源码
def restrict_tags(tags, included, relation=operator.is_):
    """Restrict to tags that are related to at least one of the included set."""
    return [t for t in make_bs4_iterable(tags) if any(relation(t, s) for s in make_bs4_iterable(included))]

# finding tags by chaining
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_is(self):
        a = b = 'xyzpdq'
        c = a[:3] + b[3:]
        self.assertRaises(TypeError, operator.is_)
        self.assertTrue(operator.is_(a, b))
        self.assertFalse(operator.is_(a,c))

    #brython fix me  (syntax error)
    #def test_is_not(self):
    #    a = b = 'xyzpdq'
    #    c = a[:3] + b[3:]
    #    self.assertRaises(TypeError, operator.is_not)
    #    self.assertFalse(operator.is_not(a, b))
    #    self.assertTrue(operator.is_not(a,c))
项目:web_ctp    作者:molebot    | 项目源码 | 文件源码
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True)
项目:pefile.pypy    作者:cloudtracer    | 项目源码 | 文件源码
def test_is(self):
        a = b = 'xyzpdq'
        c = a[:3] + b[3:]
        self.assertRaises(TypeError, operator.is_)
        self.assertTrue(operator.is_(a, b))
        self.assertFalse(operator.is_(a,c))
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True)
项目:ndk-python    作者:gittor    | 项目源码 | 文件源码
def test_is(self):
        a = b = 'xyzpdq'
        c = a[:3] + b[3:]
        self.assertRaises(TypeError, operator.is_)
        self.assertTrue(operator.is_(a, b))
        self.assertFalse(operator.is_(a,c))
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_operator(self):
        import operator
        self.assertIs(operator.truth(0), False)
        self.assertIs(operator.truth(1), True)
        self.assertIs(operator.not_(1), False)
        self.assertIs(operator.not_(0), True)
        self.assertIs(operator.contains([], 1), False)
        self.assertIs(operator.contains([1], 1), True)
        self.assertIs(operator.lt(0, 0), False)
        self.assertIs(operator.lt(0, 1), True)
        self.assertIs(operator.is_(True, True), True)
        self.assertIs(operator.is_(True, False), False)
        self.assertIs(operator.is_not(True, True), False)
        self.assertIs(operator.is_not(True, False), True)
项目:ROS-Code    作者:Richienb    | 项目源码 | 文件源码
def compare(value1, value2, comparision):
    import operator
    if comparision == 'is':
        return operator.is_(value1, value2)
    elif comparision == 'or':
        return operator.or_(value1, value2)
    elif comparision == 'and':
        return operator.and_(value1, value2)

# Use Euler's Formula