<commit_before># -*- coding: utf-8 -*-
import os
import json
import logging
import binascii
import webbrowser
try:
    from urllib import urlencode
except ImportError:
    from urllib.parse import urlencode
from datetime import datetime

import tus
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

KB = 1024
MB = 1024 * KB

# Read and write operations are limited to this chunk size.
# This can make a big difference when dealing with large files.
CHUNK_SIZE = 256 * KB

BASE_URL = None
UPLOAD_URL = None
TUS_UPLOAD_URL = None
ACCESS_TOKEN_URL = None
AUTHENTICATION_URL = None
AUTHORIZATION_URL = None

logger = logging.getLogger(__name__)


def _set_domain(domain='put.io', scheme='https'):
    global BASE_URL
    global UPLOAD_URL
    global TUS_UPLOAD_URL
    global ACCESS_TOKEN_URL
    global AUTHENTICATION_URL
    global AUTHORIZATION_URL

    api_base = '{scheme}://api.{domain}/v2'.format(scheme=scheme, domain=domain)
    upload_base = '{scheme}://upload.{domain}'.format(scheme=scheme, domain=domain)

    BASE_URL = api_base
    UPLOAD_URL = upload_base + '/v2/files/upload'
    TUS_UPLOAD_URL = upload_base + '/files'
    ACCESS_TOKEN_URL = api_base + '/oauth2/access_token'
    AUTHENTICATION_URL = api_base + '/oauth2/authenticate'
    AUTHORIZATION_URL = api_base + '/oauth2/authorizations/clients/{client_id}'


_set_domain()


class APIError(Exception):
    pass


class ClientError(APIError):<commit_msg>customize APIError class<commit_after># -*- coding: utf-8 -*-
import os
import json
import logging
import binascii
import webbrowser
try:
    from urllib import urlencode
except ImportError:
    from urllib.parse import urlencode
from datetime import datetime

import tus
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry

KB = 1024
MB = 1024 * KB

# Read and write operations are limited to this chunk size.
# This can make a big difference when dealing with large files.
CHUNK_SIZE = 256 * KB

BASE_URL = None
UPLOAD_URL = None
TUS_UPLOAD_URL = None
ACCESS_TOKEN_URL = None
AUTHENTICATION_URL = None
AUTHORIZATION_URL = None

logger = logging.getLogger(__name__)


def _set_domain(domain='put.io', scheme='https'):
    global BASE_URL
    global UPLOAD_URL
    global TUS_UPLOAD_URL
    global ACCESS_TOKEN_URL
    global AUTHENTICATION_URL
    global AUTHORIZATION_URL

    api_base = '{scheme}://api.{domain}/v2'.format(scheme=scheme, domain=domain)
    upload_base = '{scheme}://upload.{domain}'.format(scheme=scheme, domain=domain)

    BASE_URL = api_base
    UPLOAD_URL = upload_base + '/v2/files/upload'
    TUS_UPLOAD_URL = upload_base + '/files'
    ACCESS_TOKEN_URL = api_base + '/oauth2/access_token'
    AUTHENTICATION_URL = api_base + '/oauth2/authenticate'
    AUTHORIZATION_URL = api_base + '/oauth2/authorizations/clients/{client_id}'


_set_domain()


class APIError(Exception):
    """
    Must be created with following arguments:
        1. Response instance (requests.Response)
        2. Type of the error (str)
        3. Extra detail about the error (str, optional)
    """

    def __str__(self):
        s = "%s, %s, %d, %s" % (
                self.response.request.method,
                self.response.request.url,
                self.response.status_code,
                self.type,
        )
        if self.message:
            s += ', %r' % self.message
        return s

    @property
    def response(self):
        return self.args[0]

    @property
    def type(self):
        return self.args[1]

    @property
    def message(self):
        if len(self.args) > 2:
            return self.args[2]


class ClientError(APIError):
{'fraction_non_alphanumeric': 0.09112903225806451, 'fraction_numerical': 0.011559139784946236, 'mean_word_length': 3.3931523022432115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1900360', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1186, 'n_words': 314}