Exemplo n.º 1
0
    def test_conversion_from_dict(self):
        arcgis_parser = ArcGISParser(self.arcgis_metadata)
        fgdc_parser = FgdcParser(self.fgdc_metadata)
        iso_parser = IsoParser(self.iso_metadata)

        self.assert_parser_conversion(
            arcgis_parser, get_metadata_parser(element_to_dict(fgdc_parser._xml_tree, recurse=True)), "dict-based"
        )
        self.assert_parser_conversion(
            arcgis_parser, get_metadata_parser(element_to_dict(iso_parser._xml_tree, recurse=True)), "dict-based"
        )

        self.assert_parser_conversion(
            fgdc_parser, get_metadata_parser(element_to_dict(arcgis_parser._xml_tree, recurse=True)), "dict-based"
        )
        self.assert_parser_conversion(
            fgdc_parser, get_metadata_parser(element_to_dict(iso_parser._xml_tree, recurse=True)), "dict-based"
        )

        self.assert_parser_conversion(
            iso_parser, get_metadata_parser(element_to_dict(arcgis_parser._xml_tree, recurse=True)), "dict-based"
        )
        self.assert_parser_conversion(
            iso_parser, get_metadata_parser(element_to_dict(fgdc_parser._xml_tree, recurse=True)), "dict-based"
        )
    def _parse_report_item(self, prop):
        """ :return: the text for each element at the configured path if type attribute matches"""

        item_type = None

        if prop == 'attribute_accuracy':
            item_type = 'DQQuanAttAcc'
        elif prop == 'dataset_completeness':
            item_type = 'DQCompOm'

        xroot = self._get_xroot_for(prop)

        parsed = (element_to_dict(e) for e in get_elements(self._xml_tree, xroot))
        parsed = flatten_items(e['children'] for e in parsed if e['attributes'].get('type') == item_type)

        return reduce_value([p['text'] for p in parsed if p['name'] == 'measDesc'])
    def _parse_report_item(self, prop):
        """ :return: the text for each element at the configured path if type attribute matches"""

        item_type = None

        if prop == 'attribute_accuracy':
            item_type = 'DQQuanAttAcc'
        elif prop == 'dataset_completeness':
            item_type = 'DQCompOm'

        xroot = self._get_xroot_for(prop)

        parsed = (element_to_dict(e) for e in get_elements(self._xml_tree, xroot))
        parsed = flatten_items(e['children'] for e in parsed if e['attributes'].get('type') == item_type)

        return reduce_value([p['text'] for p in parsed if p['name'] == 'measDesc'])