def sync_members(g):
    g.state.revert()
    g._register_silos()
    granary_list = g.silos
    granary_list_database = list_silos()
    usernames = list_usernames()
    for silo in granary_list:
        if (not (silo in granary_list_database)):
            add_silo(silo)
        kw = g.describe_silo(silo)
        owners = []
        admins = []
        managers = []
        submitters = []
        if (('administrators' in kw) and kw['administrators']):
            admins = [x.strip() for x in kw['administrators'].split(',') if x]
        if (('managers' in kw) and kw['managers']):
            managers = [x.strip() for x in kw['managers'].split(',') if x]
        if (('submitters' in kw) and kw['submitters']):
            submitters = [x.strip() for x in kw['submitters'].split(',') if x]
        owners = [x for x in owners if (x in usernames)]
        admins = [x for x in admins if (x in usernames)]
        managers = [x for x in managers if (x in usernames)]
        submitters = [x for x in submitters if (x in usernames)]
        d_admins = []
        d_managers = []
        d_sunbmitters = []
        if (silo in granary_list_database):
            (d_admins, d_managers, d_submitters) = list_group_usernames(silo)
            admins.extend(d_admins)
            managers.extend(d_managers)
            submitters.extend(d_submitters)
        owners.extend(admins)
        owners.extend(managers)
        owners.extend(submitters)
        admins = list(set(admins))
        managers = list(set(managers))
        submitters = list(set(submitters))
        owners = list(set(owners))
        new_silo_users = []
        for a in admins:
            if (not (a in d_admins)):
                new_silo_users.append((a, 'administrator'))
        for a in managers:
            if (not (a in d_managers)):
                new_silo_users.append((a, 'manager'))
        for a in new_submitters:
            if (not (a in d_submitters)):
                new_silo_users.append((a, 'submitter'))
        if new_silo_users:
            add_group_users(silo, new_silo_users)
        kw['owners'] = ','.join(owners)
        kw['administrators'] = ','.join(admins)
        kw['managers'] = ','.join(managers)
        kw['submitters'] = ','.join(submitters)
        g.describe_silo(silo, **kw)
    g.sync()
    return
def sync_members(g):
    g.state.revert()
    g._register_silos()
    granary_list = g.silos
    granary_list_database = list_silos()
    usernames = list_usernames()
    for silo in granary_list:
        if (not (silo in granary_list_database)):
            add_silo(silo)
        kw = g.describe_silo(silo)
        owners = []
        admins = []
        managers = []
        submitters = []
        if (('administrators' in kw) and kw['administrators']):
            admins = [x.strip() for x in kw['administrators'].split(',') if x]
        if (('managers' in kw) and kw['managers']):
            managers = [x.strip() for x in kw['managers'].split(',') if x]
        if (('submitters' in kw) and kw['submitters']):
            submitters = [x.strip() for x in kw['submitters'].split(',') if x]
        owners = [x for x in owners if (x in usernames)]
        admins = [x for x in admins if (x in usernames)]
        managers = [x for x in managers if (x in usernames)]
        submitters = [x for x in submitters if (x in usernames)]
        d_admins = []
        d_managers = []
        d_sunbmitters = []
        if (silo in granary_list_database):
            (d_admins, d_managers, d_submitters) = list_group_usernames(silo)
            admins.extend(d_admins)
            managers.extend(d_managers)
            submitters.extend(d_submitters)
        owners.extend(admins)
        owners.extend(managers)
        owners.extend(submitters)
        admins = list(set(admins))
        managers = list(set(managers))
        submitters = list(set(submitters))
        owners = list(set(owners))
        new_silo_users = []
        for a in admins:
            if (not (a in d_admins)):
                new_silo_users.append((a, 'administrator'))
        for a in managers:
            if (not (a in d_managers)):
                new_silo_users.append((a, 'manager'))
        for a in new_submitters:
            if (not (a in d_submitters)):
                new_silo_users.append((a, 'submitter'))
        if new_silo_users:
            add_group_users(silo, new_silo_users)
        kw['owners'] = ','.join(owners)
        kw['administrators'] = ','.join(admins)
        kw['managers'] = ','.join(managers)
        kw['submitters'] = ','.join(submitters)
        g.describe_silo(silo, **kw)
    g.sync()
    return