<commit_before>#!/usr/bin/env python

"""
Client abstract class
"""

__author__ = '<NAME> (<EMAIL>)'

from abc import ABCMeta, abstractmethod


class AbstractClient(object):
    __metaclass__ = ABCMeta

    @abstractmethod
    def __init__(self, auth, http_session=None):
        """ Store the object containing the information needed for
        the authentication """
        pass

        """# Need to find a smart method to check if auth is a list or an object
        if len(auth) < 2:
            print "/'auth/' object must contain at least 2 values"

        self.auth = auth
        self.session = http_session
        if self.auth[0]:
            print "user name set as {0}".format(self.auth[0])
        if self.auth[1]:
            print "password set as ************".format(self.auth[1])

        if len(self.auth) > 2:
            if self.auth[2]:
                print "cert file set as {0}".format(self.auth[2])
            if self.auth[3]:
                print "key file set as {0}".format(self.auth[3])
                """

    @abstractmethod
    def login(self):
        pass

    @abstractmethod
    def put(self):
        pass

    @abstractmethod
    def get(self):
        pass<commit_msg>Implemented find datasets by metadata<commit_after>#!/usr/bin/env python

"""
Client abstract class
"""

__author__ = '<NAME> (<EMAIL>)'

from abc import ABCMeta, abstractmethod
import find.getdatasetinfo as datasetinfo


class AbstractClient(object):
    __metaclass__ = ABCMeta

    @abstractmethod
    def __init__(self, auth, http_session=None):
        """ Store the object containing the information needed for
        the authentication """
        pass

    @abstractmethod
    def login(self):
        pass

    @abstractmethod
    def put(self):
        pass

    @abstractmethod
    def get(self):
        pass

    def find_by_metadata(self, ckan_url='eudat-b1.dkrz.de', community='',
                         pattern=[], ckan_limit=1000):
        """
        Retrieve datasets information by given search criteria.
        Returns a list of datasets (each dataset is a list of dictionary
        composed by key and value).

        ckan_url : string
            CKAN portal address, to which search requests are submitted
            (default is eudat-b1.dkrz.de).
        community : string
            Community where you want to search in.
        pattern : list
            CKAN search pattern, i.e. (a list of) field:value terms.
        ckan_limit : int
            Limit of listed datasets (default is 1000).
        """
        results = datasetinfo.get_dataset_info(ckan_url=ckan_url,
                                               community=community,
                                               pattern=pattern,
                                               ckan_limit=ckan_limit)
        return results
{'fraction_non_alphanumeric': 0.0920266947664208, 'fraction_numerical': 0.008429926238145416, 'mean_word_length': 1.9061224489795918, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4787561', 'n_tokens_mistral': 778, 'n_tokens_neox': 742, 'n_words': 243}