예제 #1
0
        def scrub(node):
            # I want to dictify vanilla objects only.
            # wtf_is(node.value)
            if wtf_is(node.value)["is_a"] == [types.ObjectType]:
                node.set(dictify(node.value))

            # I want to scrub out functions here.
            if isinstance(node.value, types.FunctionType) or isinstance(node.value, types.MethodType):
                # register the function/method into the lut, get an id (key).
                fname = self.lut.register(node.value)
                # Adds function and path to callbacks list
                callbacks.append((fname, node.path))
                node.set("[function]")
예제 #2
0
    def scrub(self, args):
        callbacks = []
        if wtf_is(args)["is_a"] == [types.ObjectType]:
            scrubbed = dictify(args)
        else:
            scrubbed = args[:]

        @walk(scrubbed)
        def scrub(node):
            # I want to dictify vanilla objects only.
            # wtf_is(node.value)
            if wtf_is(node.value)["is_a"] == [types.ObjectType]:
                node.set(dictify(node.value))

            # I want to scrub out functions here.
            if isinstance(node.value, types.FunctionType) or isinstance(node.value, types.MethodType):
                # register the function/method into the lut, get an id (key).
                fname = self.lut.register(node.value)
                # Adds function and path to callbacks list
                callbacks.append((fname, node.path))
                node.set("[function]")

        # Some trickery with the "arguments" field. May not suffice.
        return {"arguments": [scrubbed] if type(scrubbed) == dict else list(scrubbed), "callbacks": dict(callbacks)}