def _getgroups(uid):
    """
    Return the primary and supplementary groups for the given UID.

    @type uid: C{int}
    """
    result = []
    pwent = pwd.getpwuid(uid)

    result.append(pwent.pw_gid)

    for grent in grp.getgrall():
        if pwent.pw_name in grent.gr_mem:
            result.append(grent.gr_gid)

    return result

    Return the primary and supplementary groups for the given UID.

    @type uid: C{int}
    
stackoverflow/venv/lib/python3.6/site-packages/twisted/protocols/ftp.py