当前位置: 首页>>代码示例>>Python>>正文


Python group.Group类代码示例

本文整理汇总了Python中group.Group的典型用法代码示例。如果您正苦于以下问题:Python Group类的具体用法?Python Group怎么用?Python Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

    def create(cls, user_name, email, password=None, locale=None, openid_identity=None, global_admin=False):
        from group import Group
        from membership import Membership
        from openid import OpenID

        import adhocracy.lib.util as util

        if password is None:
            password = util.random_token()

        import adhocracy.i18n as i18n

        if locale is None:
            locale = i18n.get_default_locale()

        user = User(user_name, email, password, locale)
        meta.Session.add(user)
        default_group = Group.by_code(Group.CODE_DEFAULT)
        default_membership = Membership(user, None, default_group)
        meta.Session.add(default_membership)

        if global_admin:
            admin_group = Group.by_code(Group.CODE_ADMIN)
            admin_membership = Membership(user, None, admin_group)
            meta.Session.add(admin_membership)

        if openid_identity is not None:
            openid = OpenID(unicode(openid_identity), user)
            meta.Session.add(openid)

        meta.Session.flush()
        return user
开发者ID:AnonOnWarpath,项目名称:adhocracy,代码行数:32,代码来源:user.py

示例2: create

    def create(cls, user_name, email, password=None, locale=None,
               openid_identity=None, global_admin=False, display_name=None,
               autojoin=True, shibboleth_persistent_id=None):
        """
        Create a user. If user_name is None, a random user name is generated.
        """
        from group import Group
        from membership import Membership

        import adhocracy.lib.util as util
        if password is None:
            password = util.random_token()

        import adhocracy.i18n as i18n
        if locale is None:
            locale = i18n.get_default_locale()

        while user_name is None:
            # Note: This can theoretically lead to IntegrityErrors if the same
            # username is generated at the same time. This is very unlikely
            # though.
            from adhocracy.lib.util import random_username
            try_user_name = random_username()
            if cls.find(try_user_name) is None:
                user_name = try_user_name
                from adhocracy.lib import helpers as h
                h.flash(_('The random username %s has been assigned to you.') %
                        user_name, 'success')

        user = User(user_name, email, password, locale,
                    display_name=display_name)
        meta.Session.add(user)

        # Add the global default group
        default_group = Group.by_code(Group.CODE_DEFAULT)
        default_membership = Membership(user, None, default_group)
        meta.Session.add(default_membership)

        # Autojoin the user in instances
        config_autojoin = config.get('adhocracy.instances.autojoin')
        if autojoin and config_autojoin:
            user.fix_autojoin(commit=False)

        if global_admin:
            admin_group = Group.by_code(Group.CODE_ADMIN)
            admin_membership = Membership(user, None, admin_group)
            meta.Session.add(admin_membership)

        if openid_identity is not None:
            from adhocracy.model.openid import OpenID
            openid = OpenID(unicode(openid_identity), user)
            meta.Session.add(openid)

        if shibboleth_persistent_id is not None:
            from adhocracy.model.shibboleth import Shibboleth
            shib = Shibboleth(shibboleth_persistent_id, user)
            meta.Session.add(shib)

        meta.Session.flush()
        return user
开发者ID:vogunal,项目名称:adhocracy,代码行数:60,代码来源:user.py

示例3: _main

def _main(osm, auth, sections):

    group = Group(osm, auth, MAPPING.keys(), None)

    for section in sections:
        assert section in group.SECTIONIDS.keys(), \
            "section must be in {!r}.".format(group.SECTIONIDS.keys())

    contacts = []

    for section in sections:
        section_contacts = [member2contacts(member, section) for
                          member in group.section_all_members(section)]

        #  flatten list of lists.
        contacts += list(itertools.chain(*section_contacts))

    # Remove blank emails
    contacts = [contact for contact in contacts if contact[2].strip() != "" ]

    # remove duplicates
    by_email = {contact[2]: contact for contact in contacts}
    contacts = list(by_email.values())

    w = csv_writer(sys.stdout)
    w.writerows(contacts)
开发者ID:hippysurfer,项目名称:scout-records,代码行数:26,代码来源:export_group_email_list.py

示例4: member_badges

def member_badges(osm, auth, firstname, lastname, csv=False, no_headers=False, term=None):
    group = Group(osm, auth, MAPPING.keys(), term)

    members = group.find_by_name(firstname, lastname)
    # member = members[-1]
    rows = []
    for member in members:
        for section_type in ('beavers', 'cubs', 'scouts'):
            try:
                badges = member.get_badges(section_type=section_type)
                if badges is not None:
                    for badge in [_ for _ in badges if _['awarded'] == '1']:
                        rows.append([member['date_of_birth'], member['last_name'],
                                     member['age'], section_type, member._section['sectionname'],
                                     badge['badge'],
                                     datetime.date.fromtimestamp(int(badge['awarded_date'])).isoformat()])
            except:
                import traceback
                traceback.print_exc()
                pass

    headers = ["DOB", "Last Name", "Age", "Section Type", "Section Name", "Badge"]

    if csv:
        w = csv_writer(sys.stdout)
        if not no_headers:
            w.writerow(list(headers))
        w.writerows(rows)
    else:
        if not no_headers:
            print(tabulate.tabulate(rows, headers=headers))
        else:
            print(tabulate.tabulate(rows, tablefmt="plain"))
开发者ID:hippysurfer,项目名称:scout-records,代码行数:33,代码来源:cli.py

示例5: create

    def create(cls, key, label, user, description=None, locale=None):
        from group import Group
        from membership import Membership
        from page import Page

        instance = Instance(unicode(key).lower(), label, user)
        instance.description = description
        instance.default_group = Group.by_code(Group.INSTANCE_DEFAULT)
        if locale is not None:
            instance.locale = locale
        meta.Session.add(instance)
        supervisor_group = Group.by_code(Group.CODE_SUPERVISOR)
        membership = Membership(user, instance, supervisor_group,
                                approved=True)
        meta.Session.add(membership)
        if config.get_bool('adhocracy.create_initial_instance_page'):
            Page.create(instance, label, u"", user)

        # Autojoin the user in instances
        config_autojoin = config.get('adhocracy.instances.autojoin')
        if (config_autojoin and
                (config_autojoin == 'ALL' or
                 key in (k.strip() for k in config_autojoin.split(',')))):
            users = adhocracy.model.User.all()
            for u in users:
                autojoin_membership = Membership(u, instance,
                                                 instance.default_group)
                meta.Session.add(autojoin_membership)

        meta.Session.flush()
        return instance
开发者ID:rowanthorpe,项目名称:adhocracy,代码行数:31,代码来源:instance.py

示例6: _main

def _main(osm, auth):
    #test_section = '15797'

    group = Group(osm, auth, MAPPING.keys())

    if group.missing_adult_references():
        log.warn("Missing adult references {!r}".format(
            group.missing_adult_references()))
开发者ID:hippysurfer,项目名称:scout-records,代码行数:8,代码来源:check.py

示例7: _parse_group

 def _parse_group(self, group_element):
     group = Group()
     group.name = group_element.get("name")
     if group.name is None:
         raise ParseError("Missing 'name' attribute in group")
     self.groups[group.name] = group
     for repo_element in group_element.findall("repo"):
         self._parse_repo(group, repo_element)
开发者ID:,项目名称:,代码行数:8,代码来源:

示例8: flip

    def flip(self):
        '''Return a group that spans the entire canvas, but is flipped 
        vertically, add it to the DOM and return a reference to it.'''

        group = Group()
        group.matrix(1, 0, 0, -1, 0, self.height)
        self.add_child(group)

        return group
开发者ID:generictjohnson,项目名称:simplesvg,代码行数:9,代码来源:canvas.py

示例9: main

def main():
	file = open("test.xml","r")
	line = file.readline()

	while not startDevices(line):
		line = file.readline()

	line = file.readline().strip()
	
	devices = []
	device = ""
	group = ""
	capability = ""
	
	while not endDevices(line):
		if beginDevice(line):
			line = deleteTags(line,"<device ",">")
			att_id = getAttrId(line)
			att_user = getAttrUser(line)
			att_fall = getAttrFall(line)
			
			device = Device(att_id, att_user, att_fall)
			line = file.readline()

		if endDevice(line):
			devices.append(device)
			line = file.readline()

		if beginGroup(line):
			line = deleteTags(line,"<group ",">")
			att_id = getAttrId(line)

			group = Group(att_id)
			group.setDevice(device)
			line = file.readline()

		if endGroup(line):
			device.addGroup(group)
			line = file.readline()

		if beginCapability(line):
			line = deleteTags(line, "<capability ", "/>")
			att_name = getAttrName(line)
			att_value = getAttrValue(line)

			capability = Capability(att_name, att_value)
			capability.setGroup(group)
			group.addCapability(capability)
			line = file.readline()

	print "Devices\n"
	printDevices(devices)
	print "End Devices\n"
	
	file.close()
	return 0
开发者ID:ebuendia,项目名称:ProyectoPython,代码行数:56,代码来源:xml-parser.py

示例10: _get_group_node

 def _get_group_node(self, app_node, group):
     assert self._lock.locked()
     name = "g%s" % group
     if app_node.has_child(name):
         return app_node.get_child(name)
     # Obviously an group factory based on app id, someday...
     group_node = Group()
     group_node.configure({"parent": app_node, "name": name, "group": group})
     group_node.start()
     return group_node
开发者ID:,项目名称:,代码行数:10,代码来源:

示例11: load_groups

 def load_groups(self):
     groups_url = 'http://s.web2.qq.com/api/get_group_name_list_mask2'
     data = {'r': open('json/load_groups.json').read() % self.token}
     headers = {"Referer": 'http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=1'}
     response_of_load_group = self.client.post(groups_url, data=data, headers=headers)
     groups_data = json.loads(response_of_load_group.text)
     if groups_data['retcode'] == 0:
         for group_data in groups_data['result']['gnamelist']:
             group = Group(group_data, self.token, self.client)
             self.groups[group.id] = group
             print group_data
             group.message('闪亮登场!')
开发者ID:encorehu,项目名称:lunaroid,代码行数:12,代码来源:qq.py

示例12: group

    def group(self):
        """

        :return: Group() that is attached to this meeting
        """
        meeting_group_relationship = self._graph_db.match(start_node=None,
                                                         rel_type=GraphRelationship.HAS_MEETING,
                                                         end_node=self.meeting_node)
        group = Group()
        for rel in meeting_group_relationship:
            group.id = rel.end_node.properties['id']
            group.get_group()
        return group
开发者ID:julianpistorius,项目名称:back-end-api,代码行数:13,代码来源:meeting.py

示例13: leave_group

    def leave_group(self, group_id):
        """
        remove relationship between user and study group
        :param group_id: string uuid
        :return: None
        """
        #TODO exception handling
        group = Group()
        group.id = group_id
        user_group_relationship = self._graph_db.match_one(start_node=self.user_node,
                                                          rel_type=GraphRelationship.MEMBER_OF,
                                                          end_node=group.group_node)

        self._graph_db.delete(user_group_relationship)
开发者ID:julianpistorius,项目名称:back-end-api,代码行数:14,代码来源:user.py

示例14: render_subimage

 def render_subimage(self):
     # #10: not render non-terminal (as separate image) if is empty
     if not self.subfields:
         return []
     # create a group view, that should be saved as separated image
     config = copy.deepcopy(self._passed_config)
     if 'view' in config:
         del config['view']
     if 'children' in config:
         del config['children']
     group = Group(name=self.name, value=self.value, mark=self.marked,
                   save_as_subimage=True, **config)
     group.add_children(self.subfields)
     return group.render()
开发者ID:PP-TSD,项目名称:sdgen,代码行数:14,代码来源:non_terminal.py

示例15: deserialize

    def deserialize(self, data):
        self.__init__()

        self.name    = data.get('name')
        self.vars    = data.get('vars', dict())
        self.address = data.get('address', '')
        self._uuid   = data.get('uuid', uuid.uuid4())
        self.implicit= data.get('implicit', False)

        groups = data.get('groups', [])
        for group_data in groups:
            g = Group()
            g.deserialize(group_data)
            self.groups.append(g)
开发者ID:jrragan,项目名称:nexus-controller,代码行数:14,代码来源:host.py


注:本文中的group.Group类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。