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


Python Group.section_all_members方法代码示例

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


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

示例1: _main

# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import section_all_members [as 别名]
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,代码行数:28,代码来源:export_group_email_list.py

示例2: _main

# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import section_all_members [as 别名]
def _main(osm, auth, sections, outdir, term):

    assert os.path.exists(outdir) and os.path.isdir(outdir)

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

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

    for section in sections:
        vcards = [member2vcard(member, section) for
                  member in group.section_all_members(section)]

        open(os.path.join(outdir, section + ".vcf"), 'w').writelines(vcards)
开发者ID:,项目名称:,代码行数:17,代码来源:

示例3: contacts_detail

# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import section_all_members [as 别名]
def contacts_detail(osm, auth, sections, csv=False, term=None, no_headers=False):
    group = Group(osm, auth, MAPPING.keys(), term)
    section_map = {'Garrick': 'Beavers',
                   'Paget': 'Beavers',
                   'Swinfen': 'Beavers',
                   'Maclean': 'Cubs',
                   'Somers': 'Cubs',
                   'Rowallan': 'Cubs',
                   'Erasmus': 'Scouts',
                   'Boswell': 'Scouts',
                   'Johnson': 'Scouts'}
    rows = []

    def add_row(section, member):
        rows.append([section_map[section], section, member['first_name'], member['last_name'],
                     member['date_of_birth'],
                     member['contact_primary_1.email1'],
                     member['contact_primary_1.address1'],
                     member['contact_primary_1.address2'],
                     member['contact_primary_1.address3'],
                     member['contact_primary_1.postcode'],
                     member['contact_primary_2.address1'],
                     member['floating.gender'].lower()])

    for section in sections:
        for member in group.section_all_members(section):
            add_row(section, member)

    headers = ["Section", "Section Name", "First", "Last", "DOB", "Email1", "Address1", "Address1.1", "Address1.2", "Address1.3",
               "Address2", "Address3", "Gender"]

    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,代码行数:43,代码来源:cli.py

示例4: _main

# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import section_all_members [as 别名]
def _main(osm, auth, sections, outdir, email, term):

    assert os.path.exists(outdir) and os.path.isdir(outdir)

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

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

    vcards = []

    for section in sections:
        section_vcards = [member2vcards(member, section) for
                          member in group.section_all_members(section)]

        #  flatten list of lists.
        vcards += list(itertools.chain(*section_vcards))

    open(os.path.join(outdir, "group.vcf"), 'w').writelines(vcards)

    if email:
        send([email, ], "OSM Group vcards", "".join(vcards))
开发者ID:hippysurfer,项目名称:scout-records,代码行数:25,代码来源:export_group_vcard.py

示例5: sync_contacts

# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import section_all_members [as 别名]

#.........这里部分代码省略.........
                    if key not in contacts:
                        contacts[key] = dict(first=_first,
                                             last=_last_osm,
                                             email=_email.lower(),
                                             addresses=[],
                                             yp=[],
                                             sections=[],
                                             groups=[],
                                             phones=[])

                    contacts[key]['sections'].append(section)
                    contacts[key]['yp'].append(yp_name)
                    contacts[key]['groups'].extend(parent_groups)
                    if len(address):
                        contacts[key]['addresses'].append((f'{_first} {_last}', address))

                    if group.is_yl(member):
                        contacts[key]['groups'].extend(yl_groups)

                    for _ in ['phone1', 'phone2']:
                        number, name = parse_tel(f(_), _)
                        if number != "":
                            contacts[key]['phones'].append((number, name))

    # For every member in the group we want to extract each unique contact address. We ignore all those that
    # not marked for wanting contact.

    # We then add all of the these unique contacts to google.

    # Now we add each of the contacts to the groups that they are associated with.

    log.info("Fetch members from OSM")
    for section_ in sections:
        for member in group.section_all_members(section_):
            add_member_contacts(section_, Group.SECTION_TYPE[section_], member)

    # for c in contacts.values():
    #    print(f'{c}')

    #  remove duplicates
    groups = []
    for key, contact in contacts.items():
        contact['groups'] = set(contact['groups'])
        contact['sections'] = set(contact['sections'])
        contact['yp'] = set(contact['yp'])
        contact['addresses'] = set(contact['addresses'])
        contact['phones'] = set(contact['phones'])
        groups.extend(contact['groups'])

    #  Gather all the groups
    groups = set(groups)
    group_names = [f"{_} (OSM)" for _ in groups]

    contacts = [contact for key, contact in contacts.items()]

    # Sync up the google groups.

    log.info("Fetch list of groups from google")
    existing_osm_groups = fetch_list_of_groups()

    # Fetch the list of group-members - this is used to find who should
    # be managers of the groups.
    existing_role_group_members = fetch_group_members(
        fetch_list_of_groups(prefix='7th-'))

    if delete_google_groups:
开发者ID:hippysurfer,项目名称:scout-records,代码行数:70,代码来源:sync_contacts_to_google.py

示例6: contacts_list

# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import section_all_members [as 别名]
def contacts_list(osm, auth, sections, term=None):
    group = Group(osm, auth, MAPPING.keys(), term)

    for section in sections:
        for member in group.section_all_members(section):
            print("{} {}".format(member['first_name'], member['last_name']))
开发者ID:hippysurfer,项目名称:scout-records,代码行数:8,代码来源:cli.py


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