@classmethod
def from_extended_slug(cls, slug):
    """Return an Target from an build or job slug."""
    parts = slug.split('/')
    assert len(parts) in [2, 3]
    user = parts[0]
    logical_id = None
    build_id = job_id = None
    if len(parts) == 3:
        project, logical_id = parts[1:]
    elif '#' in parts[1]:
        project, logical_id = parts[1].split('#', 1)
    elif '@' in parts[1]:
        project, build_id = parts[1].split('@', 1)
        build_id = int(build_id)
    elif ':' in parts[1]:
        project, job_id = parts[1].split(':', 1)
        job_id = int(job_id)
    else:
        project = parts[1]
    if logical_id:
        build_number, sep, job_number = logical_id.partition('.')
        assert build_number
        build_number = int(build_number)
        if job_number:
            job_number = int(job_number)
        else:
            job_number = None
        return cls(user, project, build_number=build_number, job_number=
            job_number)
    return cls(user, project, build_id, job_id)
