<commit_before>__author__ = "<NAME>"
__version__ = "0.1"

RESPONSE_CODES = {
        200: "OK: Success",
        202: "Accepted: The request was accepted and the user was queued for processing",
        401: "Not Authorized: either you need to provide authentication credentials, or the credentials provided aren't valid.",
        403: "Bad Request: Your request is invalid and we'll return and error message that tells you why. This is the status code if you have exceeded the rate limit.",
        404: "Not Found: either you are requesting an invalid URI or the resource in question doesn't exist.",
        500: "Internal Server Error: we did something wrong.",
        502: "Bad Gateway: returned if Klout is down or being upgraded.",
        503: "Service Unavailable: the Klout servers are up, but are overloaded with requests. Try again later."
}
class KloutError( Exception ):
    def __init__(self, code=0, msg=''):
        super(KloutError, self).__init__()
        self.code = code
        self.msg = msg
    def __str__(self):
        return repr(self)
    def __repr__(self):
        return "%i: %s" % (self.code, self.msg)
 
class Klout( object ):
    def __init__(self, key, serviceType="service"):
        self._apiKey = key
        self.__service = self.__getProxyFactory(serviceType)

    def __getProxyFactory(self, serviceType):
        service = None
        if serviceType == "test":
            service = TestKloutService(serviceType)
        else:
            service = KloutService(self._apiKey)
        self.__service = service
        return self.__service
        
    def score(self, users):
        """
            Retrieve a Klout score
            @param: users - List of usernames
            @return: A list of tuples in the form (username, klout_score)
        """
        if not users:
            raise Exception("Input is empty")
        if not isinstance(users, (list, tuple)):
            raise Exception("Not Implemented Yet")
        users = ",".join(users)
        query = {"users": users}
        result = self.__service.makeCall("score", query)
        
        return result
    def show(self, users):
        """
            Retrieve a user object
            @param: users - List of usernames
            @return: A dictionary with the returned data
        """
        if not users:
            raise Exception("Input is empty")
        if not isinstance(users, (list, tuple)):
            raise Exception("Not Implemented Yet")
        users = ",".join(users)
        query = {"users":users}
        result = self.__service.makeCall("user", query)
        return result
    def topics(self, users):
        """
            Returns the top 3 topics objects
            @param: users - A list of usernames<commit_msg>Refactoring score method<commit_after>__author__ = "<NAME>"
__version__ = "0.1"

RESPONSE_CODES = {
        200: "OK: Success",
        202: "Accepted: The request was accepted and the user was queued for processing",
        401: "Not Authorized: either you need to provide authentication credentials, or the credentials provided aren't valid.",
        403: "Bad Request: Your request is invalid and we'll return and error message that tells you why. This is the status code if you have exceeded the rate limit.",
        404: "Not Found: either you are requesting an invalid URI or the resource in question doesn't exist.",
        500: "Internal Server Error: we did something wrong.",
        502: "Bad Gateway: returned if Klout is down or being upgraded.",
        503: "Service Unavailable: the Klout servers are up, but are overloaded with requests. Try again later."
}
class KloutError( Exception ):
    def __init__(self, code=0, msg=''):
        super(KloutError, self).__init__()
        self.code = code
        self.msg = msg
    def __str__(self):
        return repr(self)
    def __repr__(self):
        return "%i: %s" % (self.code, self.msg)
 
class Klout( object ):
    def __init__(self, key, serviceType="service"):
        self._apiKey = key
        self.__service = self.__getProxyFactory(serviceType)

    def __getProxyFactory(self, serviceType):
        service = None
        if serviceType == "test":
            service = TestKloutService(serviceType)
        else:
            service = KloutService(self._apiKey)
        self.__service = service
        return self.__service
        
    def score(self, users):
        """
            Retrieve a Klout score
            @param: users - List of usernames
            @return: A list of tuples in the form (username, klout_score)
        """
        if not users:
            raise KloutError(0, "No Users")
        if not isinstance(users, (list, tuple)):
            raise KloutError(0, "Wrong input.")
        users = ",".join(users)
        query = {"users": users}
        result = self.__service.makeCall("score", query)
        
        return result
    def show(self, users):
        """
            Retrieve a user object
            @param: users - List of usernames
            @return: A dictionary with the returned data
        """
        if not users:
            raise Exception("Input is empty")
        if not isinstance(users, (list, tuple)):
            raise Exception("Not Implemented Yet")
        users = ",".join(users)
        query = {"users":users}
        result = self.__service.makeCall("user", query)
        return result
    def topics(self, users):
        """
            Returns the top 3 topics objects
            @param: users - A list of usernames
{'fraction_non_alphanumeric': 0.09584837545126354, 'fraction_numerical': 0.010469314079422382, 'mean_word_length': 2.2365654205607477, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2704199', 'n_tokens_mistral': 1489, 'n_tokens_neox': 1440, 'n_words': 555}