provider.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:landscape-client 作者: CanonicalLtd 项目源码 文件源码
def get_group_data(self):
        """
        Parse group(5) formatted files and return tuples of group data in the
        form (groupname, group password, group id and a list of member
        usernames).
        """
        group_data = []
        group_file = open(self._group_file, "r")
        reader = csv.DictReader(group_file, fieldnames=self.group_fields,
                                delimiter=":", quoting=csv.QUOTE_NONE)
        current_line = 0
        for row in reader:
            current_line += 1
            # Skip if we find the NIS marker
            if (row["name"].startswith("+") or row["name"].startswith("-")):
                continue
            try:
                group_data.append((row["name"], row["passwd"], int(row["gid"]),
                                   row["members"].split(",")))
            except (AttributeError, ValueError):
                logging.warn("group file %s is incorrectly formatted: "
                             "line %d." % (self._group_file, current_line))
        group_file.close()
        return group_data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号