Skip to content

Commit e2cd7be

Browse files
author
Lee Richardson
committed
Clean up
1 parent 9e1b277 commit e2cd7be

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

ansible/filter_plugins/apigee_helpers.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import collections
21
import re
32
from typing import List
43

@@ -75,27 +74,28 @@ def apigee_remove_proxy_from_product(product: dict, proxy_to_remove):
7574
return product
7675

7776

78-
def apigee_teams_map(teamMembers: List[dict], teams: List[dict]):
79-
joined = collections.defaultdict(dict)
80-
for item in teamMembers + teams:
77+
def apigee_team_to_admin(team):
78+
return next((attr.get('value') for attr in team['attributes'] if attr['name'] == 'ADMIN_EMAIL'), None)
79+
80+
81+
def apigee_teams_map(team_members: List[dict], teams: List[dict]):
82+
from collections import defaultdict
83+
joined = defaultdict(dict)
84+
for item in team_members + teams:
8185
joined[item['name']].update(item)
8286
full_teams = list(joined.values())
8387

8488
return {
8589
team['name']: {
86-
"contact": next((attr.get('value') for attr in team['attributes'] if attr['name'] == 'ADMIN_EMAIL'), {}),
90+
"contact": apigee_team_to_admin(team),
8791
"members": team['members']
8892
}
8993
for team in full_teams
9094
}
9195

9296

9397
def apigee_teams_to_point_of_contact(teams: List[dict]):
94-
95-
return {
96-
next((attr.get('value') for attr in team['attributes'] if attr['name'] == 'ADMIN_EMAIL'), {})
97-
for team in teams
98-
}
98+
return {apigee_team_to_admin(team) for team in teams}
9999

100100

101101
def apigee_teams_to_members(teams: List[dict]):

0 commit comments

Comments
 (0)