Extract the members of a group from /etc/group.
331019
def ParseGroupEntry(self, line):
    """"""
    fields = ("name", "passwd", "gid", "members")
    if line:
      rslt = dict(zip(fields, line.split(":")))
      name = rslt["name"]
      group = self.entry.setdefault(name, rdf_client.Group(name=name))
      group.pw_entry.store = self.GetPwStore(rslt["passwd"])
      if group.pw_entry.store == self.base_store:
        group.pw_entry.hash_type = self.GetHashType(rslt["passwd"])
      # If the group contains NIS entries, they may not have a gid.
      if rslt["gid"]:
        group.gid = int(rslt["gid"])
      group.members = set(rslt["members"].split(","))
1275618
def by_group(self):  # pragma: no cover
        
        group_membership = {}
        for record in self.__get_groups_with_membership():
            group_membership[record.cn.value] = [
                i for i in record.memberUid.values
            ]
        return group_membership
449716
def iter_finds(regex_obj, s):
    """"""
    if isinstance(regex_obj, str):
        for m in re.finditer(regex_obj, s):
            yield m.group()
    else:
        for m in regex_obj.finditer(s):
            yield m.group()
833516
private String extractGroup(String path) {
        if (TextUtils.isEmpty(path) || !path.startsWith("/")) {
            throw new HandlerException(Consts.TAG + "Extract the default group failed, the path must be start with '/' and contain more than 2 '/'!");
        }

        try {
            String defaultGroup = path.substring(1, path.indexOf("/", 1));
            if (TextUtils.isEmpty(defaultGroup)) {
                throw new HandlerException(Consts.TAG + "Extract the default group failed! There's nothing between 2 '/'!");
            } else {
                return defaultGroup;
            }
        } catch (Exception e) {
            logger.warning(Consts.TAG, "Failed to extract default group! " + e.getMessage());
            return null;
        }
    }
1097775
def get_groups(self, roles):
        """"""
        ret = {}
        for role in roles:
            if role not in self.flatten:
                raise MissingRole(role)
            for b in self.flatten[role]['backends_groups']:
                if b not in ret:
                    ret[b] = []
                ret[b] = ret[b] + self.flatten[role]['backends_groups'][b]
        return ret
236977
def group_members(self, group, limit=99999):
        
        url = 'rest/api/1.0/admin/groups/more-members'
        params = {}
        if limit:
            params['limit'] = limit
        if group:
            params['context'] = group
        return (self.get(url, params=params) or {}).get('values')
701089
def _fmto_groups(self):
        """"""
        ret = defaultdict(set)
        for key in self:
            ret[getattr(self, key).group].add(getattr(self, key))
        return dict(ret)
776641
def _get_span(s, pattern):
    """"""
    i, j = -1, -1

    match = pattern.match(s)
    if not match:
        return i, j

    for group_name in pattern.groupindex:
        i, j = match.span(group_name)
        if (i, j) != (-1, -1):
            return i, j

    return i, j
894645
def lazy_groups_of(iterator: Iterator[A], group_size: int) -> Iterator[List[A]]:
    
    return iter(lambda: list(islice(iterator, 0, group_size)), [])
1102853
def in_group(self, group, dn=False):
        
        if dn:
            return group in self.groups()
        return group.check_member(self)
56983
def get_gid(group_name)
      Etc.group { |g| return g.gid if g.name == group_name }
    end
263100
private Set<String> getGroups(DirContext context, String callerDn) {
        Set<String> groups = null;
        String groupSearchBase = idStoreDefinition.getGroupSearchBase();
        String groupSearchFilter = idStoreDefinition.getGroupSearchFilter();
        if (groupSearchBase.isEmpty() || groupSearchFilter.isEmpty()) {
            groups = getGroupsByMembership(context, callerDn);
        } else {
            groups = getGroupsByMember(context, callerDn, groupSearchBase, groupSearchFilter);
        }
        return groups;
    }
490140
def members(name, members_list):
    '''
    
    '''
    retcode = 1
    grp_info = __salt__['group.info'](name)
    if grp_info and name in grp_info['name']:
        cmd = '/usr/bin/dscl . -delete /Groups/{0} GroupMembership'.format(name)
        retcode = __salt__['cmd.retcode'](cmd) == 0
        for user in members_list.split(','):
            cmd = '/usr/bin/dscl . -merge /Groups/{0} GroupMembership {1}'.format(name, user)
            retcode = __salt__['cmd.retcode'](cmd)
            if not retcode == 0:
                break
            # provided list is '': users previously deleted from group
            else:
                retcode = 0

    return retcode == 0
1367173
def from_group(cls, group):
        
        if not group:
            return
        tag_items = group.split(";")
        return list(map(cls.parse, tag_items))
549835
def group_lines(lines):
    """"""
    groups = []
    group = []

    for line in lines:
        if line.strip() == "":
            groups.append(group[:])
            group = []
            continue
        group.append(line)

    if group:
        groups.append(group[:])

    return groups
1339670
def group_values(self, group_name):
        """"""
        group_index = self.groups.index(group_name)
        values = []
        for key in self.data_keys:
            if key[group_index] not in values:
                values.append(key[group_index])
        return values
687235
def members(self, x):
        """"""
        if x not in self._parents:
            yield x
            return
        cur_x = x
        while True:
            yield cur_x
            cur_x = self._prev_next[cur_x][1]
            if cur_x == x:
                break