diff --git a/participation/management/commands/export_results.py b/participation/management/commands/export_results.py index a86340a..55ee898 100644 --- a/participation/management/commands/export_results.py +++ b/participation/management/commands/export_results.py @@ -17,8 +17,8 @@ class Command(BaseCommand): self.w("") self.w("") - def w(self, msg): - self.stdout.write(msg) + def w(self, msg, prefix="", suffix=""): + self.stdout.write(f"{prefix}{msg}{suffix}") def handle_tournament(self, tournament): name = tournament.name @@ -64,17 +64,16 @@ class Command(BaseCommand): self.w("") bold = (not tournament.final and participation.final) or (tournament.final and i < 2) if bold: - self.w(f"\t{participation.team.name} ({participation.team.trigram})") + prefix, suffix = "\t", "" else: - self.w(f"\t{participation.team.name} ({participation.team.trigram})") + prefix, suffix = "\t", "" + self.w(f"{participation.team.name} ({participation.team.trigram})", prefix, suffix) for pool in tournament.pools.filter(participations=participation).all(): pool_note = pool.average(participation) - self.w(f"\t{pool_note:.01f}") - self.w(f"\t{note:.01f}") + self.w(f"{pool_note:.01f}", prefix, suffix) + self.w(f"{note:.01f}", prefix, suffix) if tournament.final: - self.w(f"\t{participation.mention_final}") - else: - self.w(f"\t{participation.mention}") + self.w(participation.mention_final if tournament.final else participation.mention, prefix, suffix) self.w("") self.w("") self.w("")