예제 #1
0
    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()
예제 #2
0
    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()
예제 #3
0
 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)
예제 #4
0
 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)