本文整理汇总了Python中indico.modules.groups.models.groups.LocalGroup.members方法的典型用法代码示例。如果您正苦于以下问题:Python LocalGroup.members方法的具体用法?Python LocalGroup.members怎么用?Python LocalGroup.members使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indico.modules.groups.models.groups.LocalGroup
的用法示例。
在下文中一共展示了LocalGroup.members方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: migrate_groups
# 需要导入模块: from indico.modules.groups.models.groups import LocalGroup [as 别名]
# 或者: from indico.modules.groups.models.groups.LocalGroup import members [as 别名]
def migrate_groups(self):
print cformat('%{white!}migrating groups')
for old_group in committing_iterator(self.zodb_root['groups'].itervalues()):
if old_group.__class__.__name__ != 'Group':
continue
group = LocalGroup(id=int(old_group.id), name=convert_to_unicode(old_group.name).strip())
print cformat('%{green}+++%{reset} %{white!}{:6d}%{reset} %{cyan}{}%{reset}').format(group.id, group.name)
members = set()
for old_member in old_group.members:
if old_member.__class__.__name__ != 'Avatar':
print cformat('%{yellow!}!!! Unsupported group member type: {}').format(
old_member.__class__.__name__)
continue
user = User.get(int(old_member.id))
if user is None:
print cformat('%{yellow!}!!! User not found: {}').format(old_member.id)
continue
while user.merged_into_user:
user = user.merged_into_user
if user.is_deleted:
print cformat('%{yellow!}!!! User deleted: {}').format(user.id)
continue
members.add(user)
for member in sorted(members, key=attrgetter('full_name')):
print cformat('%{blue!}<->%{reset} %{white!}{:6d} %{yellow}{} ({})').format(
member.id, member.full_name, member.email)
group.members = members
db.session.add(group)