• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python constants.wrapBool函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中typhon.objects.constants.wrapBool函数的典型用法代码示例。如果您正苦于以下问题:Python wrapBool函数的具体用法?Python wrapBool怎么用?Python wrapBool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wrapBool函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: recv

    def recv(self, atom, args):
        if atom is ISSETTLED_1:
            return wrapBool(isSettled(args[0]))

        if atom is OPTSAME_2:
            first, second = args
            result = optSame(first, second)
            if result is NOTYET:
                return NullObject
            return wrapBool(result is EQUAL)

        if atom is SAMEEVER_2:
            first, second = args
            result = optSame(first, second)
            if result is NOTYET:
                raise userError(u"Not yet settled!")
            return wrapBool(result is EQUAL)

        if atom is SAMEYET_2:
            first, second = args
            result = optSame(first, second)
            return wrapBool(result is EQUAL)

        if atom is MAKETRAVERSALKEY_1:
            return TraversalKey(args[0])

        raise Refused(self, atom, args)
开发者ID:markrwilliams,项目名称:typhon,代码行数:27,代码来源:equality.py


示例2: recv

    def recv(self, atom, args):
        from typhon.nodes import Noun, Method, Obj
        from typhon.objects.equality import optSame, EQUAL
        from typhon.objects.user import Audition

        if atom is _UNCALL_0:
            from typhon.objects.collections.maps import EMPTY_MAP

            return ConstList([subrangeGuardMaker, StrObject(u"get"), ConstList([self.superGuard]), EMPTY_MAP])

        if atom is AUDIT_1:
            audition = args[0]
            if not isinstance(audition, Audition):
                raise userError(u"not invoked with an Audition")
            ast = audition.ast
            if not isinstance(ast, Obj):
                raise userError(u"audition not created with an object expr")
            methods = ast._script._methods
            for m in methods:
                if isinstance(m, Method) and m._verb == u"coerce":
                    mguard = m._g
                    if isinstance(mguard, Noun):
                        rGSG = audition.getGuard(mguard.name)
                        if isinstance(rGSG, FinalSlotGuard):
                            rGSG0 = rGSG.valueGuard
                            if isinstance(rGSG0, SameGuard):
                                resultGuard = rGSG0.value

                                if optSame(resultGuard, self.superGuard) is EQUAL or (
                                    SUPERSETOF_1 in self.superGuard.respondingAtoms()
                                    and self.superGuard.call(u"supersetOf", [resultGuard]) is wrapBool(True)
                                ):
                                    return wrapBool(True)
                                raise userError(
                                    u"%s does not have a result guard implying "
                                    u"%s, but %s" % (audition.fqn, self.superGuard.toQuote(), resultGuard.toQuote())
                                )
                            raise userError(
                                u"%s does not have a determinable "
                                u"result guard, but <& %s> :%s" % (audition.fqn, mguard.name, rGSG.toQuote())
                            )
                    break
            return self
        if atom is PASSES_1:
            return wrapBool(args[0].auditedBy(self))
        if atom is COERCE_2:
            specimen, ej = args[0], args[1]
            if specimen.auditedBy(self):
                return specimen
            c = specimen.call(u"_conformTo", [self])
            if c.auditedBy(self):
                return c
            throw(ej, StrObject(u"%s does not conform to %s" % (specimen.toQuote(), self.toQuote())))

        raise Refused(self, atom, args)
开发者ID:markrwilliams,项目名称:typhon,代码行数:55,代码来源:guards.py


示例3: recv

    def recv(self, atom, args):
        if atom is RESOLVE_1:
            return wrapBool(self.resolve(args[0]))

        if atom is RESOLVE_2:
            return wrapBool(self.resolve(args[0], unwrapBool(args[1])))

        if atom is SMASH_1:
            return wrapBool(self.smash(args[0]))

        raise Refused(self, atom, args)
开发者ID:washort,项目名称:typhon,代码行数:11,代码来源:refs.py


示例4: auditedBy

def auditedBy(auditor, specimen):
    """
    Whether an auditor has audited a specimen.
    """
    from typhon.objects.refs import resolution
    from typhon.objects.constants import wrapBool
    return wrapBool(resolution(specimen).auditedBy(auditor))
开发者ID:markrwilliams,项目名称:typhon,代码行数:7,代码来源:auditors.py


示例5: _uncall

 def _uncall(self):
     from typhon.objects.collections.lists import wrapList
     from typhon.objects.collections.maps import EMPTY_MAP
     return [
         makeSourceSpan, StrObject(u"run"),
         wrapList([wrapBool(self._isOneToOne), IntObject(self.startLine),
                    IntObject(self.startCol), IntObject(self.endLine),
                    IntObject(self.endCol)]), EMPTY_MAP]
开发者ID:dckc,项目名称:typhon,代码行数:8,代码来源:data.py


示例6: recv

    def recv(self, atom, args):
        from typhon.objects.constants import wrapBool
        from typhon.objects.constants import NullObject
        if atom is AUDIT_1:
            return wrapBool(True)

        if atom is PASSES_1:
            return wrapBool(args[0].auditedBy(selfless))

        if atom is COERCE_2:
            if args[0].auditedBy(selfless):
                return args[0]
            from typhon.objects.ejectors import throw
            throw(args[1], NullObject)
            return NullObject

        raise Refused(self, atom, args)
开发者ID:markrwilliams,项目名称:typhon,代码行数:17,代码来源:auditors.py


示例7: optSame

    def optSame(self, first, second):
        """
        Whether `first` and `second` are the same.

        Returns `null` if `first` or `second` are too unsettled to compare.
        """

        result = optSame(first, second)
        if result is NOTYET:
            return NullObject
        return wrapBool(result is EQUAL)
开发者ID:monte-language,项目名称:typhon,代码行数:11,代码来源:equality.py


示例8: safeScope

def safeScope():
    return finalize({
        u"null": NullObject,
        u"Infinity": Infinity,
        u"NaN": NaN,
        u"false": wrapBool(False),
        u"true": wrapBool(True),

        u"Any": anyGuard,
        u"Binding": BindingGuard(),
        u"DeepFrozen": deepFrozenGuard,
        u"FinalSlot": theFinalSlotGuardMaker,
        u"Near": NearGuard(),
        u"Same": sameGuardMaker,
        u"Selfless": selfless,
        u"SubrangeGuard": subrangeGuardMaker,
        u"VarSlot": theVarSlotGuardMaker,

        u"M": MObject(),
        u"Ref": RefOps(),
        u"_auditedBy": auditedBy(),
        u"_equalizer": Equalizer(),
        u"_loop": loop(),
        u"_makeBytes": theMakeBytes,
        u"_makeDouble": theMakeDouble,
        u"_makeFinalSlot": theFinalSlotMaker,
        u"_makeInt": theMakeInt,
        u"_makeList": theMakeList,
        u"_makeMap": theMakeMap,
        u"_makeSourceSpan": makeSourceSpan,
        u"_makeStr": theMakeStr,
        u"_makeString": theMakeStr,
        u"_makeVarSlot": theVarSlotMaker,
        u"_slotToBinding": theSlotBinder,
        u"throw": theThrower,

        u"trace": TraceLn(),
        u"traceln": TraceLn(),
    })
开发者ID:dckc,项目名称:typhon,代码行数:39,代码来源:safe.py


示例9: recv

    def recv(self, atom, args):
        from typhon.objects.constants import wrapBool
        from typhon.objects.collections.helpers import monteMap
        from typhon.objects.user import Audition
        if atom is AUDIT_1:
            audition = args[0]
            if not isinstance(audition, Audition):
                raise userError(u"not an Audition")
            return wrapBool(self.audit(audition))

        if atom is COERCE_2:
            from typhon.objects.constants import NullObject
            from typhon.objects.ejectors import theThrower
            ej = args[1]
            if ej is NullObject:
                ej = theThrower
            checkDeepFrozen(args[0], monteMap(), ej, args[0])
            return args[0]

        if atom is SUPERSETOF_1:
            return wrapBool(deepFrozenSupersetOf(args[0]))
        raise Refused(self, atom, args)
开发者ID:washort,项目名称:typhon,代码行数:22,代码来源:auditors.py


示例10: mirandaMethods

    def mirandaMethods(self, atom, arguments, namedArgsMap):
        from typhon.objects.collections.maps import EMPTY_MAP
        if atom is _CONFORMTO_1:
            # Welcome to _conformTo/1.
            # to _conformTo(_): return self
            return self

        if atom is _GETALLEGEDINTERFACE_0:
            # Welcome to _getAllegedInterface/0.
            interface = self.optInterface()
            if interface is None:
                from typhon.objects.interfaces import ComputedInterface
                interface = ComputedInterface(self)
            return interface

        if atom is _PRINTON_1:
            # Welcome to _printOn/1.
            from typhon.objects.constants import NullObject
            self.printOn(arguments[0])
            return NullObject

        if atom is _RESPONDSTO_2:
            from typhon.objects.constants import wrapBool
            from typhon.objects.data import unwrapInt, unwrapStr
            verb = unwrapStr(arguments[0])
            arity = unwrapInt(arguments[1])
            atom = getAtom(verb, arity)
            result = (atom in self.respondingAtoms() or
                      atom in mirandaAtoms)
            return wrapBool(result)

        if atom is _SEALEDDISPATCH_1:
            # to _sealedDispatch(_): return null
            from typhon.objects.constants import NullObject
            return NullObject

        if atom is _UNCALL_0:
            from typhon.objects.constants import NullObject
            return NullObject

        if atom is _WHENMORERESOLVED_1:
            # Welcome to _whenMoreResolved.
            # This method's implementation, in Monte, should be:
            # to _whenMoreResolved(callback): callback<-(self)
            from typhon.vats import currentVat
            vat = currentVat.get()
            vat.sendOnly(arguments[0], RUN_1, [self], EMPTY_MAP)
            from typhon.objects.constants import NullObject
            return NullObject
        return None
开发者ID:monte-language,项目名称:typhon,代码行数:50,代码来源:root.py


示例11: recv

    def recv(self, atom, args):
        if atom is ASK_1:
            return wrapBool(self.ask(args[0]))

        if atom is GETGUARD_1:
            return self.getGuard(unwrapStr(args[0]))

        if atom is GETOBJECTEXPR_0:
            return self.ast

        if atom is GETFQN_0:
            return StrObject(self.fqn)

        raise Refused(self, atom, args)
开发者ID:markrwilliams,项目名称:typhon,代码行数:14,代码来源:user.py


示例12: recv

    def recv(self, atom, args):
        # _makeIterator/0: Create an iterator for this collection's contents.
        if atom is _MAKEITERATOR_0:
            return self._makeIterator()

        if atom is _PRINTON_1:
            printer = args[0]
            self.printOn(printer)
            return NullObject

        # contains/1: Determine whether an element is in this collection.
        if atom is CONTAINS_1:
            return wrapBool(self.contains(args[0]))

        # size/0: Get the number of elements in the collection.
        if atom is SIZE_0:
            return IntObject(self.size())

        # slice/1 and slice/2: Select a subrange of this collection.
        if atom is SLICE_1:
            start = unwrapInt(args[0])
            try:
                return self.slice(start)
            except IndexError:
                raise userError(u"slice/1: Index out of bounds")

        # slice/1 and slice/2: Select a subrange of this collection.
        if atom is SLICE_2:
            start = unwrapInt(args[0])
            stop = unwrapInt(args[1])
            try:
                return self.slice(start, stop)
            except IndexError:
                raise userError(u"slice/1: Index out of bounds")

        # snapshot/0: Create a new constant collection with a copy of the
        # current collection's contents.
        if atom is SNAPSHOT_0:
            return self.snapshot()

        if atom is JOIN_1:
            l = unwrapList(args[0])
            return self.join(l)

        return self._recv(atom, args)
开发者ID:markrwilliams,项目名称:typhon,代码行数:45,代码来源:lists.py


示例13: audit

    def audit(self, audition):
        from typhon.nodes import Noun, Method, Obj
        from typhon.objects.equality import optSame, EQUAL
        from typhon.objects.user import Audition
        if not isinstance(audition, Audition):
            raise userError(u"not invoked with an Audition")
        ast = audition.ast
        if not isinstance(ast, Obj):
            raise userError(u"audition not created with an object expr")
        methods = ast._script._methods
        for m in methods:
            if isinstance(m, Method) and m._verb == u"coerce":
                mguard = m._g
                if isinstance(mguard, Noun):
                    rGSG = audition.getGuard(mguard.name)
                    if isinstance(rGSG, FinalSlotGuard):
                        rGSG0 = rGSG.valueGuard
                        if isinstance(rGSG0, SameGuard):
                            resultGuard = rGSG0.value

                            if (optSame(resultGuard, self.superGuard)
                                is EQUAL or
                                (self.superGuard.call(u"supersetOf",
                                    [resultGuard])
                                 is wrapBool(True))):
                                return True
                            raise userError(
                                u"%s does not have a result guard implying "
                                u"%s, but %s" % (audition.fqn,
                                                 self.superGuard.toQuote(),
                                                 resultGuard.toQuote()))
                        raise userError(u"%s does not have a determinable "
                                        u"result guard, but <& %s> :%s" % (
                                            audition.fqn, mguard.name,
                                            rGSG.toQuote()))
                break
        return False
开发者ID:monte-language,项目名称:typhon,代码行数:37,代码来源:guards.py


示例14: recv

 def recv(self, atom, args):
     if atom is COMBINE_1:
         return self.combine(args[0])
     if atom is GETSTARTCOL_0:
         return self.getStartCol()
     if atom is GETSTARTLINE_0:
         return self.getStartLine()
     if atom is GETENDCOL_0:
         return self.getEndCol()
     if atom is GETENDLINE_0:
         return self.getEndLine()
     if atom is ISONETOONE_0:
         return self.isOneToOne()
     if atom is NOTONETOONE_0:
         return self.notOneToOne()
     if atom is _UNCALL_0:
         from typhon.objects.collections.lists import ConstList
         from typhon.objects.collections.maps import EMPTY_MAP
         return ConstList([
             makeSourceSpan, StrObject(u"run"),
             ConstList([wrapBool(self._isOneToOne), IntObject(self.startLine),
                        IntObject(self.startCol), IntObject(self.endLine),
                        IntObject(self.endCol)]), EMPTY_MAP])
     raise Refused(self, atom, args)
开发者ID:washort,项目名称:typhon,代码行数:24,代码来源:data.py


示例15: isOneToOne

 def isOneToOne(self):
     return wrapBool(self._isOneToOne)
开发者ID:washort,项目名称:typhon,代码行数:2,代码来源:data.py


示例16: recv

    def recv(self, atom, args):
        from typhon.objects.collections.lists import ConstList

        # _makeIterator/0: Create an iterator for this collection's contents.
        if atom is _MAKEITERATOR_0:
            return self._makeIterator()

        if atom is _PRINTON_1:
            printer = args[0]
            self.printOn(printer)
            return NullObject

        if atom is _UNCALL_0:
            from typhon.objects.collections.maps import EMPTY_MAP
            # [1,2,3].asSet() -> [[1,2,3], "asSet"]
            rv = ConstList(self.objectSet.keys())
            return ConstList([rv, StrObject(u"asSet"), ConstList([]),
                              EMPTY_MAP])

        # contains/1: Determine whether an element is in this collection.
        if atom is CONTAINS_1:
            return wrapBool(self.contains(args[0]))

        # size/0: Get the number of elements in the collection.
        if atom is SIZE_0:
            return IntObject(self.size())

        # slice/1 and slice/2: Select a subrange of this collection.
        if atom is SLICE_1:
            start = unwrapInt(args[0])
            try:
                return self.slice(start)
            except IndexError:
                raise userError(u"slice/1: Index out of bounds")

        # slice/1 and slice/2: Select a subrange of this collection.
        if atom is SLICE_2:
            start = unwrapInt(args[0])
            stop = unwrapInt(args[1])
            try:
                return self.slice(start, stop)
            except IndexError:
                raise userError(u"slice/1: Index out of bounds")

        # snapshot/0: Create a new constant collection with a copy of the
        # current collection's contents.
        if atom is SNAPSHOT_0:
            return self.snapshot()

        if atom is ASSET_0:
            return self

        if atom is DIVERGE_0:
            _flexSet = getGlobal(u"_flexSet").getValue()
            return _flexSet.call(u"run", [self])

        if atom is AND_1:
            return self._and(args[0])

        # or/1: Unify the elements of this collection with another.
        if atom is OR_1:
            return self._or(args[0])

        # XXX Decide if we follow python-style '-' or E-style '&!' here.
        if atom is SUBTRACT_1:
            return self.subtract(args[0])

        if atom is ASLIST_0:
            return ConstList(self.objectSet.keys())

        if atom is BUTNOT_1:
            return self.subtract(args[0])

        if atom is WITH_1:
            key = args[0]
            d = self.objectSet.copy()
            d[key] = None
            return ConstSet(d)

        if atom is WITHOUT_1:
            key = args[0]
            d = self.objectSet.copy()
            # Ignore the case where the key wasn't in the map.
            if key in d:
                del d[key]
            return ConstSet(d)

        if atom is INCLUDE_1:
            key = args[0]
            self.include(key)
            return NullObject

        if atom is REMOVE_1:
            key = args[0]
            self.remove(key)
            return NullObject

        if atom is POP_0:
            return self.pop()

#.........这里部分代码省略.........
开发者ID:markrwilliams,项目名称:typhon,代码行数:101,代码来源:sets.py


示例17: deepFrozenSupersetOf

def deepFrozenSupersetOf(guard):
    from typhon.objects.collections.helpers import monteMap
    from typhon.objects.collections.lists import ConstList
    from typhon.objects.constants import wrapBool
    from typhon.objects.ejectors import Ejector
    from typhon.objects.refs import Promise
    from typhon.objects.guards import (
        AnyOfGuard, BoolGuard, BytesGuard, CharGuard, DoubleGuard,
        FinalSlotGuard, IntGuard, SameGuard, StrGuard, SubrangeGuard,
        VoidGuard)
    from typhon.prelude import getGlobalValue
    if guard is deepFrozenGuard:
        return True
    if guard is deepFrozenStamp:
        return True
    if isinstance(guard, Promise):
        guard = guard.resolution()
    if isinstance(guard, BoolGuard):
        return True
    if isinstance(guard, BytesGuard):
        return True
    if isinstance(guard, CharGuard):
        return True
    if isinstance(guard, DoubleGuard):
        return True
    if isinstance(guard, IntGuard):
        return True
    if isinstance(guard, StrGuard):
        return True
    if isinstance(guard, VoidGuard):
        return True

    if isinstance(guard, SameGuard):
        ej = Ejector()
        try:
            v = guard.value
            checkDeepFrozen(v, monteMap(), ej, v)
            return True
        except Ejecting:
            return False

    if isinstance(guard, FinalSlotGuard):
        return deepFrozenSupersetOf(guard.valueGuard)
    for superGuardName in [u"List", u"NullOk", u"Set"]:
        superGuard = getGlobalValue(superGuardName)
        if superGuard is None:
            continue
        ej = Ejector()
        try:
            subGuard = superGuard.call(u"extractGuard", [guard, ej])
            return deepFrozenSupersetOf(subGuard)
        except Ejecting:
            # XXX lets other ejectors get through
            pass
    for pairGuardName in [u"Map", u"Pair"]:
        pairGuard = getGlobalValue(pairGuardName)
        if pairGuard is None:
            continue
        ej = Ejector()
        try:
            guardPair = pairGuard.call(u"extractGuards", [guard, ej])
            if isinstance(guardPair, ConstList) and guardPair.size() == 2:
                return (
                    (deepFrozenSupersetOf(guardPair.strategy.fetch(
                        guardPair, 0))) and
                    (deepFrozenSupersetOf(guardPair.strategy.fetch(
                        guardPair, 1))))
        except Ejecting:
            # XXX lets other ejectors get through
            pass
    if (SubrangeGuard(deepFrozenGuard).call(u"passes", [guard])
            is wrapBool(True)):
        return True
    if isinstance(guard, AnyOfGuard):
        for g in guard.subguards:
            if not deepFrozenSupersetOf(g):
                return False
        return True
    return False
开发者ID:markrwilliams,项目名称:typhon,代码行数:79,代码来源:auditors.py


示例18: testUnwrapBoolPromise

 def testUnwrapBoolPromise(self):
     with scopedVat(testingVat()):
         p = makeNear(wrapBool(False))
         self.assertFalse(unwrapBool(p))
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_refs.py


示例19: testResolveNear

 def testResolveNear(self):
     with scopedVat(testingVat()):
         p = makeNear(wrapBool(False))
         self.assertFalse(resolution(p).isTrue())
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_refs.py


示例20: optSame

 def optSame(self, first, second):
     result = optSame(first, second)
     if result is NOTYET:
         return NullObject
     return wrapBool(result is EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:5,代码来源:equality.py



注:本文中的typhon.objects.constants.wrapBool函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python data.IntObject类代码示例发布时间:2022-05-27
下一篇:
Python lists.wrapList函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap