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

Python Function.Function类代码示例

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

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



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

示例1: execute

    def execute(self, theToken):
        
        # resolve variables from the token
        resolved = {}

        linearToken = theToken.linearize()
        
        for theVar, theLocation in self._variables.items():
            try:
                assert isinstance(theLocation, VariableLocation)
                resolved[theVar] = theLocation.toValue(linearToken[theLocation.patternIndex])
            except:
                import myclips
                myclips.logger.debug("%s: unresolvable variable %s: %s:%s %s", self.completeRuleName(), theVar, theLocation.patternIndex, theLocation, linearToken )
        
        # prepare the FunctionEnv object    
        theEnv = FunctionEnv(resolved, self._network, self._network.modulesManager, self._network.resources)
        
        # execute all rhs passing FunctionEnv
        # theEnv could be modified from the function call.
        # This THE way to share memory between functions
        
        for action in self._rhs:
            assert isinstance(action, types.FunctionCall)
            
            # get the function definition linked to the FunctionCall
            #funcDefinition = action.funcDefinition
            
            #assert isinstance(funcDefinition, FunctionDefinition)
            # expand the args 
            #funcDefinition.linkedType.__class__.execute(funcDefinition.linkedType, theEnv, *(action.funcArgs))
            
            Function.doExecute(action, theEnv)
开发者ID:julianpistorius,项目名称:myclips,代码行数:33,代码来源:PNode.py


示例2: do

    def do(self, funcEnv, resourceId, *args, **kargs):
        """
        Retract function handler implementation
        """
        
        # convert <TYPE:value> to python value
        resourceId = Function.resolve(self, funcEnv, self.semplify(funcEnv, resourceId, types.Symbol, ("1", "symbol")))
        
        if resourceId != "nil":
            try:
                resource = funcEnv.RESOURCES[resourceId]
            except KeyError:
                raise InvalidArgValueError("Resource with logical name %s cannot be found"%str(resourceId))
            else:
            
#                for fragment in args:
#                    
#                    # revolve variables and function calls
#                    fragment = self.resolve(funcEnv, self.semplify(funcEnv, fragment))
#                    
#                    resource.write(str(fragment))
                    
                resource.write("".join([str(self.resolve(funcEnv, self.semplify(funcEnv, x))) for x in args]))
                    
        return types.NullValue()
开发者ID:julianpistorius,项目名称:myclips,代码行数:25,代码来源:Printout.py


示例3: resolve

 def resolve(self, funcEnv, arg):
     """
     Override Function.resolve to manage the <Symbol:crlf> conversion to NEWLINE
     and to remove quotes in types.String values
     """
     if isinstance(arg, types.Symbol) and arg.pyEqual("crlf"):
         return "\n"
     else:
         return Function.resolve(self, funcEnv, arg)
开发者ID:julianpistorius,项目名称:myclips,代码行数:9,代码来源:Printout.py


示例4: __init__

 def __init__(self, *args, **kwargs):
     Function.__init__(self, *args, **kwargs)
开发者ID:julianpistorius,项目名称:myclips,代码行数:2,代码来源:Subtraction.py


示例5: __init__

 def __init__(self, cmpType=None, *args, **kwargs):
     Function.__init__(self, *args, **kwargs)
     self._cmpType = cmpType if cmpType is not None else types.BaseParsedType
开发者ID:julianpistorius,项目名称:myclips,代码行数:3,代码来源:_TypeTesting.py


示例6: isinstance

         # add the new rule to the network
         self._network.addRule(parsed)
         
     elif isinstance(parsed, types.DefFactsConstruct):
         # add the deffacts
         self._network.addDeffacts(parsed)
         
     elif isinstance(parsed, types.FunctionCall):
         # execute the function
         assert isinstance(parsed, types.FunctionCall)
         
         # prepare the FunctionEnv object    
         theEnv = FunctionEnv({}, self._network, self._network.modulesManager, self._network.resources)
         #funcDefinition = parsed.funcDefinition
         #theResult = funcDefinition.linkedType.__class__.execute(funcDefinition.linkedType, theEnv, *(parsed.funcArgs))
         # replace old function bootstrap method with a faster one
         theResult = Function.doExecute(parsed, theEnv)
         
         if not isinstance(theResult, types.NullValue):
             return theResult
     
     elif isinstance(parsed, types.GlobalVariable):
         # resolve the global value
         
         return self._network.modulesManager.currentScope.globalsvars.getDefinition(parsed.evaluate()).linkedType.runningValue
         
     elif isinstance(parsed, types.BaseParsedType):
         
         return parsed
 
 
开发者ID:julianpistorius,项目名称:myclips,代码行数:29,代码来源:Interpreter.py


示例7: isinstance

            parsed = theEnv.network.getParser().parse(aString, extended=True)
        except Exception, e:
            print >> theEnv.RESOURCES['werror'], theEnv.network.getParser().ExceptionPPrint(e, aString)
            os.chdir(oldcwd)
            return types.Symbol('FALSE')
        else:
            cString = ""
            for p in parsed:
                if isinstance(p, types.DefRuleConstruct):
                    theEnv.network.addRule(p)
                    
                elif isinstance(p, types.DefFactsConstruct):
                    theEnv.network.addDeffacts(p)
                    
                elif isinstance(p, types.FunctionCall):
                    theResult = Function.doExecute(p, theEnv)
                    
                    if not isinstance(theResult, types.NullValue):
                        print >> theEnv.RESOURCES['wtrace'], str(theResult)
                                            
            os.chdir(oldcwd)
            return types.Symbol('TRUE')
    
    
Batch.DEFINITION = FunctionDefinition("?SYSTEM?", "batch", Batch(), types.Symbol, Batch.do ,
            [
                Constraint_ExactArgsLength(1),
                Constraint_ArgType((types.Symbol, types.String), 0)
            ],forward=False)
        
        
开发者ID:julianpistorius,项目名称:myclips,代码行数:29,代码来源:Batch.py


示例8: __init__

 def __init__(self, theParams, theActions, *args, **kwargs):
     Function.__init__(self, *args, **kwargs)
     self._actions = theActions if isinstance(theActions, list) else []
     self._params = theParams if isinstance(theParams, list) else []
开发者ID:julianpistorius,项目名称:myclips,代码行数:4,代码来源:UserFunction.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils_general.flash_success_errors函数代码示例发布时间:2022-05-27
下一篇:
Python completion_engine.suggest_type函数代码示例发布时间: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