Ejemplo n.º 1
0
    def get_info_by_metadata(self, ckan_url='eudat-b1.dkrz.de', community='',
                         pattern=[], ckan_limit=1000):
        """
        Retrieve dataset info by given search criteria using CKAN portal.

        :param ckan_url: CKAN portal address, to which search requests are
        submitted (default is eudat-b1.dkrz.de).
        :param community: Community where you want to search in.
        :param pattern: CKAN search pattern i.e. (a list of) field:value terms.
        :param ckan_limit: Limit of listed datasets (default is 1000).
        :return: list of datasets (each dataset is a list of dictionary
        composed by key and value) considering only the datasets containing
        a pid value.
        """
        results = datasetinfo.get_dataset_info(ckan_url=ckan_url,
                                               community=community,
                                               pattern=pattern,
                                               ckan_limit=ckan_limit)
        return results
Ejemplo n.º 2
0
    def get_pid_by_metadata(self, ckan_url='eudat-b1.dkrz.de', community='',
                         pattern=[], ckan_limit=1000):
        """
        Retrieve dataset PIDs by given search criteria using CKAN portal.

        :param ckan_url: CKAN portal address, to which search requests are
        submitted (default is eudat-b1.dkrz.de).
        :param community: Community where you want to search in.
        :param pattern: CKAN search pattern i.e. (a list of) field:value terms.
        :param ckan_limit: Limit of listed datasets (default is 1000).
        :return: list of PIDs (with handle URL).
        """
        results = datasetinfo.get_dataset_info(ckan_url=ckan_url,
                                               community=community,
                                               pattern=pattern,
                                               ckan_limit=ckan_limit)
        pid_list = []
        for ds in results:
            for extra in ds:
                if extra['key'] == 'PID':
                    pid_list.append(extra['value'])

        return pid_list