add --only-sponsors flag

Filter results based on companies that sponsor the foundation at gold
or platinum level.

Change-Id: Ieacdfc3f512fc102656d3bcfcd9fccdacac20f43
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
This commit is contained in:
Doug Hellmann 2018-05-03 17:21:20 -04:00
parent 4e25b3f101
commit 979d1c8239
2 changed files with 21 additions and 1 deletions

View File

@ -45,3 +45,7 @@ class Sponsors:
if name.lower() in self._names:
return name
return '*other'
@functools.lru_cache(maxsize=1024)
def __contains__(self, name):
return name.lower() in self._names

View File

@ -32,13 +32,20 @@ class ContributionsReportBase(lister.Lister):
action='append',
help='filter to only include specific roles (may be repeated)',
)
parser.add_argument(
sponsor_group = parser.add_mutually_exclusive_group()
sponsor_group.add_argument(
'--highlight-sponsors',
default=False,
action='store_true',
help=('highlight sponsor organizations and '
'combine stats for others'),
)
sponsor_group.add_argument(
'--only-sponsors',
default=False,
action='store_true',
help=('show only stats for sponsor organizations'),
)
parser.add_argument(
'--sponsor-level',
default='all',
@ -97,6 +104,15 @@ class ContributionsReportBase(lister.Lister):
if ignore_teams:
data = (d for d in data if d['Team'].lower() not in ignore_teams)
if parsed_args.only_sponsors:
sponsor_map = sponsors.Sponsors(parsed_args.sponsor_level)
data = (
d
for d in data
if d['Organization'] in sponsor_map
)
ignore_tags = set(parsed_args.ignore_tag)
if ignore_tags:
team_data = governance.Governance(