本文整理汇总了Python中group.Group.find_by_name方法的典型用法代码示例。如果您正苦于以下问题:Python Group.find_by_name方法的具体用法?Python Group.find_by_name怎么用?Python Group.find_by_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类group.Group
的用法示例。
在下文中一共展示了Group.find_by_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: member_badges
# 需要导入模块: from group import Group [as 别名]
# 或者: from group.Group import find_by_name [as 别名]
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"))