Runs the ``\\du`` command and returns a list of column values with
        information about all user roles.
976801
def list_users(self):
        
        lines = output_lines(self.exec_psql('\\du'))
        return [line.split('|') for line in lines]
1360695
def list_roles(self, envs=[], query='/roles/'):
        
        juicer.utils.Log.log_debug("List Roles %s", ", ".join(envs))

        count = 0

        for env in envs:
            count += 1
            rcount = 0

            juicer.utils.Log.log_info("%s:", env)
            _r = self.connectors[env].get(query)
            if _r.status_code == Constants.PULP_GET_OK:
                roles = juicer.utils.load_json_str(_r.content)

                for role in roles:
                    rcount += 1

                    juicer.utils.Log.log_info("Name: %s" % role['display_name'])
                    juicer.utils.Log.log_info("Description: %s" % role['description'])
                    juicer.utils.Log.log_info("ID: %s" % role['id'])
                    juicer.utils.Log.log_info("Users: %s" % ', '.join(role['users']))

                    if rcount < len(roles):
                        # just want a new line
                        juicer.utils.Log.log_info("\n")

                if count < len(envs):
                    # just want a new line
                    juicer.utils.Log.log_info("\n")
            else:
                _r.raise_for_status()
        return True
853287
function getRole(user) {
      user = user || getCurrentUser();
      return _.find(userRoles, {role: user.role});
    }
163175
def role_list(profile=None, **connection_args):
    '''
    
    '''
    kstone = auth(profile, **connection_args)
    ret = {}
    for role in kstone.roles.list():
        ret[role.name] = dict((value, getattr(role, value)) for value in dir(role)
                              if not value.startswith('_') and
                              isinstance(getattr(role, value), (six.string_types, dict, bool)))
    return ret
44682
private function compileUserRoles()
    {
        if ($this->userRoles !== null) {
            return;
        }

        if (!$this->user) {
            $this->userRoles = [];

            return;
        }

        $roleList = [];
        $roleExpansion = [];

        /** @var Role $role */
        foreach ($this->roleProvider->getAllRoles() as $role) {
            $roleList[$role->getId()] = $role;
        }

        /** @var Role $userRole */
        $userRoles = $this->user->getRoles();
        if ($userRoles) {
            foreach ($userRoles as $userRole) {
                $roleExpansion[] = $userRole->getName();

                $parentRole = $userRole->getParent();
                while ($parentRole) {
                    $roleExpansion[] = $parentRole->getName();
                    $parentRole = $parentRole->getParent();
                }
            }
        }
        $this->userRoles = array_unique($roleExpansion);
    }
1368582
def roles_dict(path, repo_prefix="", repo_sub_dir=""):
    
    exit_if_path_not_found(path)

    aggregated_roles = {}

    roles = os.walk(path).next()[1]

    # First scan all directories
    for role in roles:
        for sub_role in roles_dict(path + "/" + role, repo_prefix="",
                                   repo_sub_dir=role + "/"):
            aggregated_roles[role + "/" + sub_role] = role + "/" + sub_role

    # Then format them
    for role in roles:
        if is_role(os.path.join(path, role)):
            if isinstance(role, basestring):
                role_repo = "{0}{1}".format(repo_prefix, role_name(role))

                aggregated_roles[role] = role_repo

    return aggregated_roles
977300
def list_roles_for_user(self, user):
        
        user_id = utils.get_id(user)
        uri = "users/%s/roles" % user_id
        resp, resp_body = self.method_get(uri)
        if resp.status_code in (401, 403):
            raise exc.AuthorizationFailure("You are not authorized to list "
                    "user roles.")
        roles = resp_body.get("roles")
        return roles
973942
public function listCommand()
    {
        $users = $this->userService->getUsers();

        $tableRows = [];
        $headerRow = ['Name', 'Email', 'Account(s)', 'Role(s)', 'Active'];

        foreach ($users as $user) {
            $tableRows[] = $this->getTableRowForUser($user);
        }

        $this->output->outputTable($tableRows, $headerRow);
    }
680753
def format_users():
    ''''''
    lines = []
    u = users()
    count = u['count']
    if not count:
        raise DapiCommError('Could not find any users on DAPI.')
    for user in u['results']:
        line = user['username']
        if user['full_name']:
            line += ' (' + user['full_name'] + ')'
        lines.append(line)
    return lines
1029364
def get_user_roles(user):
    """"""
    if not hasattr(user, '_role_cache'):
        user._role_cache = list(TenantRole.objects.filter(user=user).values_list(
            'group', 'role', 'tenant'))
    return user._role_cache
1249264
public String[] getDestinationRoles(Map<String, ?> destinationPermissions, String dest, String user) {
        SibTr.debug(tc,  " dest: " + dest + " user: " + user);
        if (user.startsWith("cn=")) {
            user = user.substring(3, user.indexOf(","));
            SibTr.debug(tc, CLASS_NAME + " user truncated to: " + user);
        }
        ArrayList<String> roleList = new ArrayList();
        int element = 0;
        Set<String> destinations = destinationPermissions.keySet();
        
        if (dest.indexOf("/") != -1) {
            dest = dest.substring(0,  dest.indexOf("/"));
        }

        for (String destination : destinations) {
            SibTr.debug(tc, CLASS_NAME + " Destination: " + destination + " dest: " + dest);
            if (destination.equals(dest)) {
                Permission permission = (Permission) destinationPermissions.get(destination);
                Map<String, Set<String>> userRoles = permission.getRoleToUserMap();
                Set<String> uRoles = userRoles.keySet();
                for (String role : uRoles) {
                    SibTr.debug(tc, CLASS_NAME + " role: " + role);
                    SibTr.debug(tc, CLASS_NAME + "    users: " + userRoles.get(role));
                    Set<String> rs = userRoles.get(role);
                    for (String r : rs) {
                        SibTr.debug(tc, CLASS_NAME + "     user: " + r);
                        if (r.equals(user)) {
                            roleList.add(role);
                        }
                     }
                }
                
                Map<String, Set<String>> groupRoles = permission.getRoleToGroupMap();
                Set<String> gRoles = groupRoles.keySet();
                for (String role : gRoles) {
                    SibTr.debug(tc, CLASS_NAME + " role: " + role);
                    SibTr.debug(tc, CLASS_NAME + "    groups: " + groupRoles.get(role));
                   
                    Set <String> rs = groupRoles.get(role);
                    
                    if (rs != null) {
                        List<String> groups = MessagingSecurityUtility
                                        .getGroupsAssociatedToUser(user,
                                                                   this);
                        if (groups != null) {
                            for (String g : groups) {
                                if (rs.contains(g)) {
                                    if (!roleList.contains(role)) {
                                        roleList.add(role);
                                    }
                                }
                            }
                        }
                       
                    }
                }                
                               
            }
        }
        if (roleList != null)
            SibTr.debug(tc,  CLASS_NAME + " roles: " + roleList.toArray().toString());
        else 
            SibTr.debug(tc, CLASS_NAME + " no roles identified for user " + user);
        
        Object[] roleListAsObjectArray = roleList.toArray();
        String[] roleListAsStrArray = Arrays.copyOf(roleListAsObjectArray, roleListAsObjectArray.length, String[].class);
        
        SibTr.exit(tc, CLASS_NAME);
        return (roleListAsStrArray);
    }
1184991
function getRoles (session) {
    // return roles from session or default
    return session && Array.isArray(session.roles)
        ? session.roles
        // default roles
        : ['all', (session && session.accountId ? 'authenticated' : 'anonymous')]
}
957884
protected function getRoleSets()
    {
        return Util::getRoleSets($this->getUsername(), new String($this->lookupName), new String($this->rolesQuery), $this);
    }
323208
public function run ()
    {
        // http://stackoverflow.com/q/1598411
        $list = [
            ["name" => "Super Admin", "slug" => "super-admin"], // Manage everything
            ["name" => "Project Admin", "slug" => "project-admin"], // Manage most aspects of the site
            ["name" => "Editor", "slug" => "editor"], // Scheduling and managing content
            ["name" => "Author", "slug" => "author"], // Write important content
            ["name" => "Contributor", "slug" => "contributor"], // Authors with limited rights
            ["name" => "Moderator", "slug" => "moderator"], // Moderate user content
            ["name" => "Member", "slug" => "member"], // Special user access
            ["name" => "Subscriber", "slug" => "subscriber"], // Paying Average Joe
            ["name" => "User", "slug" => "user"], // Average Joe
        ];

        DB::beginTransaction ();

        try {
            foreach ($list as $roleData) {
                $role = Roles::where ('slug', $roleData['slug'])->first ();

                if (!$role)
                    Roles::create ($roleData);
            }
        } catch (\Exception $e) {
            DB::rollback ();

            throw new Exception($e->getMessage ());
        }

        DB::commit ();
    }
808701
private List<String> getUsersFor(Collection<String> roles){
		List<String> users = new HashList<>();
		for(String role: roles){
			if(roleMembershipRU.containsKey(role))
				users.addAll(roleMembershipRU.get(role));
		}
		return users;
	}
961966
def has_role(user, roles):
    """"""
    if user and user.is_superuser:
        return True

    if not isinstance(roles, list):
        roles = [roles]

    normalized_roles = []
    for role in roles:
        if not inspect.isclass(role):
            role = RolesManager.retrieve_role(role)

        normalized_roles.append(role)

    user_roles = get_user_roles(user)

    return any([role in user_roles for role in normalized_roles])
245906
def get_user_switchable_roles(self):
        
        roles = []
        for rs in self.current.user.role_set:
            # rs.role != self.current.role is not True after python version 2.7.12
            if rs.role.key != self.current.role.key:
                roles.append((rs.role.key, '%s %s' % (rs.role.unit.name,
                                                      rs.role.abstract_role.name)))
        return roles