Skip to content

Commit

Permalink
refactor: remove arrow from CA-QC
Browse files Browse the repository at this point in the history
- maintained parser functionality
  • Loading branch information
Barissa-Imran committed Nov 29, 2023
1 parent 3c9e0df commit b4a8db1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions parsers/CA_QC.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from typing import Any
from zoneinfo import ZoneInfo

# The arrow library is used to handle datetimes
import arrow
from requests import Session

from electricitymap.contrib.lib.models.event_lists import (
Expand Down Expand Up @@ -37,7 +35,9 @@ def fetch_production(
now = datetime.now(tz=TIMEZONE)
for elem in data:
values = elem["valeurs"]
timestamp = arrow.get(elem["date"], tzinfo=TIMEZONE).datetime
timestamp = datetime.strptime(elem["date"], "%Y-%m-%dT%H:%M:%S").replace(
tzinfo=TIMEZONE
)
# The datasource returns future timestamps or recent with a 0.0 value, so we ignore them.
if timestamp <= now and values.get("total", 0) > 0:
production.append(
Expand Down Expand Up @@ -71,7 +71,9 @@ def fetch_consumption(
if "demandeTotal" in elem["valeurs"]:
consumption.append(
zoneKey=zone_key,
datetime=arrow.get(elem["date"], tzinfo=TIMEZONE).datetime,
datetime=datetime.strptime(elem["date"], "%Y-%m-%dT%H:%M:%S").replace(
tzinfo=TIMEZONE
),
consumption=elem["valeurs"]["demandeTotal"],
source=SOURCE,
)
Expand Down

0 comments on commit b4a8db1

Please sign in to comment.