Skip to content

Commit

Permalink
Fixes some bugs with toml
Browse files Browse the repository at this point in the history
  • Loading branch information
dulte committed Sep 5, 2024
1 parent 535a361 commit 7c3df6d
Showing 1 changed file with 26 additions and 29 deletions.
55 changes: 26 additions & 29 deletions src/pyaro_readers/eeareader/eeadownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path


from tomli import tomllib
import tomli as tomllib


from tqdm import tqdm
Expand All @@ -32,7 +32,6 @@ class EEADownloader:
METADATFILE = Path(__file__).parent / "metadata.csv"
DATAFILE = Path(__file__).parent / "data.toml"


request_body = dict(contries=[], cities=[], properties=[], datasets=[], source="")

def __init__(
Expand Down Expand Up @@ -108,21 +107,19 @@ def get_station_metadata(self) -> dict:
return metadata

def get_pollutants(self) -> dict:
with open(self.DATAFILE, "r") as f:
poll = tomlib.load(f)["pollutant"]
with open(self.DATAFILE, "rb") as f:
poll = tomllib.load(f)["pollutant"]
return poll

def get_default_pollutants(self) -> list[str]:
with open(self.DATAFILE, "r") as f:
poll = tomlib.load(f)["defaults"]["pollutants"]
with open(self.DATAFILE, "rb") as f:
poll = tomllib.load(f)["defaults"]["pollutants"]
return poll

def make_pollutant_url_list(self, pollutants: list[str]) -> list[str]:
urls = []
with open(
self.DATAFILE
) as f:
poll = tomlib.load(f)["pollutant"]
with open(self.DATAFILE, "rb") as f:
poll = tomllib.load(f)["pollutant"]
for key in poll:
if poll[key] in pollutants:
urls.append(self.URL_POLLUTANT + key)
Expand Down Expand Up @@ -258,21 +255,21 @@ def postprocess(


if __name__ == "__main__":



# eead = EEADownloader()
# # eead.download_default(
# # Path(
# # "/home/danielh/Documents/pyaerocom/pyaro-readers/src/pyaro_readers/eeareader/data"
# # )
# # )

# eead.postprocess_all_files(
# Path(
# "/home/danielh/Documents/pyaerocom/pyaro-readers/src/pyaro_readers/eeareader/data"
# ),
# Path(
# "/home/danielh/Documents/pyaerocom/pyaro-readers/src/pyaro_readers/eeareader/renamed"
# ),
# )
app()


# eead = EEADownloader()
# # eead.download_default(
# # Path(
# # "/home/danielh/Documents/pyaerocom/pyaro-readers/src/pyaro_readers/eeareader/data"
# # )
# # )

# eead.postprocess_all_files(
# Path(
# "/home/danielh/Documents/pyaerocom/pyaro-readers/src/pyaro_readers/eeareader/data"
# ),
# Path(
# "/home/danielh/Documents/pyaerocom/pyaro-readers/src/pyaro_readers/eeareader/renamed"
# ),
# )

0 comments on commit 7c3df6d

Please sign in to comment.