forked from kieras/zombie-projects-watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filters.py
52 lines (40 loc) · 1.22 KB
/
filters.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import re
def filter_projects_matching_org_level(orgs):
def filter_projects(project):
if project.get('org') in orgs:
return True
else:
return False
return filter_projects
def filter_whitelisted_projects(whitelisted_project_ids):
def filter_projects(project):
if project.get('projectId') not in whitelisted_project_ids:
return True
else:
return False
return filter_projects
def filter_older_than(days):
def filter_older_projects(project):
if int(project.get('createdDaysAgo')) > days:
return True
else:
return False
return filter_older_projects
def filter_owners(bindings):
if bindings.get('role') == 'roles/owner':
return True
else:
return False
def filter_users(member):
if 'user:' in member:
return True
else:
return False
def filter_whitelisted_users(whitelisted_users_regex):
def filter_users(project):
for owner in project.get('owners'):
for whitelisted_user in whitelisted_users_regex:
if re.search(whitelisted_user, owner):
return False
return True
return filter_users