import re


def location_platform_from_current_location(current_location: str):
    """Parses currentLocation: "At ..." -> (location, platform_number)"""

    # ignore if not *at* a location
    if not current_location.startswith("At "):
        return None, None

    # discard initial 'At '
    current_location = current_location[3:]

    # at current station/platform (i.e. "[At ]Platform")
    if current_location == "Platform":
        return "<current>", "<current>"  # special values

    # with station and platform, supporting the following alternatives
    # - "Manor House Platform 1" (normal)
    # - "East Finchley, Platform 1" (extra comma)
    # - "London Bridge Plaform 1" (typo)
    # - "Kings Cross P7" (abbreviation)
    station_platform = re.match(r"^(.*?),? P(?:lat?form )?(\d+)$", current_location)

    if station_platform is not None:
        return station_platform.group(1), station_platform.group(2)

    # without platform number (e.g. "[At ]Angel platform")
    if current_location.endswith(" platform"):
        return current_location[: -len(" platform")], None

    # no mention of platform
    if "Platform" not in current_location:
        return current_location, None

    return None, None