-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathui.py
More file actions
63 lines (55 loc) · 2.01 KB
/
Copy pathui.py
File metadata and controls
63 lines (55 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from rich.console import Console
from rich.progress import (
Progress,
SpinnerColumn,
BarColumn,
TextColumn,
TimeRemainingColumn,
MofNCompleteColumn
)
from rich.panel import Panel
class TranslationInterface:
def __init__(self):
self.console = Console()
# Estado dos Arquivos
self.current_file = "Carregando..."
self.total_files = 0
self.completed_files = 0
# Configuração da Barra
self.progress = Progress(
SpinnerColumn(),
BarColumn(bar_width=None),
TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
TextColumn("•"),
MofNCompleteColumn(), # Linhas X/Y
TextColumn("•"),
TimeRemainingColumn(),
expand=True
)
self.task_id = self.progress.add_task("", total=100)
def set_totals(self, total_lines, total_files):
"""Define o total de linhas E de arquivos."""
self.total_files = total_files
self.progress.update(self.task_id, total=total_lines)
def update_status(self, filename):
"""Atualiza apenas o nome do arquivo atual (chamado a cada linha)."""
self.current_file = filename
self.progress.update(self.task_id, advance=1)
def mark_file_complete(self):
"""Chamado quando um arquivo termina por completo."""
self.completed_files += 1
def get_renderable(self):
"""
Retorna o Painel.
O rodapé agora mostra: "Arquivo Atual | Arqs: 5/20"
"""
# Formata o contador de arquivos
file_counter = f"[bold green]Arqs: {self.completed_files}/{self.total_files}[/]"
return Panel(
self.progress,
title="[bold blue]Translate-CLI (BETA)[/]",
# Subtítulo com duas informações: Arquivo Atual + Contagem de Arquivos
subtitle=f"[yellow]{self.current_file}[/] • {file_counter}",
border_style="blue",
padding=(1, 2)
)