#NEWLINE# def get_team( tid = None , name = None ) : #NEWLINE# #INDENT# '\n    Retrieve a team based on a property (tid, name, etc.).\n\n    Args:\n        tid: team id\n        name: team name\n    Returns:\n        Returns the corresponding team object or None if it could not be found\n    ' #NEWLINE# db = api . api . common . get_conn ( ) #NEWLINE# match = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if ( tid is not None ) : #NEWLINE# #INDENT# match . update ( { #NEWLINE# #INDENT# 'tid' : tid , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( name is not None ) : #NEWLINE# #INDENT# match . update ( { #NEWLINE# #INDENT# 'team_name' : name , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if api . auth . is_logged_in ( ) : #NEWLINE# #INDENT# match . update ( { #NEWLINE# #INDENT# 'tid' : api . user . get_user ( ) [ 'tid' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise InternalException ( 'Must supply tid or team name to get_team' ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# team = db . teams . find_one ( match , { #NEWLINE# #INDENT# '_id' : 0 , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( team is None ) : #NEWLINE# #INDENT# raise InternalException ( 'Team does not exist.' ) #NEWLINE# #UNINDENT# return name