def _create_event(team: Team, game: Game) -> Result[Event, ErrCode]: if not game.opening_whistle: return Result.from_failure(ErrCode.MISSING_OPENING_WHISTLE) venue = 'Heimspiel' if game.home_team == team else 'Auswärtsspiel' summary = f'{venue} - {game.opponent_of(team).short_name}' leg_title = game.leg_title() description = f'{leg_title} gegen {game.opponent_of(team).name}' if game.sports_hall: description += '\nSporthalle: ' + str(game.sports_hall.name) dated_games = game.other_games().filter(opening_whistle__isnull=False) for other in sorted(dated_games, key=lambda g: g.opening_whistle): if other.home_goals is not None: description += f'\n{other.leg_title()}: {other.home_goals}:{other.guest_goals} ({_outcome(other, team)})' start = game.opening_whistle end = start + timedelta(minutes=90) dtstamp = datetime.now() location = game.sports_hall.address if game.sports_hall else None uid = f'game/{game.number}@hbscorez.de' event = Event() event.add('summary', summary) event.add('description', description) event.add('dtstart', start) event.add('dtend', end) event.add('dtstamp', dtstamp) if location: event['location'] = vText(location) event['uid'] = uid return Result.from_value(event)