<commit_before>"""Represent KLEE working directories"""
# vim: set sw=4 ts=4 softtabstop=4 expandtab:

import glob
import logging
import os
import re

from .info import Info
from .test import Test
from ..exceptions import InputError

_logger = logging.getLogger(__name__)

class KleeDir:
    """A KLEE working directory"""

    def __init__(self, path: "Path to a KLEE working directory."):
        """
        Open a KLEE working directory.
        """
        _logger.debug('Creating KleeDir from "{}"'.format(path))
        self.path = path
        try:
            self.info = Info(os.path.join(path, "info"))
        except InputError as ie:
            _logger.debug(ie)
            self.info = None

        self._lost_test_cases = 0

        # Note: Tests should be returned in order so that all properties that use
        # it (e.g. `abort_errors`) are also ordered.
        test_files = sorted(glob.glob(os.path.join(glob.escape(path), 'test*.ktest')))
        if self.is_valid:
            # Check the number of test matches what we expect
            if len(test_files) != self.info.tests:
                msg = "Expected {} tests but found {} for KLEE directory \"{}\"".format(
                    self.info.tests,
                    len(test_files),
                    self.path)
                _logger.warning(msg)
                if len(test_files) < self.info.tests:
                    # FIXME: This is a hack around a bug in KLEE
                    # https://github.com/klee/klee/issues/555
                    self._lost_test_cases += 1
                else:
                    # Should never happen
                    raise Exception(msg)
            elif self.info.tests < self.info.completed_paths:<commit_msg>Handle `FileNotFoundError` when trying open KLEE's info file.<commit_after>"""Represent KLEE working directories"""
# vim: set sw=4 ts=4 softtabstop=4 expandtab:

import glob
import logging
import os
import re

from .info import Info
from .test import Test
from ..exceptions import InputError

_logger = logging.getLogger(__name__)

class KleeDir:
    """A KLEE working directory"""

    def __init__(self, path: "Path to a KLEE working directory."):
        """
        Open a KLEE working directory.
        """
        _logger.debug('Creating KleeDir from "{}"'.format(path))
        self.path = path
        try:
            self.info = Info(os.path.join(path, "info"))
        except InputError as ie:
            _logger.debug(ie)
            self.info = None
        except FileNotFoundError as fne:
            _logger.debug(fne)
            _logger.error('Info file not found at \"{}\"'.format(os.path.join(path, "info")))
            self.info = None

        self._lost_test_cases = 0

        # Note: Tests should be returned in order so that all properties that use
        # it (e.g. `abort_errors`) are also ordered.
        test_files = sorted(glob.glob(os.path.join(glob.escape(path), 'test*.ktest')))
        if self.is_valid:
            # Check the number of test matches what we expect
            if len(test_files) != self.info.tests:
                msg = "Expected {} tests but found {} for KLEE directory \"{}\"".format(
                    self.info.tests,
                    len(test_files),
                    self.path)
                _logger.warning(msg)
                if len(test_files) < self.info.tests:
                    # FIXME: This is a hack around a bug in KLEE
                    # https://github.com/klee/klee/issues/555
                    self._lost_test_cases += 1
                else:
                    # Should never happen
                    raise Exception(msg)
            elif self.info.tests < self.info.completed_paths:
{'fraction_non_alphanumeric': 0.10126242277733011, 'fraction_numerical': 0.0042976094547408005, 'mean_word_length': 1.8254931714719271, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '903957', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1017, 'n_words': 310}