Ejemplo n.º 1
0
    def extract_content(self, source):
        # type: (dict) -> Any

        try:
            if self.ds_num is None:
                result = nested_lookup(source, self.data_map)
            else:
                result = nested_lookup(source["ds:{}".format(self.ds_num)],
                                       self.data_map)

            if self.post_processor is not None:
                result = self.post_processor(result)
        except:
            result = self.fallback_value

        return result
Ejemplo n.º 2
0
    def extract_content(self, source):
        # type: (dict) -> Any

        try:
            if self.ds_num is None:
                result = nested_lookup(source, self.extraction_map)
            else:
                result = nested_lookup(source["ds:{}".format(self.ds_num)],
                                       self.extraction_map)
        except (KeyError, IndexError, TypeError):
            result = self.extraction_map_except_fallback

        if result is not None and self.post_processor is not None:
            try:
                result = self.post_processor(result)
            except:
                result = self.post_processor_except_fallback

        return result
Ejemplo n.º 3
0
    def extract_content(self, source):
        # type: (dict) -> Any

        try:
            result = nested_lookup(source["ds:{}".format(self.ds_num)],
                                   self.extraction_map)
        except (IndexError, TypeError):
            result = None

        if self.post_processor is not None:
            result = self.post_processor(result)

        return result