Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Giga77 committed Jan 21, 2025
1 parent 8b99864 commit 1940121
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions custom_components/ecole_directe/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
logger=_LOGGER,
name=entry.title,
update_interval=timedelta(
minutes=entry.options.get("refresh_interval", DEFAULT_REFRESH_INTERVAL)
minutes=entry.options.get(
"refresh_interval", DEFAULT_REFRESH_INTERVAL)
),
)
self.config_entry = entry
Expand Down Expand Up @@ -151,7 +152,8 @@ async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
self.config_entry.options.get("decode_html", False),
)

self.data[f"{eleve.get_fullname_lower()}_homework"] = homeworks
self.data[f"{
eleve.get_fullname_lower()}_homework"] = homeworks

self.compare_data(
previous_data,
Expand Down Expand Up @@ -205,14 +207,18 @@ async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
eleve,
year_data,
self.hass.config.config_dir,
self.config_entry.options.get("notes_affichees", GRADES_TO_DISPLAY)
self.config_entry.options.get(
"notes_affichees", GRADES_TO_DISPLAY)
)
disciplines = grades_evaluations["disciplines"]
self.data[f"{eleve.get_fullname_lower()}_disciplines"] = disciplines
self.data[f"{
eleve.get_fullname_lower()}_disciplines"] = disciplines
for discipline in disciplines:
self.data[f"{eleve.get_fullname_lower()}_{discipline["name"]}"] = discipline
self.data[f"{eleve.get_fullname_lower()}_{
discipline["name"]}"] = discipline

self.data[f"{eleve.get_fullname_lower()}_moyenne_generale"] = grades_evaluations["moyenne_generale"]
self.data[f"{eleve.get_fullname_lower(
)}_moyenne_generale"] = grades_evaluations["moyenne_generale"]

self.data[f"{eleve.get_fullname_lower()}_grades"] = (
grades_evaluations["grades"]
Expand All @@ -236,7 +242,8 @@ async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
eleve,
)
except Exception as ex:
_LOGGER.warning("Error getting grades from ecole directe: %s", ex)
_LOGGER.warning(
"Error getting grades from ecole directe: %s", ex)

if DEBUG_ON or "EDT" in eleve.modules:
try:
Expand Down Expand Up @@ -281,15 +288,17 @@ async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
)
self.data[f"{eleve.get_fullname_lower()}_timetable_period"] = list(
filter(
lambda lesson: lesson["start"].date() >= current_week_begin
lambda lesson: lesson["start"].date(
) >= current_week_begin
and lesson["start"].date() <= current_week_end,
lessons,
)
)
self.data[f"{eleve.get_fullname_lower()}_timetable_period_1"] = (
list(
filter(
lambda lesson: lesson["start"].date() >= next_week_begin
lambda lesson: lesson["start"].date(
) >= next_week_begin
and lesson["start"].date() <= next_week_end,
lessons,
)
Expand All @@ -306,7 +315,8 @@ async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
)

except Exception as ex:
_LOGGER.warning("Error getting Lessons from ecole directe: %s", ex)
_LOGGER.warning(
"Error getting Lessons from ecole directe: %s", ex)

if DEBUG_ON or "VIE_SCOLAIRE" in eleve.modules:
try:
Expand Down Expand Up @@ -378,7 +388,8 @@ async def _async_update_data(self) -> dict[Platform, dict[str, Any]]:
self.hass.config.config_dir,
)
except Exception as ex:
_LOGGER.warning("Error getting messages from ecole directe: %s", ex)
_LOGGER.warning(
"Error getting messages from ecole directe: %s", ex)

return self.data

Expand Down

0 comments on commit 1940121

Please sign in to comment.