Skip to content

Commit 3c865fa

Browse files
committed
feat: Update dependencies and refactor UI components for astronomical data display
- Updated `isort` dependency from version 7.0.0 to 8.0.1 in `pyproject.toml`. - Updated `uv` dependency from version 0.10.6 to 0.10.7 in `pyproject.toml` and `uv.lock`. - Updated `uv_build` dependency from version 0.10.6 to 0.10.7 in `pyproject.toml`. - Refactored `synthwave.py` to utilize new `build_astro_table` and `build_forecast_table` functions for better modularity. - Removed unused imports and code related to direct rendering of astronomical data in `synthwave.py`. - Added new `astro_table.py` and `forecast_table.py` modules to handle rendering of astronomical and forecast data tables respectively. - Updated `header_panel.py` to simplify header rendering logic. - Adjusted `__init__.py` to reflect the removal of `synthwave_display` from exports.
1 parent c625c4c commit 3c865fa

13 files changed

Lines changed: 160 additions & 255 deletions

File tree

.github/workflows/auto-merge-on-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- name: Auto-merge matching PR
20-
uses: actions/github-script@v7
20+
uses: actions/github-script@v8
2121
with:
2222
github-token: ${{ secrets.GITHUB_TOKEN }}
2323
script: |

.github/workflows/cache-uv-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
build-cache:
88
runs-on: ubuntu-latest
99
env:
10-
UV_VERSION: '0.10.6'
10+
UV_VERSION: '0.10.8'
1111
PYTHON_VERSION: '3.13'
1212
steps:
1313
- name: Checkout repository

.github/workflows/ci-cd.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ jobs:
3838
release:
3939
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
4040
needs: [test, docker-build-and-image-scan]
41-
uses: ./.github/workflows/release.yaml
41+
uses: milsman2/python-app-template/.github/workflows/release.yaml@main
4242
permissions:
4343
contents: write
4444
secrets: inherit
4545

4646
trigger-auto-merge:
47-
needs: release
48-
if: needs.release.result == 'success'
49-
uses: ./.github/workflows/auto-merge-on-release.yml
47+
needs: [release, docker-build-and-image-scan]
48+
uses: milsman2/python-app-template/.github/workflows/auto-merge-on-release.yml@main
5049
permissions:
5150
contents: write
5251
pull-requests: write

.github/workflows/pytest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
permissions:
1010
contents: read
1111
env:
12-
UV_VERSION: '>=0.10.6'
12+
UV_VERSION: '>=0.10.8'
1313
PYTHON_VERSION: '3.13'
1414
steps:
1515
- name: Checkout repository

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
dist_artifacts_name: dist
1616
dist_artifacts_dir: dist
1717
lock_file_artifact: uv.lock
18-
UV_VERSION: '>=0.10.6'
18+
UV_VERSION: '>=0.10.8'
1919
PYTHON_VERSION: '3.13'
2020
GITHUB_ACTIONS_AUTHOR_NAME: github-actions
2121
GITHUB_ACTIONS_AUTHOR_EMAIL: actions@users.noreply.github.com

.github/workflows/ruff.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
permissions:
1010
contents: read
1111
env:
12-
UV_VERSION: '>=0.10.6'
12+
UV_VERSION: '>=0.10.8'
1313
PYTHON_VERSION: '3.13'
1414

1515
steps:

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies = [
99
"black>=26.1.0",
1010
"coverage>=7.13.2",
1111
"httpx>=0.28.1",
12-
"isort>=7.0.0",
12+
"isort>=8.0.1",
1313
"loguru>=0.7.3",
1414
"pathlib>=1.0.1",
1515
"prometheus-client>=0.24.1",
@@ -24,10 +24,10 @@ dependencies = [
2424
]
2525

2626
[project.optional-dependencies]
27-
build = ["uv >= 0.10.6"]
27+
build = ["uv >= 0.10.7"]
2828

2929
[build-system]
30-
requires = ["uv_build >= 0.10.6"]
30+
requires = ["uv_build >= 0.10.7"]
3131
build-backend = "uv_build"
3232

3333
[project.scripts]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""UI package for synthwave terminal display and related components."""
22

33
from sample_python_app.ui.display import display_astronomical_data
4-
from sample_python_app.ui.synthwave import synthwave_dashboard, synthwave_display
4+
from sample_python_app.ui.synthwave import synthwave_dashboard
55

6-
__all__ = ["synthwave_display", "synthwave_dashboard", "display_astronomical_data"]
6+
__all__ = ["synthwave_dashboard", "display_astronomical_data"]
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"""Render an astronomical summary table with figlets and times.
2+
3+
This module builds a two-column Rich table containing large figlet
4+
art for sunrise/sunset, followed by an "Event | Local Time" header
5+
row and the corresponding event times converted to the app timezone.
6+
"""
7+
8+
from pyfiglet import Figlet
9+
from rich.align import Align
10+
from rich.console import Group
11+
from rich.table import Table
12+
from rich.text import Text
13+
14+
from sample_python_app.core import Settings
15+
from sample_python_app.models import AstronomicalData
16+
17+
18+
def build_astro_table(astro: AstronomicalData, settings: Settings):
19+
"""Build a rich Table for the astronomical data.
20+
21+
The table renders large figlets first, then a manual header row
22+
"Event | Local Time" immediately below the figlets so the
23+
column labels appear under the art.
24+
"""
25+
astro_table = Table(show_header=False, box=None)
26+
27+
sunrise_local = astro.sunrise.astimezone(settings.tz)
28+
sun_art = Figlet(font="small", width=60).renderText("SUNRISE")
29+
sun_set_art = Figlet(font="small", width=60).renderText("SUNSET")
30+
sun_text = Text(sun_art, style="bold yellow")
31+
sun_set_text = Text(sun_set_art, style="bold blue")
32+
sunrise_time_art = Figlet(font="mini", width=60).renderText(
33+
sunrise_local.strftime("%I:%M %p")
34+
)
35+
sunset_time_art = Figlet(font="mini", width=60).renderText(
36+
astro.sunset.astimezone(settings.tz).strftime("%I:%M %p")
37+
)
38+
sunrise_time_text = Text(sunrise_time_art, style="bold yellow")
39+
sunset_time_text = Text(sunset_time_art, style="bold blue")
40+
41+
astro_table.add_row(
42+
Align(
43+
Group(Align.center(sun_text), Align.center(sunrise_time_text)),
44+
align="center",
45+
vertical="middle",
46+
),
47+
Align(
48+
Group(Align.center(sun_set_text), Align.center(sunset_time_text)),
49+
align="center",
50+
vertical="middle",
51+
),
52+
)
53+
54+
astro_table.add_row(
55+
Text("Event", style="bold magenta", justify="center"),
56+
Text("Local Time", style="bold magenta", justify="center"),
57+
)
58+
59+
tz = settings.tz
60+
time_fmt = "%I:%M %p %Z"
61+
for name, dt in astro.as_local(tz).items():
62+
label = name.replace("_", " ").title()
63+
value = dt.strftime(time_fmt) if hasattr(dt, "strftime") else str(dt)
64+
astro_table.add_row(f"[bold #ff6ec7]{label}[/]", f"[bold #00eaff]{value}[/]")
65+
66+
return astro_table
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""Module for building a rich Table to display forecast data."""
2+
3+
from rich.table import Table
4+
5+
from sample_python_app.core import Settings
6+
from sample_python_app.models.forecast_geojson import ForecastFeature
7+
8+
9+
def build_forecast_table(forecast: ForecastFeature, settings: Settings, periods=12):
10+
"""Build a rich Table for the hourly forecast data."""
11+
fc_table = Table(show_header=True, header_style="bold magenta", box=None)
12+
fc_table.add_column("Time", style="bold #00eaff")
13+
fc_table.add_column("T", style="bold #ffdd57")
14+
fc_table.add_column("POP", style="bold #ff6ec7")
15+
fc_table.add_column("Wind", style="bold #00ff9e")
16+
fc_table.add_column("Short", style="bold #ffffff")
17+
18+
count = 0
19+
for p in forecast.properties.periods:
20+
if count >= periods:
21+
break
22+
t = p.start_time.astimezone(settings.tz).strftime("%I %p")
23+
temp = (
24+
f"{p.temperature}°{p.temperature_unit or ''}"
25+
if p.temperature is not None
26+
else "-"
27+
)
28+
pop = (
29+
f"{int(p.probability_of_precipitation.value)}%"
30+
if p.probability_of_precipitation
31+
and p.probability_of_precipitation.value is not None
32+
else "-"
33+
)
34+
wind = p.wind_speed or "-"
35+
short = p.short_forecast or ""
36+
fc_table.add_row(t, temp, pop, wind, short)
37+
count += 1
38+
return fc_table

0 commit comments

Comments
 (0)