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


Python Group.all_yp_members_without_senior_duplicates_dict方法代码示例

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


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

示例1: census_list

# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import all_yp_members_without_senior_duplicates_dict [as 别名]
def census_list(osm, auth, term=None, csv=False, attending_only=False,
                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_member.address1'],
                     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()])

    all_members_dict = group.all_yp_members_without_senior_duplicates_dict()

    for section in ('Swinfen', 'Paget', 'Garrick'):
        members = all_members_dict[section]
        for member in members:
            age = member.age().days / 365
            if (age > 5 and age < 9):
                add_row(section, member)
            else:
                log.info("Excluding: {} {} because not of Beaver age ({}).".format(
                    member['first_name'], member['last_name'], age
                ))

    for section in ('Maclean', 'Rowallan', 'Somers'):
        members = all_members_dict[section]
        for member in members:
            age = member.age().days / 365
            if (age > 7 and age < 11):
                add_row(section, member)
            else:
                log.info("Excluding: {} {} because not of Cub age ({}).".format(
                    member['first_name'], member['last_name'], age
                ))

    for section in ('Johnson', 'Boswell', 'Erasmus'):
        members = all_members_dict[section]
        for member in members:
            age = member.age().days / 365
            if (age > 10 and age < 16):
                add_row(section, member)
            else:
                log.info("Excluding: {} {} because not of Scout age ({}).".format(
                    member['first_name'], member['last_name'], age
                ))

    headers = ["Section", "Section Name", "First", "Last", "DOB", "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,代码行数:77,代码来源:cli.py


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