<commit_before>""" Abstract IO handler """
import os


class IOHandler(object):
    """ Abstract IO handler class """
    path = None

    def __init__(self, path, mode, overwrite=False):
        """
        Perform some checks on the path where we need to operate (read/write).

        :param path: path where IO needs to take place
        :param mode: 'r' for reading, 'w' for writing
        :param overwrite: if writing, overwrite path if it already exists
        """
        self.path = path
        if mode == 'r':
            if not os.path.exists(path):
                raise Exception('{} not found.'.format(path))
        elif mode == 'w':
            path_directory = os.path.dirname(path)
            if not os.path.exists(path_directory):
                raise Exception('Output file path does not exist! --> {}'.format(path))
            if not overwrite:
                if os.path.exists(path):
                    # Raise most specific subclass of FileExistsError (3.6) and IOError (2.7).
                    raise Exception('Output file already exists! --> {}'.format(path))

    def read(self):
        """
        Read the point cloud from disk

        :return point_cloud:
        """
        raise NotImplementedError(
            "Class %s doesn't implement read()" % self.__class__.__name__)

    def write(self, point_cloud):<commit_msg>replace exceptions with specific oserrors in IOHandler<commit_after>""" Abstract IO handler """
import os


class IOHandler(object):
    """ Abstract IO handler class """
    path = None

    def __init__(self, path, mode, overwrite=False):
        """
        Perform some checks on the path where we need to operate (read/write).

        :param path: path where IO needs to take place
        :param mode: 'r' for reading, 'w' for writing
        :param overwrite: if writing, overwrite path if it already exists
        """
        self.path = path
        if mode == 'r':
            if not os.path.exists(path):
                raise FileNotFoundError('{} not found.'.format(path))
        elif mode == 'w':
            path_directory = os.path.dirname(path)
            if not os.path.exists(path_directory):
                raise FileNotFoundError('Output file path does not exist! --> {}'.format(path))
            if not overwrite:
                if os.path.exists(path):
                    # Raise most specific subclass of FileExistsError (3.6) and IOError (2.7).
                    raise FileExistsError('Output file already exists! --> {}'.format(path))

    def read(self):
        """
        Read the point cloud from disk

        :return point_cloud:
        """
        raise NotImplementedError(
            "Class %s doesn't implement read()" % self.__class__.__name__)

    def write(self, point_cloud):
{'fraction_non_alphanumeric': 0.10805008944543829, 'fraction_numerical': 0.0028622540250447226, 'mean_word_length': 2.055737704918033, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4103874', 'n_tokens_mistral': 742, 'n_tokens_neox': 704, 'n_words': 261}