def get_game(site, description="<STR_LIT>", create=False):
game = None<EOL>games = Game.objects.filter(site=site).order_by("<STR_LIT>")<EOL>try:<EOL><INDENT>game = games[<NUM_LIT:0>]<EOL><DEDENT>except IndexError:<EOL><INDENT>game = None<EOL><DEDENT>if game is None or game.is_expired() or is_after_endtime():<EOL><INDENT>if create:<EOL><INDENT>if is_starttime():<EOL><INDENT>game = Game(site=site, description=description)<EOL>game.save()<EOL><DEDENT>else:<EOL><INDENT>raise TimeRangeError(<EOL>_(u"<STR_LIT>"))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>game = None<EOL><DEDENT><DEDENT>elif not is_after_endtime():<EOL><INDENT>game = games[<NUM_LIT:0>]<EOL><DEDENT>return game<EOL>
get the current game, if its still active, else
creates a new game, if the current time is inside the
GAME_START_TIMES interval and create=True
@param create: create a game, if there is no active game
@returns: None if there is no active Game, and none shoul be
created or the (new) active Game.