<s> from soccermetrics . rest import SoccermetricsRestClient <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> client = SoccermetricsRestClient ( ) <EOL> manager = client . managers . get ( full_name = u'<STR_LIT>' ) . data [ <NUM_LIT:0> ] <EOL> hmatches = client . link . get ( manager . link . natl . homeMatches , sort = "<STR_LIT>" ) . all ( ) <EOL> amatches = client . link . get ( manager . link . natl . awayMatches , sort = "<STR_LIT>" ) . all ( ) <EOL> matches = sorted ( hmatches + amatches , key = lambda k : k . matchDate ) <EOL> sub_list = [ ] <EOL> for match in matches : <EOL> team_key = '<STR_LIT>' if match . homeManagerName == manager . fullName else '<STR_LIT>' <EOL> subs = client . link . get ( match . link . substitutions , <EOL> team_name = getattr ( match , team_key ) , sort = "<STR_LIT>" ) . data <EOL> sub_dict = dict ( first = None , second = None , third = None ) <EOL> subkeys = sorted ( sub_dict . keys ( ) ) <EOL> for k , sub in enumerate ( subs ) : <EOL> sub_dict [ subkeys [ k ] ] = int ( sub . timeMins ) <EOL> print "<STR_LIT>" % ( match . matchday , match . homeTeamName , <EOL> match . awayTeamName ) , <EOL> print sub_dict [ '<STR_LIT>' ] , sub_dict [ '<STR_LIT>' ] , sub_dict [ '<STR_LIT>' ] <EOL> sub_list . append ( sub_dict ) <EOL> dict2list = lambda vec , k : [ x [ k ] for x in vec if x [ k ] ] <EOL> avg1st = sum ( dict2list ( sub_list , '<STR_LIT>' ) ) / len ( dict2list ( sub_list , '<STR_LIT>' ) ) <EOL> avg2nd = sum ( dict2list ( sub_list , '<STR_LIT>' ) ) / len ( dict2list ( sub_list , '<STR_LIT>' ) ) <EOL> avg3rd = sum ( dict2list ( sub_list , '<STR_LIT>' ) ) / len ( dict2list ( sub_list , '<STR_LIT>' ) ) <EOL> print avg1st , avg2nd , avg3rd </s>
