<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_flask_metadata(app, version, repository, description, api_version="1.0", name=None, auth=None, route=None):
 """ Sets metadata on the application to be returned via metadata routes. Parameters app : :class:`flask.Flask` instance Flask application for the microservice you're adding metadata to. version: `str` Version of your microservice. repository: `str` URL of the repository containing your microservice's source code. description: `str` Description of the microservice. api_version: `str`, optional Version of the SQuaRE service API framework. Defaults to '1.0'. name : `str`, optional Microservice name. Defaults to the Flask app name. If set, changes the Flask app name to match. auth : `dict`, `str`, or `None` The 'auth' parameter must be None, the empty string, the string 'none', or a dict containing a 'type' key, which must be 'none', 'basic', or 'bitly-proxy'. If the type is not 'none', there must also be a 'data' key containing a dict which holds authentication information appropriate to the authentication type. The legal non-dict 'auth' values are equivalent to a 'type' key of 'none'. route : `None`, `str`, or list of `str`, optional The 'route' parameter must be None, a string, or a list of strings. If supplied, each string will be prepended to the metadata route. Raises ------ TypeError If arguments are not of the appropriate type. ValueError If arguments are the right type but have illegal values. Returns ------- Nothing, but sets `app` metadata and decorates it with `/metadata` and `/v{app_version}/metadata` routes. """


    errstr = set_flask_metadata.__doc__
    if not isinstance(app, Flask):
        raise TypeError(errstr)
    if name is None:
        name = app.name
    app.config["NAME"] = name
    if app.name != name:
        app.name = name
    app.config["VERSION"] = version
    app.config["REPOSITORY"] = repository
    app.config["DESCRIPTION"] = description
    app.config["API_VERSION"] = api_version
    if not (isinstance(name, str) and isinstance(description, str) and
            isinstance(repository, str) and isinstance(version, str) and
            isinstance(api_version, str)):
        raise TypeError(errstr)
    if not (name and description and repository and version and api_version):
        raise ValueError(errstr)
    if auth is None or (isinstance(auth, str) and ((auth == "none") or
                                                   (auth == ""))):
        auth = {"type": "none",
                "data": None}
    if not isinstance(auth, dict):
        raise TypeError(errstr)
    if "type" not in auth:
        raise ValueError(errstr)
    atp = auth["type"]
    if atp == "none":
        app.config["AUTH"] = {"type": "none",
                              "data": None}
    else:
        if atp not in ["basic", "bitly-proxy"] or "data" not in auth:
            raise ValueError(errstr)
    app.config["AUTH"] = auth
    add_metadata_route(app, route)