

def dumps(self):
    try:
        return self.dumps_simple()
    except Exception:
        pass
    functions = []
    for (f, kwargs) in self.functions:
        for key in kwargs:
            try:
                kwargs[key] = kwargs[key].to_dict()
            except (AttributeError, TypeError):
                pass
        functions.append({
            'function': self.to_path(f),
            'kwargs': kwargs,
        })

    def handler(obj):
        try:
            json_handler(obj)
        except Exception:
            if isinstance(obj, SerializableFunction):
                return {
                    'type': 'SerializedFunction',
                    'dump': obj.dumps(),
                }
            elif isfunction(obj):
                return {
                    'type': 'SerializedFunction',
                    'dump': SerializableFunction(obj).dumps(),
                }
    return json.dumps(functions, default=handler)

dataset/ETHPy150Open dimagi/commcare-hq/corehq/ex-submodules/couchexport/util.py SerializableFunction.dumps/original