def METHOD_NAME(self, format: str, f: flow.Flow) -> str:
    """
    Export a flow and return the result.
    """
    if format not in formats:
        raise exceptions.CommandError("No such export format: %s" % format)
    func = formats[format]
    return strutils.always_str(func(f), "utf8", "backslashreplace")