def source_path(path):
    """Given a path to a compiled Python file, return the corresponding source path.

    If passed a path that isn't a compiled thing, return it intact.

    """
    if path is None:
        return path
    for extension in ['$py.class', '.pyc', '.pyo']:
        if path.endswith(extension):
            return ''.join([path[:-len(extension)], '.py'])
    return path