<s> from __future__ import print_function <EOL> import argparse <EOL> import csv <EOL> import glob <EOL> import os . path <EOL> import sys <EOL> import yaml <EOL> from releasetools import governance <EOL> MILESTONE = '<STR_LIT>' <EOL> INTERMEDIARY = '<STR_LIT>' <EOL> def main ( ) : <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> default = governance . PROJECTS_LIST , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> default = os . path . expanduser ( '<STR_LIT>' ) , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> choices = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> default = '<STR_LIT>' , <EOL> ) <EOL> parser . add_argument ( <EOL> '<STR_LIT>' , <EOL> help = '<STR_LIT>' , <EOL> ) <EOL> args = parser . parse_args ( ) <EOL> latest_versions = { } <EOL> pat = os . path . join ( <EOL> args . releases_repo , <EOL> '<STR_LIT>' , <EOL> args . series , <EOL> '<STR_LIT>' , <EOL> ) <EOL> for fn in glob . glob ( pat ) : <EOL> with open ( fn , '<STR_LIT:r>' ) as f : <EOL> y = yaml . safe_load ( f . read ( ) ) <EOL> deliverable = os . path . basename ( fn ) [ : - <NUM_LIT:5> ] <EOL> v = y [ '<STR_LIT>' ] [ - <NUM_LIT:1> ] [ '<STR_LIT:version>' ] <EOL> latest_versions [ deliverable ] = v <EOL> team_data = governance . get_team_data ( ) <EOL> teams = { <EOL> n . lower ( ) : governance . Team ( n , i ) <EOL> for n , i in team_data . items ( ) <EOL> } <EOL> deliverables_by_model = { <EOL> MILESTONE : { <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : { } , <EOL> } , <EOL> INTERMEDIARY : { <EOL> '<STR_LIT>' : { } , <EOL> '<STR_LIT>' : { } , <EOL> } , <EOL> } <EOL> for t in teams . values ( ) : <EOL> for dn , di in t . deliverables . items ( ) : <EOL> for model in deliverables_by_model . keys ( ) : <EOL> if model in di . tags : <EOL> if '<STR_LIT>' in di . tags : <EOL> managed = '<STR_LIT>' <EOL> else : <EOL> managed = '<STR_LIT>' <EOL> dbm_team = deliverables_by_model [ model ] [ managed ] . setdefault ( <EOL> di . team . name . lower ( ) , [ ] ) <EOL> dbm_team . append ( di ) <EOL> break <EOL> if args . format == '<STR_LIT>' : <EOL> writer = csv . writer ( sys . stdout ) <EOL> writer . writerow ( <EOL> ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) ) <EOL> for managed in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> for model in [ MILESTONE , INTERMEDIARY ] : <EOL> short_model = model . rpartition ( '<STR_LIT:->' ) [ - <NUM_LIT:1> ] <EOL> dbm_teams = sorted ( deliverables_by_model [ model ] [ managed ] . items ( ) ) <EOL> for team_name , team_deliverables in dbm_teams : <EOL> team = teams [ team_name ] <EOL> for d in sorted ( team_deliverables , key = lambda d : d . name ) : <EOL> writer . writerow ( <EOL> ( managed , <EOL> short_model , <EOL> team . name . lower ( ) , <EOL> team . data [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> team . data [ '<STR_LIT>' ] [ '<STR_LIT:email>' ] , <EOL> team . data . get ( '<STR_LIT>' ) , <EOL> d . type , <EOL> d . name , <EOL> latest_versions . get ( d . name , '<STR_LIT>' ) ) ) <EOL> else : <EOL> for managed in [ '<STR_LIT>' , '<STR_LIT>' ] : <EOL> print ( '<STR_LIT>' . format ( managed ) ) <EOL> for model in [ MILESTONE , INTERMEDIARY ] : <EOL> print ( '<STR_LIT>' . format ( model ) ) <EOL> dbm_teams = sorted ( deliverables_by_model [ model ] [ managed ] . items ( ) ) <EOL> for team_name , team_deliverables in dbm_teams : <EOL> team = teams [ team_name ] <EOL> print ( '<STR_LIT>' . format ( team_name ) ) <EOL> print ( '<STR_LIT>' . format ( <EOL> team . data [ '<STR_LIT>' ] [ '<STR_LIT>' ] , <EOL> team . data [ '<STR_LIT>' ] [ '<STR_LIT:email>' ] , <EOL> ) ) <EOL> print ( '<STR_LIT>' . format ( team . data . get ( '<STR_LIT>' , '<STR_LIT>' ) ) ) <EOL> print ( '<STR_LIT>' ) <EOL> for d in sorted ( team_deliverables , key = lambda d : d . name ) : <EOL> v = latest_versions . get ( d . name , '<STR_LIT>' ) <EOL> print ( '<STR_LIT>' . format ( d = d , v = v ) ) <EOL> print ( ) </s>
