<commit_before>from __future__ import unicode_literals

import requests
import time


class TembaException(Exception):
    def __init__(self, msg, caused_by=None):
        self.msg = msg
        self.caused_by = caused_by

    def __unicode__(self):
        text = self.msg
        if self.caused_by:
            text += "\ncaused by:\n%s" % self.caused_by
        return text


class TembaClient(object):
    """
    Client for the Temba API
    """
    def __init__(self, host, token, ssl=True):
        if host.startswith('http'):
            self.root_url = host
        else:
            self.root_url = '%s://%s/api/v1' % ('https' if ssl else 'http', host)

        self.token = token

    def create_contact(self, name, urns, fields, group_uuids):
        payload = dict(name=name, urns=urns, fields=fields, group_uuids=group_uuids)
        return self._create_single('contacts', payload)

    def get_contact(self, uuid):
        return self._get_single('contacts', uuid=uuid)

    def get_contacts(self, name=None, group_uuids=None):
        params = {}
        if name is not None:
            params['name'] = name
        if group_uuids is not None:
            params['group_uuids'] = group_uuids

        return self._get_single('contacts', **params)

    def get_flow(self, uuid):
        return self._get_single('flows', uuid=uuid)<commit_msg>Fixed get_contacts<commit_after>from __future__ import unicode_literals

import requests
import time


class TembaException(Exception):
    def __init__(self, msg, caused_by=None):
        self.msg = msg
        self.caused_by = caused_by

    def __unicode__(self):
        text = self.msg
        if self.caused_by:
            text += "\ncaused by:\n%s" % self.caused_by
        return text


class TembaClient(object):
    """
    Client for the Temba API
    """
    def __init__(self, host, token, ssl=True):
        if host.startswith('http'):
            self.root_url = host
        else:
            self.root_url = '%s://%s/api/v1' % ('https' if ssl else 'http', host)

        self.token = token

    def create_contact(self, name, urns, fields, group_uuids):
        payload = dict(name=name, urns=urns, fields=fields, group_uuids=group_uuids)
        return self._create_single('contacts', payload)

    def get_contact(self, uuid):
        return self._get_single('contacts', uuid=uuid)

    def get_contacts(self, name=None, group_uuids=None):
        params = {}
        if name is not None:
            params['name'] = name
        if group_uuids is not None:
            params['group_uuids'] = group_uuids

        return self._get_all('contacts', **params)

    def get_flow(self, uuid):
        return self._get_single('flows', uuid=uuid)
{'fraction_non_alphanumeric': 0.11323529411764706, 'fraction_numerical': 0.0007352941176470588, 'mean_word_length': 2.580263157894737, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6155085', 'n_tokens_mistral': 881, 'n_tokens_neox': 851, 'n_words': 210}