import re


def deconstruct_rsync_url(rsync_url):
    """Turns an rsync url into experiment, machine, and rsync_module parts.

    Returns None if the rsync_url does not conform to the required spec.
    """
    parts = re.compile(
        r'rsync://(.*)\.(mlab\d.[a-z]{3}\d[\dt]\.measurement-lab.org):\d*/(.*)')
    match = parts.match(rsync_url)
    if match is None:
        return None
    else:
        return match.group(1), match.group(2), match.group(3)