Helper to get the context ID and user ID from the given names.
421385
def _get_context_and_user_ids(self, context_name, user_name):
        """"""
        if context_name is None:
            return None, None

        context_id = self.get_context_info(context_name)['id']
        user_id = None
        if user_name:
            user_id = self._get_user_id_from_name(context_id, user_name)

        return context_id, user_id
1054910
private String getUsernameForUserId(int id) {
        if (id > 0) {
            String username = userIdentityStore.getPortalUserName(id);
            if (username != null) {
                return username;
            }
            logger.warn(
                    "Invalid userID {} found when exporting a portlet; return system username instead",
                    id);
        }
        return systemUsername;
    }
1070232
def get_username(self, userid):
        '''
        '''

        username = self.user_map.get(userid)
        if not username:
            users = self.get_users()
            if users:
                members = {
                    m['id']: m['name']
                    for m in users.get('members', [{}])
                    if m.get('id')
                    and m.get('name')
                }
                if members:
                    self.user_map.update(members)

                username = self.user_map.get(userid, userid)

        return username
1317896
def get_read_user_ids(self):
        """"""
        read_user_ids = self.json_response.get("readUserIdList", None)
        self.logger.info("%s\t%s" % (self.request_method, self.request_url))
        return read_user_ids
562260
def get_owner_names_value(self, obj):
        """"""
        return [
            self._get_user(user)
            for user in get_users_with_permission(obj, get_full_perm('owner', obj))
        ]
290172
def _get_id_from_username(self, username):
        
        _mask = "mask[id, username]"
        _filter = {'users': {'username': utils.query_filter(username)}}
        user = self.list_users(_mask, _filter)
        if len(user) == 1:
            return [user[0]['id']]
        elif len(user) > 1:
            raise exceptions.SoftLayerError("Multiple users found with the name: %s" % username)
        else:
            raise exceptions.SoftLayerError("Unable to find user id for %s" % username)
195006
def user_parse(data):
        """"""
        user_ = data.get('user', {})
        yield 'id', data.get('user_nsid') or user_.get('id')
        yield 'username', user_.get('username', {}).get('_content')
        first_name, _, last_name = data.get(
            'fullname', {}).get('_content', '').partition(' ')
        yield 'first_name', first_name
        yield 'last_name', last_name
94099
def user_parse(data):
        """"""
        user_ = data.get('user')
        yield 'id', user_.get('username')
        yield 'username', user_.get('username')
        yield 'first_name', user_.get('first_name')
        yield 'last_name', user_.get('last_name')
        yield 'picture', user_.get('avatar')
        yield 'link', user_.get('resource_url')
680696
def find_nameid(self, userid, **kwargs):
        
        res = []
        try:
            _vals = self.db[userid]
        except KeyError:
            logger.debug("failed to find userid %s in IdentDB", userid)
            return res

        for val in _vals.split(" "):
            nid = decode(val)
            if kwargs:
                for key, _val in kwargs.items():
                    if getattr(nid, key, None) != _val:
                        break
                else:
                    res.append(nid)
            else:
                res.append(nid)

        return res
743297
def user_info(name, **client_args):
    '''
    
    '''
    matching_users = (user for user in list_users(**client_args)
                      if user.get('user') == name)

    try:
        return next(matching_users)
    except StopIteration:
        pass
943300
def get_username(details, backend, response, *args, **kwargs):
    

    user = details.get('user')
    if not user:
        user_uuid = kwargs.get('uid')
        if not user_uuid:
            return

        username = uuid_to_username(user_uuid)
    else:
        username = user.username

    return {
        'username': username
    }
549126
def get_context_data(self, **kwargs):
        
        context = super(BaseAuthorDetail, self).get_context_data(**kwargs)
        context['author'] = self.author
        return context
367514
def getUsers(context, roles, allow_empty=True):
    
    mtool = getToolByName(context, 'portal_membership')
    pairs = allow_empty and [['', '']] or []
    users = mtool.searchForMembers(roles=roles)
    for user in users:
        uid = user.getId()
        fullname = user.getProperty('fullname')
        if not fullname:
            fullname = uid
        pairs.append((uid, fullname))
    pairs.sort(lambda x, y: cmp(x[1], y[1]))
    return DisplayList(pairs)
26922
def _ids(self):
        """"""
        for pk in self._pks:
            yield getattr(self, pk)

        for pk in self._pks:

            try:
                yield str(getattr(self, pk))
            except ValueError:
                pass
546575
protected static String getUserNames(Set<String> ids, String andLocalized) {

        List<String> userNames = new ArrayList<String>();

        for (String id : ids) {
            CmsSessionInfo session = OpenCms.getSessionManager().getSessionInfo(new CmsUUID(id));
            try {
                String name = A_CmsUI.getCmsObject().readUser(session.getUserId()).getName();
                if (!userNames.contains(name)) {
                    userNames.add(name);
                }
            } catch (CmsException e) {
                LOG.error("Unable to read user information", e);
            }
        }

        Iterator<String> iterator = userNames.iterator();

        String res = "";

        while (iterator.hasNext()) {
            res += iterator.next();
            if (iterator.hasNext()) {
                res += ", ";
            }
        }
        int lastPosSeperation = res.lastIndexOf(", ");

        return lastPosSeperation == -1
        ? res
        : res.substring(0, lastPosSeperation)
            + " "
            + andLocalized
            + " "
            + res.substring(lastPosSeperation + 2, res.length());
    }
1086806
def context(names):
    """"""
    import json

    contexts = [_context_json(name) for name in set(names)]
    if contexts:
        click.echo(
            json.dumps(
                contexts[0] if len(contexts) == 1 else contexts,
                indent=2,
            )
        )
1139475
def _get_zone_id_from_name(self, name):
        """"""
        results = self.client['Account'].getDomains(
            filter={"domains": {"name": utils.query_filter(name)}})
        return [x['id'] for x in results]