<commit_before>import copy
import sys

if sys.version_info.major < 3:
    from httplib import responses
    from urlparse import urlsplit
else:
    from http.client import responses
    from urllib.parse import urlsplit

import requests

from .zdesk_api import ZendeskAPI


def get_id_from_url(url):
    url_id = urlsplit(url).path.split('/')[-1].split('.')[0]
    if url_id.isdigit():
        return url_id
    else:
        return None


class ZendeskError(Exception):
    def __init__(self, msg, code, response):
        self.msg = msg
        self.error_code = code
        self.response = response

    def __str__(self):
        return repr('%s: %s %s' % (self.error_code, self.msg, self.response))


class AuthenticationError(ZendeskError):
    pass


class RateLimitError(ZendeskError):
    pass


class Zendesk(ZendeskAPI):
    """ Python API Wrapper for Zendesk"""

    def __init__(self, zdesk_url, zdesk_email=None, zdesk_password=<PASSWORD>,
                 zdesk_token=False, headers=None, client_args=None,
                 api_version=2):
        """
        Instantiates an instance of Zendesk. Takes optional parameters for
        HTTP Basic Authentication

        Parameters:
        zdesk_url - https://company.zendesk.com (use http if not SSL enabled)
        zdesk_email - Specific to your Zendesk account (typically email)
        zdesk_password - Specific to your Zendesk account or your account's
            API token if zdesk_token is True
        zdesk_token - use api token for authentication instead of user's
            actual password
        headers - Pass headers in dict form. This will override default.
        client_args - Pass arguments to http client in dict form.
            {'cache': False, 'timeout': 2}
            or a common one is to disable SSL certficate validation
            {"disable_ssl_certificate_validation": True}
        """
        # Set attributes necessary for API
        self._zdesk_url = None
        self._zdesk_email = None
        self._zdesk_password = <PASSWORD>
        self._zdesk_token = False

        self.client = requests.Session()

        self.zdesk_url = zdesk_url.rstrip('/')
        self.zdesk_email = zdesk_email
        self.zdesk_password = <PASSWORD>
        self.zdesk_token = zdesk_token

        # Set headers
        self.client_args = copy.deepcopy(client_args) or {}
        self.headers = copy.deepcopy(headers) or {}

        if api_version != 2:
            raise ValueError("Unsupported Zendesk API Version: %d" %
                             api_version)

    def _update_auth(self):
        if self.zdesk_email and self.zdesk_password:
            self.client.auth = (self.zdesk_email, self.zdesk_password)
        else:
            self.client.auth = None

    @property
    def zdesk_url(self):<commit_msg>update examples left over from httplib<commit_after>import copy
import sys

if sys.version_info.major < 3:
    from httplib import responses
    from urlparse import urlsplit
else:
    from http.client import responses
    from urllib.parse import urlsplit

import requests

from .zdesk_api import ZendeskAPI


def get_id_from_url(url):
    url_id = urlsplit(url).path.split('/')[-1].split('.')[0]
    if url_id.isdigit():
        return url_id
    else:
        return None


class ZendeskError(Exception):
    def __init__(self, msg, code, response):
        self.msg = msg
        self.error_code = code
        self.response = response

    def __str__(self):
        return repr('%s: %s %s' % (self.error_code, self.msg, self.response))


class AuthenticationError(ZendeskError):
    pass


class RateLimitError(ZendeskError):
    pass


class Zendesk(ZendeskAPI):
    """ Python API Wrapper for Zendesk"""

    def __init__(self, zdesk_url, zdesk_email=None, zdesk_password=<PASSWORD>,
                 zdesk_token=False, headers=None, client_args=None,
                 api_version=2):
        """
        Instantiates an instance of Zendesk. Takes optional parameters for
        HTTP Basic Authentication

        Parameters:
        zdesk_url - https://company.zendesk.com (use http if not SSL enabled)
        zdesk_email - Specific to your Zendesk account (typically email)
        zdesk_password - Specific to your Zendesk account or your account's
            API token if zdesk_token is True
        zdesk_token - use api token for authentication instead of user's
            actual password
        headers - Pass headers in dict form. This will override default.
        client_args - Pass arguments to http client in dict form.
            {'allow_redirects': False, 'timeout': 2}
            or a common one is to disable SSL certficate validation
            {'verify': True}
        """
        # Set attributes necessary for API
        self._zdesk_url = None
        self._zdesk_email = None
        self._zdesk_password = None
        self._zdesk_token = False

        self.client = requests.Session()

        self.zdesk_url = zdesk_url.rstrip('/')
        self.zdesk_email = zdesk_email
        self.zdesk_password = <PASSWORD>
        self.zdesk_token = zdesk_token

        # Set headers
        self.client_args = copy.deepcopy(client_args) or {}
        self.headers = copy.deepcopy(headers) or {}

        if api_version != 2:
            raise ValueError("Unsupported Zendesk API Version: %d" %
                             api_version)

    def _update_auth(self):
        if self.zdesk_email and self.zdesk_password:
            self.client.auth = (self.zdesk_email, self.zdesk_password)
        else:
            self.client.auth = None

    @property
    def zdesk_url(self):
{'fraction_non_alphanumeric': 0.08071111111111111, 'fraction_numerical': 0.0021333333333333334, 'mean_word_length': 2.3810096153846154, 'pattern_counts': {'":': 1, '<': 10, '<?xml version=': 0, '>': 8, 'https://': 2, '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': '5236971', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1644, 'n_words': 466}