<commit_before>"""
dealing with the UW Affiliation Groups
"""

import logging
try:
    from sets import Set as set, ImmutableSet as frozenset
except ImportError:
    pass
from uw_gws import GWS
from myuw.util.settings import get_myuw_test_access_group
from myuw.dao import get_netid_of_current_user, get_netid_of_original_user
from myuw.dao.pws import is_employee


logger = logging.getLogger(__name__)
gws = GWS()

alumni_asso = 'uw_affiliation_alumni-association-members'
fhcrc_emp = 'uw_affiliation_fhcrc-employee'
medicine_aff = 'uw_affiliation_uw-medicine-affiliate'
medicine_wf = 'uw_affiliation_uw-medicine-workforce'
med_res = 'uw_affiliation_wwami-medical-resident'
medicine_staff = 'uw_affiliation_uwnc-staff'
scca_emp = 'uw_affiliation_scca-employee'
uwp_pro = 'uw_affiliation_uwp-provider'
uwp_staff = 'uw_affiliation_uwp-staff'
uwnc_staff = 'uw_affiliation_uwnc-staff'
applicant = 'uw_affiliation_applicant'
staff = 'uw_affiliation_staff-employee'
stud_emp = 'uw_affiliation_student-employee'
bot_stud = 'uw_affiliation_bothell-student'
sea_stud = 'uw_affiliation_seattle-student'
tac_stud = 'uw_affiliation_tacoma-student'
grad = 'uw_affiliation_graduate-grad'
undergrad = 'uw_affiliation_undergraduate'  # grace 90 days
grad_prof = 'uw_affiliation_graduate'  # grace 90 days
pce = 'uw_affiliation_extension-student'
grad_c2 = 'uw_affiliation_continuum-student_graduate'
undergrad_c2 = 'uw_affiliation_continuum-student_undergraduate'
all_groups = [alumni_asso, staff, medicine_wf, medicine_aff, medicine_staff,
              uwp_pro, uwp_staff, med_res, fhcrc_emp, scca_emp, uwnc_staff,
              applicant, stud_emp, bot_stud, sea_stud, tac_stud, undergrad,
              grad_prof, grad, pce, grad_c2, undergrad_c2]
RELEVANT_GROUPS = frozenset(all_groups)


def _search_groups(uwnetid):
    """
    Returns a Set of the uw groups the uwnetid is an effective member of
    """
    group_names = set([])
    group_refs = gws.search_groups(member=uwnetid,
                                   stem="uw_affiliation",
                                   name="",
                                   scope="all",
                                   type="direct")
    if group_refs:
        for gr in group_refs:
            name = str(gr.name)
            if name in RELEVANT_GROUPS:
                group_names.add(name)
    return group_names
<commit_msg>adjust param order to match mock file<commit_after>"""
dealing with the UW Affiliation Groups
"""

import logging
try:
    from sets import Set as set, ImmutableSet as frozenset
except ImportError:
    pass
from uw_gws import GWS
from myuw.util.settings import get_myuw_test_access_group
from myuw.dao import get_netid_of_current_user, get_netid_of_original_user
from myuw.dao.pws import is_employee


logger = logging.getLogger(__name__)
gws = GWS()

alumni_asso = 'uw_affiliation_alumni-association-members'
fhcrc_emp = 'uw_affiliation_fhcrc-employee'
medicine_aff = 'uw_affiliation_uw-medicine-affiliate'
medicine_wf = 'uw_affiliation_uw-medicine-workforce'
med_res = 'uw_affiliation_wwami-medical-resident'
medicine_staff = 'uw_affiliation_uwnc-staff'
scca_emp = 'uw_affiliation_scca-employee'
uwp_pro = 'uw_affiliation_uwp-provider'
uwp_staff = 'uw_affiliation_uwp-staff'
uwnc_staff = 'uw_affiliation_uwnc-staff'
applicant = 'uw_affiliation_applicant'
staff = 'uw_affiliation_staff-employee'
stud_emp = 'uw_affiliation_student-employee'
bot_stud = 'uw_affiliation_bothell-student'
sea_stud = 'uw_affiliation_seattle-student'
tac_stud = 'uw_affiliation_tacoma-student'
grad = 'uw_affiliation_graduate-grad'
undergrad = 'uw_affiliation_undergraduate'  # grace 90 days
grad_prof = 'uw_affiliation_graduate'  # grace 90 days
pce = 'uw_affiliation_extension-student'
grad_c2 = 'uw_affiliation_continuum-student_graduate'
undergrad_c2 = 'uw_affiliation_continuum-student_undergraduate'
all_groups = [alumni_asso, staff, medicine_wf, medicine_aff, medicine_staff,
              uwp_pro, uwp_staff, med_res, fhcrc_emp, scca_emp, uwnc_staff,
              applicant, stud_emp, bot_stud, sea_stud, tac_stud, undergrad,
              grad_prof, grad, pce, grad_c2, undergrad_c2]
RELEVANT_GROUPS = frozenset(all_groups)


def _search_groups(uwnetid):
    """
    Returns a Set of the uw groups the uwnetid is an effective member of
    """
    group_names = set([])
    group_refs = gws.search_groups(member=uwnetid,
                                   scope="all",
                                   type="direct",
                                   stem="uw_affiliation",
                                   name="")
    if group_refs:
        for gr in group_refs:
            name = str(gr.name)
            if name in RELEVANT_GROUPS:
                group_names.add(name)
    return group_names

{'fraction_non_alphanumeric': 0.07899159663865546, 'fraction_numerical': 0.0033613445378151263, 'mean_word_length': 3.756243756243756, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '297635', 'n_tokens_mistral': 1665, 'n_tokens_neox': 1604, 'n_words': 320}