当前位置: 首页>>代码示例>>Python>>正文


Python constants.wrapBool函数代码示例

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


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


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