Parses given location data.

    :param data: Exception.
    :type data: Exception
    :return: Location object.
    :rtype: Location

def parse_location(data):
    """
    Parses given location data.

    :param data: Exception.
    :type data: Exception
    :return: Location object.
    :rtype: Location
    """

    tokens = data.split(",")
    location = Location(directories=[], files=[], filters_in=[], filters_out=[], targets=[])
    if not tokens:
        return location

    for token in tokens:
        token = token.strip()
        if not token:
            continue

        if foundations.common.path_exists(token):
            if os.path.isdir(token):
                location.directories.append(token)
            else:
                location.files.append(token)
        else:
            match = re.match("(?P<filterIn>\*\.\w+)", token)
            if match:
                location.filters_in.append(fnmatch.translate(match.group("filterIn")))
                continue
            match = re.match("!(?P<filterOut>\*\.\w+)", token)
            if match:
                location.filters_out.append(fnmatch.translate(match.group("filterOut")))
                continue
            match = re.match("\<(?P<target>[\w ]+)\>", token)
            if match:
                location.targets.append(match.group("target"))
                continue
    return location