Exemplo n.º 1
0
 def _extract_paragraphs(
         self, configs: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
     json_path = [
         'singleVisual', 'objects', 'general', 0, 'properties', 'paragraphs'
     ]
     return [
         paragraph for config in configs
         for paragraph in dig(config, json_path)
     ]
Exemplo n.º 2
0
 def _parse_data(self, response_json: Dict[str, List]) -> Dict[str, int]:
     results = super()._parse_data(response_json)
     ethnicity_labels = dig(response_json, [*self.JSON_PATH[0:-3], 'ValueDicts', 'D0'])
     totals = {'Overall', 'Overall Known Race/Ethnicity'}
     return {
         ethnicity_label: count
         for ethnicity_label_index, count in results
         if (ethnicity_label := ethnicity_labels[ethnicity_label_index].strip()) not in totals
     }
Exemplo n.º 3
0
 def _extract_meta(self, response_json: Dict[str, Any]) -> str:
     visual_containers = dig(response_json, ['exploration', 'sections', 0, 'visualContainers'])
     text_boxes = self._extract_text_runs(visual_containers)
     return max(text_boxes, key=len)
 def _parse_data(self, response_json: Dict[str, List]) -> int: # type: ignore
     return cast(int, dig(response_json, self.JSON_PATH))
Exemplo n.º 5
0
def most_recent_case_time(data: Dict[str, Any]) -> datetime:
    most_recent_cases = cast(Dict[str, str], dig(data,
                                                 ['series', 'cases', -1]))
    return parse_datetime(most_recent_cases['date'])