[docs]classPhilippines(CountryTestBase):location="Philippines"source_label="Philippines Department of Health"units="people tested"_base_url="https://drive.google.com/drive/folders/1ZPPcVU4M7T-dtRyUceb0pMAd8ickYf8o"rename_columns={"report_date":"Date","cumulative_unique_individuals":"Cumulative total",}
[docs]def_get_id_folder(self):withtempfile.TemporaryDirectory()astmp:# Download filedownload_folder(self._base_url,output=tmp)# Get downloaded relevant file pathf=[fforfinos.listdir(tmp)if"READ ME FIRST"inf][0]pdf_path=os.path.join(tmp,f)# Get id of relevant folderreturnself._parse_drive_id_from_pdf(pdf_path)
[docs]def_parse_drive_id_from_pdf(self,pdf_path):# Get link from pdfwithopen(pdf_path,"rb")asf:text=extract_text(f)link=re.search(r"https://bit\.ly/.*",text).group()# Unshortenresp=requests.get(link)link=resp.url# Get idreturnlink.split("/")[-1].split("?")[-2]
[docs]defpipe_checks(self,df:pd.DataFrame):n=20ifdf.Date.isna().any():raiseValueError("Some `Date` have NaN values!")ifnot(df.Date.max()>localdatenow(minus_days=n)):raiseValueError(f"Data has not been updated for more than {n} days! Check source.")returndf