<commit_before>import requests
# from IPython import embed
import re

class Connection(object):
    def __init__(self, config, environment):
        self.config = config
        self.environment = environment

    def _token_header(self):
        return "Token token={0}".format(self.config.access_token)

    def get(self, path, options={}):
        headers = {
            'Authorization': self._token_header(),
            'User-Agent': self._user_agent(),
        }
        response = requests.get(path, headers=headers)
        return response.json()

    def post(self, path, data, options={}):
        headers = {
            'Content-Type': 'application/vnd.api+json',
            'Authorization': self._token_header(),
            'User-Agent': self._user_agent(),
        }
        response = requests.post(path, json=data, headers=headers)
        # TODO(fotinakis): exception handling.
        # response.raise_for_status()
        return response.json()

    def _user_agent(self):
        client = ' '.join(filter(None, [
          "Percy/%s" % self._api_version(),
          "percy-client/%s" % self._client_version(),
        ]))

        environment = '; '.join(filter(None, [
          self._environment_info(),
          "python/%s" % (self._python_version()),
          self.environment.current_ci, # maybe
        ]))

        return "%s (%s)" % (client, environment)

    def _client_version(self):
        import percy
        return percy.__version__

    def _python_version(self):
        from platform import python_version
        return python_version()
<commit_msg>python-percy-client not percy-client<commit_after>import requests
# from IPython import embed
import re

class Connection(object):
    def __init__(self, config, environment):
        self.config = config
        self.environment = environment

    def _token_header(self):
        return "Token token={0}".format(self.config.access_token)

    def get(self, path, options={}):
        headers = {
            'Authorization': self._token_header(),
            'User-Agent': self._user_agent(),
        }
        response = requests.get(path, headers=headers)
        return response.json()

    def post(self, path, data, options={}):
        headers = {
            'Content-Type': 'application/vnd.api+json',
            'Authorization': self._token_header(),
            'User-Agent': self._user_agent(),
        }
        response = requests.post(path, json=data, headers=headers)
        # TODO(fotinakis): exception handling.
        # response.raise_for_status()
        return response.json()

    def _user_agent(self):
        client = ' '.join(filter(None, [
          "Percy/%s" % self._api_version(),
          "python-percy-client/%s" % self._client_version(),
        ]))

        environment = '; '.join(filter(None, [
          self._environment_info(),
          "python/%s" % (self._python_version()),
          self.environment.current_ci, # maybe
        ]))

        return "%s (%s)" % (client, environment)

    def _client_version(self):
        import percy
        return percy.__version__

    def _python_version(self):
        from platform import python_version
        return python_version()

{'fraction_non_alphanumeric': 0.12795031055900621, 'fraction_numerical': 0.0006211180124223603, 'mean_word_length': 2.3657262277951934, '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': '4290622', 'n_tokens_mistral': 907, 'n_tokens_neox': 884, 'n_words': 188}