Skip to content

Commit

Permalink
Merge pull request #48 from J-Dudek/main
Browse files Browse the repository at this point in the history
Fix: add return not null on inexist field
  • Loading branch information
Giga77 authored Nov 22, 2024
2 parents 7927520 + 08419b2 commit 2c5d64e
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions custom_components/ecole_directe/ecole_directe_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,23 +504,34 @@ def get_grades_evaluations(token, eleve, annee_scolaire, config_path):
if "periodes" in data:
data["periodes"].sort(key=operator.itemgetter("dateDebut"))
for periode_json in data["periodes"]:
if datetime.now() < datetime.strptime(periode_json["dateDebut"], "%Y-%m-%d"):
if datetime.now() < datetime.strptime(
periode_json["dateDebut"], "%Y-%m-%d"
):
continue
if datetime.now() > datetime.strptime(periode_json["dateFin"], "%Y-%m-%d"):
continue
response["disciplines"] = get_disciplines_periode(periode_json)
if periode_json["ensembleMatieres"]:
response["moyenne_generale"] = {
"moyenneGenerale":periode_json["ensembleMatieres"]["moyenneGenerale"],
"moyenneClasse":periode_json["ensembleMatieres"]["moyenneClasse"],
"moyenneMin":periode_json["ensembleMatieres"]["moyenneMin"],
"moyenneMax":periode_json["ensembleMatieres"]["moyenneMax"],
"dateCalcul":periode_json["ensembleMatieres"]["dateCalcul"],
}
"moyenneGenerale": periode_json.get(
["ensembleMatieres"]["moyenneGenerale"], ""
),
"moyenneClasse": periode_json.get(
["ensembleMatieres"]["moyenneClasse"], ""
),
"moyenneMin": periode_json.get(
["ensembleMatieres"]["moyenneMin"], ""
),
"moyenneMax": periode_json.get(
["ensembleMatieres"]["moyenneMax"], ""
),
"dateCalcul": periode_json.get(
["ensembleMatieres"]["dateCalcul"], ""
),
}

break


if "notes" in data:
data["notes"].sort(key=operator.itemgetter("date"))
data["notes"].reverse()
Expand Down Expand Up @@ -567,6 +578,7 @@ def get_grade(data):
"elements_programme": elements_programme,
}


def get_disciplines_periode(data):
"""get periode information"""

Expand All @@ -589,6 +601,7 @@ def get_disciplines_periode(data):
_LOGGER.warning("get_periode: %s", ex)
raise


def get_evaluation(data):
"""get evaluation information"""

Expand Down

0 comments on commit 2c5d64e

Please sign in to comment.