

@ensure_valid_username
@ensure_valid_groupname
def group_command(args):
    session = make_session()
    group = session.query(Group).filter_by(groupname=args.groupname).scalar()
    if (not group):
        logging.error('No such group %s'.format(args.groupname))
        return
    for username in args.username:
        user = User.get(session, name=username)
        if (not user):
            logging.error("no such user '{}'".format(username))
            return
        if (args.subcommand == 'add_member'):
            if args.member:
                role = 'member'
            elif args.owner:
                role = 'owner'
            elif args.np_owner:
                role = 'np-owner'
            elif user.manager:
                role = 'manager'
            assert role
            logging.info('Adding {} as {} to group {}'.format(username, role, args.groupname))
            group.add_member(user, user, 'grouper-ctl join', status='actioned', role=role)
            AuditLog.log(session, user.id, 'join_group', '{} manually joined via grouper-ctl'.format(username), on_group_id=group.id)
            session.commit()
        elif (args.subcommand == 'remove_member'):
            logging.info('Removing {} from group {}'.format(username, args.groupname))
            group.revoke_member(user, user, 'grouper-ctl remove')
            AuditLog.log(session, user.id, 'leave_group', '{} manually left via grouper-ctl'.format(username), on_group_id=group.id)
            session.commit()

dataset/ETHPy150Open dropbox/grouper/grouper/ctl/group.py group_command/VarMisuse@162/211 `args`->`user`