Сжат формат таблицы для телефонов: w=25 символов, имена по 17 символов с обрезкой
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 4s
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 4s
This commit is contained in:
parent
62e1c73cdd
commit
98a8febf37
1 changed files with 13 additions and 22 deletions
|
|
@ -78,19 +78,10 @@ def format_pairings(pairings_data: dict, tournament_name: str) -> str:
|
|||
pairings = pairings_data['pairings']
|
||||
rnd = pairings_data['round']
|
||||
|
||||
max_name_w = 20
|
||||
for pairing in pairings:
|
||||
if len(pairing) == 3:
|
||||
for p in (pairing[0], pairing[1]):
|
||||
w = _display_width(p.name)
|
||||
if w > max_name_w:
|
||||
max_name_w = w
|
||||
max_name_w = min(max_name_w + 3, 42)
|
||||
w_board, w_name, w_pts = 2, 17, 4
|
||||
border = '┼'.join('─' * w for w in [w_board, w_name, w_pts])
|
||||
|
||||
w_board, w_pts = 4, 5
|
||||
border = '─┼─'.join('─' * w for w in [w_board, max_name_w, w_pts])
|
||||
|
||||
header = f'{_pad_col("#", w_board)} │ {_pad_col("Игрок", max_name_w)} │ {_pad_col("О", w_pts)}'
|
||||
header = f'{_pad_col("#", w_board)}│{_pad_col("Игрок", w_name)}│{_pad_col("О", w_pts)}'
|
||||
table_header = f'```\n{header}\n{border}\n'
|
||||
|
||||
source = pairings_data.get('source', 'algorithm')
|
||||
|
|
@ -99,7 +90,7 @@ def format_pairings(pairings_data: dict, tournament_name: str) -> str:
|
|||
|
||||
return {
|
||||
'title': f'*{_md_escape(tournament_name)}*\n📋 *Тур {rnd}* — пары',
|
||||
'rows': _build_table_rows(pairings, w_board, max_name_w, w_pts, border),
|
||||
'rows': _build_table_rows(pairings, w_board, w_name, w_pts, border),
|
||||
'table_header': table_header,
|
||||
'footer': footer,
|
||||
}
|
||||
|
|
@ -118,7 +109,7 @@ def _build_table_rows(pairings: list, w_board: int, w_name: int, w_pts: int,
|
|||
rows.append(
|
||||
f'{_pad_col(str(board), w_board)}│'
|
||||
f'{_pad_col(p1.name, w_name)}│'
|
||||
f'{_pad_col(str(p1.points), w_pts)}'
|
||||
f'{_pad_col(f"{p1.points:.1f}", w_pts)}'
|
||||
)
|
||||
rows.append(
|
||||
f'{_pad_col("", w_board)}│'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue