<commit_before>from __future__ import absolute_import
# encoding: UTF-8
from django.conf import settings
from django.core.cache import caches
from urllib import urlencode
from tml.api.client import Client


class CachedClient(object):
    def __init__(self, client, backend):
        self.client = client
        self.backend = backend

    @classmethod
    def instance(cls):
        client = Client(settings.TML.get('token'))
        return cls.wrap(client)

    @classmethod
    def wrap(cls, client):
        backend_name = settings.TML.get('cache', None)
        if backend_name is None:
            return client
        return cls(client, caches[backend_name])
<commit_msg>Use python3 urlencode import<commit_after>from __future__ import absolute_import
# encoding: UTF-8
from django.conf import settings
from django.core.cache import caches
from tml.api.client import Client
try:
    from urllib import urlencode
except ImportError:
    # PY3
    from urllib.parse import urlencode

class CachedClient(object):
    def __init__(self, client, backend):
        self.client = client
        self.backend = backend

    @classmethod
    def instance(cls):
        client = Client(settings.TML.get('token'))
        return cls.wrap(client)

    @classmethod
    def wrap(cls, client):
        backend_name = settings.TML.get('cache', None)
        if backend_name is None:
            return client
        return cls(client, caches[backend_name])

{'fraction_non_alphanumeric': 0.08264462809917356, 'fraction_numerical': 0.0027548209366391185, 'mean_word_length': 3.092957746478873, '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': '4642355', 'n_tokens_mistral': 415, 'n_tokens_neox': 411, 'n_words': 121}