<commit_before>from servicenow import Utils

class Base(object):
    __table__ = None

    def __init__(self, Connection):
        self.Connection = Connection

    @Utils.cached()
    def fetch_all(self, params):
        return self.Connection._get(self.__table__, params).json()

    @Utils.cached()
    def fetch_one(self, params):
        return self.Connection._get(self.__table__, params).json()['records'][0]

    def create(self, params):
        return self.Connection._post(self.__table__, params).json()

    def update(self, where, params):
        return self.Connection._update(self.__table__, where, params).json()

    def delete(self, params):
        return self.Connection._delete(self.__table__, params).json()

class Server(Base):
    __table__ = 'cmdb_ci_server.do'

class Incident(Base):
    __table__ = 'incident.do'<commit_msg>fixing IndexError when fetch_one is empty<commit_after>from servicenow import Utils

class Base(object):
    __table__ = None

    def __init__(self, Connection):
        self.Connection = Connection

    @Utils.cached()
    def fetch_all(self, params):
        return self.Connection._get(self.__table__, params).json()

    @Utils.cached()
    def fetch_one(self, params):
        try:
            return self.Connection._get(self.__table__, params).json()['records'][0]
        except IndexError:
            return []

    def create(self, params):
        return self.Connection._post(self.__table__, params).json()

    def update(self, where, params):
        return self.Connection._update(self.__table__, where, params).json()

    def delete(self, params):
        return self.Connection._delete(self.__table__, params).json()

class Server(Base):
    __table__ = 'cmdb_ci_server.do'

class Incident(Base):
    __table__ = 'incident.do'
{'fraction_non_alphanumeric': 0.12235817575083426, 'fraction_numerical': 0.0011123470522803114, 'mean_word_length': 3.3771289537712894, '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': '1838387', 'n_tokens_mistral': 530, 'n_tokens_neox': 517, 'n_words': 118}