@@ -64,7 +64,7 @@ def sync_team(client=None, owner=None, team_id=None, slug=None):
6464 try :
6565 org = client .organization (owner )
6666 team = org .team (team_id )
67- custom_map = load_custom_map ()
67+ custom_map , ignore_users = load_custom_map ()
6868 try :
6969 directory_group = custom_map [slug ] if slug in custom_map else slug
7070 directory_members = directory_group_members (group = directory_group )
@@ -73,7 +73,8 @@ def sync_team(client=None, owner=None, team_id=None, slug=None):
7373 traceback .print_exc (file = sys .stderr )
7474
7575 team_members = github_team_members (
76- client = client , owner = owner , team_id = team_id , attribute = USER_SYNC_ATTRIBUTE
76+ client = client , owner = owner , team_id = team_id ,
77+ attribute = USER_SYNC_ATTRIBUTE , ignore_users = ignore_users
7778 )
7879 compare = compare_members (
7980 group = directory_members , team = team_members , attribute = USER_SYNC_ATTRIBUTE
@@ -124,9 +125,9 @@ def github_team_info(client=None, owner=None, team_id=None):
124125 return org .team (team_id )
125126
126127
127- def github_team_members (client = None , owner = None , team_id = None , attribute = "username" ):
128+ def github_team_members (client = None , owner = None , team_id = None , attribute = "username" , ignore_users = [] ):
128129 """
129- Look up members of a give team in GitHub
130+ Look up members of a given team in GitHub
130131 :param client:
131132 :param owner:
132133 :param team_id:
@@ -151,7 +152,7 @@ def github_team_members(client=None, owner=None, team_id=None, attribute="userna
151152 else :
152153 for member in team .members ():
153154 team_members .append ({"username" : str (member ), "email" : "" })
154- return team_members
155+ return [ m for m in team_members if m [ "username" ] not in ignore_users ]
155156
156157
157158def compare_members (group , team , attribute = "username" ):
@@ -241,6 +242,7 @@ def load_custom_map(file="syncmap.yml"):
241242 :return:
242243 """
243244 syncmap = {}
245+ ignore_users = []
244246 if os .path .isfile (file ):
245247 from yaml import load , Loader
246248
@@ -249,7 +251,9 @@ def load_custom_map(file="syncmap.yml"):
249251 for d in data ["mapping" ]:
250252 syncmap [d ["github" ]] = d ["directory" ]
251253
252- return syncmap
254+ ignore_users = data .get ('ignore_users' , [])
255+
256+ return (syncmap , ignore_users )
253257
254258
255259def get_app_installations ():
@@ -279,7 +283,7 @@ def sync_all_teams():
279283 print (f'Syncing all teams: { time .strftime ("%A, %d. %B %Y %I:%M:%S %p" )} ' )
280284
281285 installations = get_app_installations ()
282- custom_map = load_custom_map ()
286+ custom_map , _ = load_custom_map ()
283287 futures = []
284288 install_count = 0
285289 with ThreadPoolExecutor (max_workers = 10 ) as exe :
0 commit comments