<commit_before>#!/usr/bin/env python
import functools
import requests
import requests_oauthlib


class Client(object):

    def __init__(self, host, consumer_key, consumer_secret,
                       oauth_token, oauth_secret, scheme="https"):
        self.auth = requests_oauthlib.OAuth1(
                            consumer_key,
                            consumer_secret,
                            oauth_token,
                            oauth_secret)
        self.session = requests.Session()
        self.host = host
        self.scheme = scheme

    def url(self, endpoint):
        if not endpoint.startswith("/"):
            endpoint = "/" + endpoint
        return "{0}://{1}{2}".format(self.scheme, self.host, endpoint)

    def __getattr__(self, attr):
        if attr in ("get", "post", "put", "delete", "patch", "head"):
            return functools.partial(self.request, attr)

        raise AttributeError(attr)

    def request(self, method, endpoint, **kwargs):
        if "auth" in kwargs:
            raise ValueError("request() called with auth")
        kwargs['auth'] = self.auth
        return self.request_full_url(method, self.url(endpoint), **kwargs)

    def request_full_url(self, method, url, **kwargs):
        response = self.session.request(method, url, **kwargs)
        response.raise_for_status()
        return response

<commit_msg>Added support for configure debugging level of httplib<commit_after>#!/usr/bin/env python
import httplib
import functools
import requests
import requests_oauthlib


class Client(object):

    def __init__(self, host, consumer_key, consumer_secret,
                 oauth_token, oauth_secret, scheme="https",
                 http_debug_level=None):
        self.auth = requests_oauthlib.OAuth1(
                            consumer_key,
                            consumer_secret,
                            oauth_token,
                            oauth_secret)
        self.session = requests.Session()
        self.host = host
        self.scheme = scheme
        self.http_debug_level = http_debug_level

    @property
    def http_debug_level(self):
        return httplib.HTTPConnection.debuglevel

    @http_debug_level.setter
    def http_debug_level(self, value):
        if not value:
            value = 0
        httplib.HTTPConnection.debuglevel = int(value)

    def url(self, endpoint):
        if not endpoint.startswith("/"):
            endpoint = "/" + endpoint
        return "{0}://{1}{2}".format(self.scheme, self.host, endpoint)

    def __getattr__(self, attr):
        if attr in ("get", "post", "put", "delete", "patch", "head"):
            return functools.partial(self.request, attr)

        raise AttributeError(attr)

    def request(self, method, endpoint, **kwargs):
        if "auth" in kwargs:
            raise ValueError("request() called with auth")
        kwargs['auth'] = self.auth
        return self.request_full_url(method, self.url(endpoint), **kwargs)

    def request_full_url(self, method, url, **kwargs):
        response = self.session.request(method, url, **kwargs)
        response.raise_for_status()
        return response


{'fraction_non_alphanumeric': 0.10731244064577398, 'fraction_numerical': 0.002849002849002849, 'mean_word_length': 2.2081218274111674, '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': '724960', 'n_tokens_mistral': 877, 'n_tokens_neox': 863, 'n_words': 210}