Metadata-Version: 2.4
Name: resultadosonpe
Version: 0.4.0
Summary: TUI application to display Peru (ONPE) election results
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.14
Requires-Dist: plotext<6,>=5.2.8
Requires-Dist: textual-plotext>=1.0.1
Requires-Dist: textual>=8.2.3
Requires-Dist: urllib3>=2.6.3
Description-Content-Type: text/markdown

# resultadosonpe

A terminal user interface (TUI) application that displays live election
results from Peru's ONPE (Oficina Nacional de Procesos Electorales).

Built with [Textual](https://textual.textualize.io/) and
[plotext](https://github.com/piccolomo/plotext) for rich, interactive
charts right in your terminal.

## Features

- Live election results for Presidential, Senators, and Andean Parliament
  races
- Horizontal bar charts showing candidate/party vote percentages
- Progress header with tallied records count and percentage
- Auto-refresh every 60 seconds with manual refresh button (`r` key)
- Internationalization support (English and Spanish)
- Connects directly to the official ONPE results API

## Installation

### Via uvx (recommended)

```bash
uvx resultadosonpe
```

### Via uv

```bash
uv tool install resultadosonpe
resultadosonpe
```

### From source

```bash
git clone https://github.com/jpchauvel/resultadosonpe.git
cd resultadosonpe
uv sync
uv run resultadosonpe
```

## Usage

Launch the application:

```bash
resultadosonpe
```

### Keyboard shortcuts

| Key | Action  |
|-----|---------|
| `r` | Refresh |
| `q` | Quit    |

### Language

The UI language follows your system locale. To force Spanish:

```bash
LANGUAGE=es resultadosonpe
```

To force English:

```bash
LANGUAGE=en resultadosonpe
```

## Development

### Prerequisites

- Python 3.14+
- [uv](https://docs.astral.sh/uv/)

### Setup

```bash
git clone https://github.com/jpchauvel/resultadosonpe.git
cd resultadosonpe
uv sync --group dev
uv run pre-commit install
uv run pre-commit install --hook-type pre-push
```

### Running tests

```bash
uv run pytest
```

### Linting and type checking

```bash
uv run ruff check src/ tests/ features/
uv run ruff format --check src/ tests/ features/
uv run mypy src/resultadosonpe/
uv run bandit -r src/resultadosonpe/ -s B101
```

## Architecture

```
src/resultadosonpe/
  __main__.py      Entry point, locale setup
  app.py           Textual app with auto-refresh and chart layout
  api_client.py    HTTP client for the ONPE results API
  models.py        Data models (ElectoralProcess, Election, etc.)
  transforms.py    Data transformation for chart display
  widgets.py       Custom Textual widgets (ElectionChart, ProgressHeader)
  i18n.py          Gettext-based internationalization
  locales/         Translation files (.po/.mo)
```

## License

[MIT](LICENSE)
