Skip to content

Commit

Permalink
Adds copy of the metadata file to the downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
dulte committed Sep 5, 2024
1 parent b300f76 commit 9a86b94
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/pyaro_readers/eeareader/eeadownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


from tqdm import tqdm
import shutil


app = typer.Typer()
Expand Down Expand Up @@ -80,6 +81,9 @@ def _make_request(self, request: dict):
else:
raise results.raise_for_status()

def _copy_metadata_to_folder(self, to_folder: Path) -> None:
shutil.copyfile(self.METADATFILE, to_folder / "metadata.csv")

def get_countries(self):
country_file = requests.get(self.BASE_URL + "Country").json()
return [country["countryCode"] for country in country_file]
Expand Down Expand Up @@ -134,6 +138,7 @@ def download_default(
if not save_loc.is_dir():
save_loc.mkdir(parents=True, exist_ok=True)

self._copy_metadata_to_folder(save_loc)
countries = self.get_countries()

errorfile = open("errors.txt", "w")
Expand Down Expand Up @@ -194,6 +199,8 @@ def postprocess_all_files(self, from_folder: Path, to_folder: Path) -> None:
polls = [str(x).split("/")[-1] for x in from_folder.iterdir() if x.is_dir()]
if not to_folder.is_dir():
to_folder.mkdir(parents=True, exist_ok=True)

self._copy_metadata_to_folder(to_folder)
conversion_error = open(to_folder / "errors.txt", "w")
error_n = 0
for poll in tqdm(polls, desc="Pollutant", disable=None):
Expand Down Expand Up @@ -231,7 +238,10 @@ def postprocess_all_files(self, from_folder: Path, to_folder: Path) -> None:
)
def download(
save_loc: Annotated[
Path, typer.Argument(help="Location where the data will be downloaded to")
Path,
typer.Argument(
help="Location where the data will be downloaded to. Deprecated!: The reader can now use the downloaded data directly"
),
]
):
eead = EEADownloader()
Expand Down

0 comments on commit 9a86b94

Please sign in to comment.