<commit_before># -*- coding: utf-8 -*-
#
# Copyright (c) 2019, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

"""Generate the coverage.rst and coverage.rst files from test results."""

import os
import sys

from docs_common import check_cclib

# Import cclib and check we are using the version from a subdirectory.
import cclib
check_cclib(cclib)


def generate_coverage():
    """Generate a string containing a reStructuredTest table
    representation of which parsers support which attributes, based on
    test results.
    """
    lines = []

    # Change directory to where tests are and add it to the path. Because there are
    # separate directories for different branches/versions, and we use a symlink to
    # point to the one we want, we need to test the real path this link resolves to.
    if "cclib_prod" in os.path.realpath('cclib'):
        testpath = "_build/cclib_prod"
    else:
        assert "cclib_dev" in os.path.realpath('cclib')
        testpath = "_build/cclib_dev"

    os.chdir(testpath)

    thispath = os.path.dirname(os.path.realpath(__file__))
    sys.path.insert(1, thispath)

    from test.test_data import (all_modules, all_parsers, parser_names, DataSuite)
    import inspect
    ds_args = inspect.getargspec(DataSuite.__init__).args
    logpath = thispath + "/coverage.tests.log"
    try:
        with open(logpath, "w") as flog:
            stdout_backup = sys.stdout
            sys.stdout = flog
            alltests = {}
            for p in parser_names:
                assert 'parsers' in ds_args
                suite = DataSuite(parsers={p: all_parsers[p]}, modules=all_modules, stream=flog)
                suite.testall()
                alltests[p] = [{'data': t.data} for t in suite.alltests]
            sys.stdout = stdout_backup
    except Exception as e:<commit_msg>Fix deprecated inspect call<commit_after># -*- coding: utf-8 -*-
#
# Copyright (c) 2019, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

"""Generate the coverage.rst and coverage.rst files from test results."""

import os
import sys

from docs_common import check_cclib

# Import cclib and check we are using the version from a subdirectory.
import cclib
check_cclib(cclib)


def generate_coverage():
    """Generate a string containing a reStructuredTest table
    representation of which parsers support which attributes, based on
    test results.
    """
    lines = []

    # Change directory to where tests are and add it to the path. Because there are
    # separate directories for different branches/versions, and we use a symlink to
    # point to the one we want, we need to test the real path this link resolves to.
    if "cclib_prod" in os.path.realpath('cclib'):
        testpath = "_build/cclib_prod"
    else:
        assert "cclib_dev" in os.path.realpath('cclib')
        testpath = "_build/cclib_dev"

    os.chdir(testpath)

    thispath = os.path.dirname(os.path.realpath(__file__))
    sys.path.insert(1, thispath)

    from test.test_data import (all_modules, all_parsers, parser_names, DataSuite)
    import inspect
    ds_args = inspect.getfullargspec(DataSuite.__init__).args
    logpath = thispath + "/coverage.tests.log"
    try:
        with open(logpath, "w") as flog:
            stdout_backup = sys.stdout
            sys.stdout = flog
            alltests = {}
            for p in parser_names:
                assert 'parsers' in ds_args
                suite = DataSuite(parsers={p: all_parsers[p]}, modules=all_modules, stream=flog)
                suite.testall()
                alltests[p] = [{'data': t.data} for t in suite.alltests]
            sys.stdout = stdout_backup
    except Exception as e:
{'fraction_non_alphanumeric': 0.08996897621509824, 'fraction_numerical': 0.0036194415718717684, 'mean_word_length': 2.800589390962672, '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': '5793930', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1158, 'n_words': 390}