<commit_before>import json

from rauth import OAuth2Session

from buffpy.response import ResponseObject

BASE_URL = 'https://api.bufferapp.com/1/%s'
PATHS = {
  'INFO': 'info/configuration.json'
}

class API(object):
  '''
    Small and clean class that embrace all basic
    operations with the buffer app
  '''

  def __init__(self, client_id, client_secret, access_token=None):
    self.session = OAuth2Session( client_id=client_id,
                                  client_secret=client_secret,
                                  access_token=access_token)

  @property
  def access_token(self):
    return self.session.access_token

  @access_token.setter
  def access_token(self, value):
    self.session.access_token = value

  def get(self, url, parser=None):
    if parser == None:
      parser = json.loads

    if not self.session.access_token:
      raise ValueError('Please set an access token first!')

    response = self.session.get(url=BASE_URL % url)

    return parser(response.content)

  def post(self, url, parser=None, **params):
    if parser == None:
      parser = json.loads

    if not self.session.access_token:
      raise ValueError('Please set an access token first!')

    headers = {'Content-Type':'application/x-www-form-urlencoded'}

    response = self.session.post(url=BASE_URL % url, headers=headers, **params)
<commit_msg>replace == None with is None<commit_after>import json

from rauth import OAuth2Session

from buffpy.response import ResponseObject

BASE_URL = 'https://api.bufferapp.com/1/%s'
PATHS = {
  'INFO': 'info/configuration.json'
}

class API(object):
  '''
    Small and clean class that embrace all basic
    operations with the buffer app
  '''

  def __init__(self, client_id, client_secret, access_token=None):
    self.session = OAuth2Session( client_id=client_id,
                                  client_secret=client_secret,
                                  access_token=access_token)

  @property
  def access_token(self):
    return self.session.access_token

  @access_token.setter
  def access_token(self, value):
    self.session.access_token = value

  def get(self, url, parser=None):
    if parser is None:
      parser = json.loads

    if not self.session.access_token:
      raise ValueError('Please set an access token first!')

    response = self.session.get(url=BASE_URL % url)

    return parser(response.content)

  def post(self, url, parser=None, **params):
    if parser is None:
      parser = json.loads

    if not self.session.access_token:
      raise ValueError('Please set an access token first!')

    headers = {'Content-Type':'application/x-www-form-urlencoded'}

    response = self.session.post(url=BASE_URL % url, headers=headers, **params)

{'fraction_non_alphanumeric': 0.10230179028132992, 'fraction_numerical': 0.0021921812203142127, 'mean_word_length': 3.1234939759036147, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '708651', 'n_tokens_mistral': 826, 'n_tokens_neox': 805, 'n_words': 210}