harvester_odt/pat_statistica/client.py
def _add_extended_metadata(self, dataset):
        """Download extended metadata for this dataset
        """

        # Download linked resources, to extract metadata
        # ------------------------------------------------------------

        dataset['_links'] = {}
        dataset_data = {}

        keys = [
            ('Indicatore', 'indicatore'),
            ('TabNumeratore', 'numeratore'),
            ('TabDenominatore', 'denominatore'),
        ]

        for orig, key in keys:
            if orig in dataset:
                url = dataset[orig]
                dataset['_links'][key] = url
                dataset_data[key] = requests.get(url).json()

        def _extract_title(json_data):
            assert isinstance(json_data, dict)
            assert len(json_data) == 1
            return json_data.keys()[0]

        # Add resource titles, now that we have them
        # ------------------------------------------------------------

        dataset['title'] = _extract_title(dataset_data['indicatore'])
        dataset['name'] = slugify(dataset['title'])

        for key in ('numeratore', 'denominatore'):
            if key in dataset_data:
                title = _extract_title(dataset_data[key])
                dataset[key + '_title'] = title
                dataset[key + '_name'] = slugify(title)

        return dataset
Download extended metadata for this dataset
        
Download extended metadata for this dataset
Download extended metadata for this dataset
def _add_extended_metadata(self, dataset):
        dataset['_links'] = {}
        dataset_data = {}
        keys = [
            ('Indicatore', 'indicatore'),
            ('TabNumeratore', 'numeratore'),
            ('TabDenominatore', 'denominatore'),
        ]
        for orig, key in keys:
            if orig in dataset:
                url = dataset[orig]
                dataset['_links'][key] = url
                dataset_data[key] = requests.get(url).json()
        def _extract_title(json_data):
            assert isinstance(json_data, dict)
            assert len(json_data) == 1
            return json_data.keys()[0]
        dataset['title'] = _extract_title(dataset_data['indicatore'])
        dataset['name'] = slugify(dataset['title'])
        for key in ('numeratore', 'denominatore'):
            if key in dataset_data:
                title = _extract_title(dataset_data[key])
                dataset[key + '_title'] = title
                dataset[key + '_name'] = slugify(title)
        return dataset
def _add_extended_metadata ( self , dataset ) : dataset [ '_links' ] = { } dataset_data = { } keys = [ ( 'Indicatore' , 'indicatore' ) , ( 'TabNumeratore' , 'numeratore' ) , ( 'TabDenominatore' , 'denominatore' ) , ] for orig , key in keys : if orig in dataset : url = dataset [ orig ] dataset [ '_links' ] [ key ] = url dataset_data [ key ] = requests . get ( url ) . json ( ) def _extract_title ( json_data ) : assert isinstance ( json_data , dict ) assert len ( json_data ) == 1 return json_data . keys ( ) [ 0 ] dataset [ 'title' ] = _extract_title ( dataset_data [ 'indicatore' ] ) dataset [ 'name' ] = slugify ( dataset [ 'title' ] ) for key in ( 'numeratore' , 'denominatore' ) : if key in dataset_data : title = _extract_title ( dataset_data [ key ] ) dataset [ key + '_title' ] = title dataset [ key + '_name' ] = slugify ( title ) return dataset
Download extended metadata for this dataset
Download extended metadata for this dataset
"""Download extended metadata for this dataset
        """ # Download linked resources, to extract metadata # ------------------------------------------------------------ # Add resource titles, now that we have them # ------------------------------------------------------------
self
dataset