Skip to content
Open
29 changes: 24 additions & 5 deletions src/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import logging
import sys

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -71,9 +72,27 @@ def print_wave(show_wave, show_large_wave, color):
color = "blue"

if show_large_wave:
print(
colors[color]
+ """
if sys.platform == "win32" and sys.stdout.encoding.lower() != "utf-8":
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
print(
colors[color]
+ """
.-``'.
.` .`
_.-' '._
.' `.
/ \\
| |
| |
\\ /
`._ _.'
`-......-`

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a wave?

"""
+ colors["end"]
)
else:
print(
colors[color]
+ """
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣴⣶⠾⠿⠿⠯⣷⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣾⠛⠁⠀⠀⠀⠀⠀⠀⠈⢻⣦⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⠿⠁⠀⠀⠀⢀⣤⣾⣟⣛⣛⣶⣬⣿⣆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
Expand All @@ -84,8 +103,8 @@ def print_wave(show_wave, show_large_wave, color):
⢀⣄⣠⣶⣿⠏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠓⠚⠋⠉⠀⠀⠀⠀⠀⠀⠈⠛⡛⡻⠿⠿⠙⠓⢒⣺⡿⠋⠁
⠉⠉⠉⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠁⠀
"""
+ colors["end"]
)
+ colors["end"]
)
elif show_wave:
print(
colors[color]
Expand Down
50 changes: 24 additions & 26 deletions src/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,32 +103,30 @@ def _build_args_string(ns):
tokens.append("metric")
if ns.imperial:
tokens.append("imperial")
flag_map = {
"json": "json",
"gpt": "gpt",
"hide_wave": "hide_wave",
"hide_uv": "hide_uv",
"hide_height": "hide_height",
"hide_direction": "hide_direction",
"hide_period": "hide_period",
"hide_location": "hide_location",
"hide_date": "hide_date",
"show_large_wave": "show_large_wave",
"show_past_uv": "show_past_uv",
"show_height_history": "show_height_history",
"show_direction_history": "show_direction_history",
"show_period_history": "show_period_history",
"show_air_temp": "show_air_temp",
"show_wind_speed": "show_wind_speed",
"show_wind_direction": "show_wind_direction",
"show_rain_sum": "show_rain_sum",
"show_precipitation_prob": "show_precipitation_prob",
"show_cloud_cover": "show_cloud_cover",
"show_visibility": "show_visibility",
}
for attr, token in flag_map.items():
if getattr(ns, attr, False):
tokens.append(token)
flags = [
"json",
"gpt",
"hide_wave",
"hide_uv",
"hide_height",
"hide_direction",
"hide_period",
"hide_location",
"hide_date",
"show_large_wave",
"show_past_uv",
"show_height_history",
"show_direction_history",
"show_period_history",
"show_air_temp",
"show_wind_speed",
"show_wind_direction",
"show_rain_sum",
"show_precipitation_prob",
"show_cloud_cover",
"show_visibility",
]
tokens.extend([flag for flag in flags if getattr(ns, flag, False)])
return ",".join(tokens)


Expand Down
30 changes: 21 additions & 9 deletions src/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ def print_location(city, show_city):
print("\n")


def _print_mapped_data(mappings, arguments_dict, data_dict):
"""
Helper function to print mapped data from a dictionary
if the argument is set.
"""
for arg_key, data_key, label in mappings:
if arguments_dict.get(arg_key) and data_key in data_dict:
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
print(f"{label}{data_dict[data_key]}")


def print_ocean_data(arguments_dict, ocean_data_dict):
"""
Prints ocean data (height, wave direction, period, etc).
Expand Down Expand Up @@ -242,9 +252,7 @@ def print_ocean_data(arguments_dict, ocean_data_dict):
("show_sea_temp", "Sea Surface Temperature", "Sea Surface Temp: "),
]

for arg_key, data_key, label in mappings:
if arguments_dict.get(arg_key) and data_key in ocean_data_dict:
print(f"{label}{ocean_data_dict[data_key]}")
_print_mapped_data(mappings, arguments_dict, ocean_data_dict)

if arguments_dict.get("show_tide") and ocean_data_dict.get("Tide"):
tide = ocean_data_dict["Tide"]
Expand Down Expand Up @@ -292,14 +300,18 @@ def print_forecast(ocean, forecast):
]

for day in range(ocean["forecast_days"]):
for arg_key, data_key, label in mappings:
if ocean[arg_key]:
# Extract day's data into a temporary dictionary
day_data = {}
for _, data_key, _ in mappings:
if data_key in forecast:
try:
data = forecast[data_key][day]
formatted = round(float(data), ocean["decimal"])
print(f"{label}{formatted}")
raw = forecast[data_key][day]
formatted = round(float(raw), ocean["decimal"])
except TypeError:
print(f"{label}{forecast[data_key][day]}")
formatted = forecast[data_key][day]
day_data[data_key] = formatted

_print_mapped_data(mappings, ocean, day_data)
print("\n")


Expand Down