<commit_before>import abc
import importlib
import io
import sys
import types
from pathlib import Path, PurePath

from . import data01
from . import zipdata01
from ..abc import ResourceReader
from ._compat import import_helper


from importlib.machinery import ModuleSpec


class Reader(ResourceReader):
    def __init__(self, **kwargs):
        vars(self).update(kwargs)

    def get_resource_reader(self, package):
        return self

    def open_resource(self, path):
        self._path = path
        if isinstance(self.file, Exception):
            raise self.file
        return self.file

    def resource_path(self, path_):
        self._path = path_
        if isinstance(self.path, Exception):
            raise self.path
        return self.path

    def is_resource(self, path_):
        self._path = path_
        if isinstance(self.path, Exception):
            raise self.path

        def part(entry):
            return entry.split('/')

        return any(
            len(parts) == 1 and parts[0] == path_ for parts in map(part, self._contents)
        )

    def contents(self):
        if isinstance(self.path, Exception):
            raise self.path
        yield from self._contents


def create_package(file, path, is_package=True, contents=()):
    name = 'testingpackage'
    module = types.ModuleType(name)
    loader = Reader(file=file, path=path, _contents=contents)
    spec = ModuleSpec(name, loader, origin='does-not-exist', is_package=is_package)
    module.__spec__ = spec
    module.__loader__ = loader
    return module


class CommonTests(metaclass=abc.ABCMeta):
    """
    Tests shared by test_open, test_path, and test_read.
    """
    @abc.abstractmethod<commit_msg>⚫ Fade to black.<commit_after>import abc
import importlib
import io
import sys
import types
from pathlib import Path, PurePath

from . import data01
from . import zipdata01
from ..abc import ResourceReader
from ._compat import import_helper


from importlib.machinery import ModuleSpec


class Reader(ResourceReader):
    def __init__(self, **kwargs):
        vars(self).update(kwargs)

    def get_resource_reader(self, package):
        return self

    def open_resource(self, path):
        self._path = path
        if isinstance(self.file, Exception):
            raise self.file
        return self.file

    def resource_path(self, path_):
        self._path = path_
        if isinstance(self.path, Exception):
            raise self.path
        return self.path

    def is_resource(self, path_):
        self._path = path_
        if isinstance(self.path, Exception):
            raise self.path

        def part(entry):
            return entry.split('/')

        return any(
            len(parts) == 1 and parts[0] == path_ for parts in map(part, self._contents)
        )

    def contents(self):
        if isinstance(self.path, Exception):
            raise self.path
        yield from self._contents


def create_package(file, path, is_package=True, contents=()):
    name = 'testingpackage'
    module = types.ModuleType(name)
    loader = Reader(file=file, path=path, _contents=contents)
    spec = ModuleSpec(name, loader, origin='does-not-exist', is_package=is_package)
    module.__spec__ = spec
    module.__loader__ = loader
    return module


class CommonTests(metaclass=abc.ABCMeta):
    """
    Tests shared by test_open, test_path, and test_read.
    """

    @abc.abstractmethod
{'fraction_non_alphanumeric': 0.09175920514319112, 'fraction_numerical': 0.0035067212156633548, 'mean_word_length': 2.6885775862068964, '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': '3377274', 'n_tokens_mistral': 992, 'n_tokens_neox': 958, 'n_words': 278}