[docs]classPalau(CountryTestBase):location:str="Palau"units:str="tests performed"source_label:str="Ministry of Health and Human Services"source_url:str="http://www.palauhealth.org/"source_url_ref:str=""regex:dict={"date":r"(\d{1,2} \w+ 20\d{2})","count":r"((\d+),(\d+))COVID-19 Testsconducted \(since"}
[docs]def_parse_data(self,soup:BeautifulSoup)->tuple:"""Gets pdf url"""sd=soup.find("a",id="HyperLink21")["href"]pdf_url=f"{self.source_url}/{sd}""""Parses pdf text"""withtempfile.NamedTemporaryFile()astmp:download_file_from_url(pdf_url,tmp.name)withopen(tmp.name,"rb")asf:text=extract_text(f)text=text.replace("\n","")"""Gets metrics from report text"""count,date=self._parse_metrics(text)record={"count":count,"date":date,}returnrecord,False
[docs]def_parse_metrics(self,text:str)->tuple:"""Get metrics from report text."""count=clean_count(re.search(self.regex["count"],text).group(1))date=clean_date(re.search(self.regex["date"],text).group(1),"%d %B %Y")returncount,date