/opt/cloudlinux/venv/lib/python3.11/site-packages/coverage
NameSizeModeActions
fullcoverage/-0755rm
htmlfiles/-0755rm
__pycache__/-0755rm
annotate.py37580644editdlrm
bytecode.py7130644editdlrm
cmdline.py344270644editdlrm
collector.py205580644editdlrm
config.py219890644editdlrm
context.py24830644editdlrm
control.py517050644editdlrm
data.py75080644editdlrm
debug.py178050644editdlrm
disposition.py19160644editdlrm
env.py60810644editdlrm
exceptions.py13620644editdlrm
execfile.py121330644editdlrm
files.py193740644editdlrm
html.py231650644editdlrm
inorout.py239000644editdlrm
jsonreport.py47540644editdlrm
lcovreport.py49390644editdlrm
misc.py121720644editdlrm
multiproc.py38460644editdlrm
numbits.py46690644editdlrm
parser.py567200644editdlrm
phystokens.py78050644editdlrm
plugin.py195250644editdlrm
plugin_support.py103510644editdlrm
py.typed720644editdlrm
python.py80660644editdlrm
pytracer.py144200644editdlrm
report.py106230644editdlrm
report_core.py40680644editdlrm
results.py133840644editdlrm
sqldata.py512950644editdlrm
templite.py109520644editdlrm
tomlconfig.py75690644editdlrm
tracer.cpython-311-x86_64-linux-gnu.so1103520755editdlrm
types.py55260644editdlrm
version.py14310644editdlrm
xmlreport.py97950644editdlrm
__init__.py12840644editdlrm
__main__.py2570644editdlrm
Edit: /opt/cloudlinux/venv/lib/python3.11/site-packages/coverage/report_core.py (4068B)
# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 # For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt """Reporter foundation for coverage.py.""" from __future__ import annotations import sys from typing import Callable, Iterable, Iterator, IO, Optional, Tuple, TYPE_CHECKING from coverage.exceptions import NoDataError, NotPython from coverage.files import prep_patterns, GlobMatcher from coverage.misc import ensure_dir_for_file, file_be_gone from coverage.plugin import FileReporter from coverage.results import Analysis from coverage.types import Protocol, TMorf if TYPE_CHECKING: from coverage import Coverage class Reporter(Protocol): """What we expect of reporters.""" report_type: str def report(self, morfs: Optional[Iterable[TMorf]], outfile: IO[str]) -> float: """Generate a report of `morfs`, written to `outfile`.""" def render_report( output_path: str, reporter: Reporter, morfs: Optional[Iterable[TMorf]], msgfn: Callable[[str], None], ) -> float: """Run a one-file report generator, managing the output file. This function ensures the output file is ready to be written to. Then writes the report to it. Then closes the file and cleans up. """ file_to_close = None delete_file = False if output_path == "-": outfile = sys.stdout else: # Ensure that the output directory is created; done here because this # report pre-opens the output file. HtmlReporter does this on its own # because its task is more complex, being multiple files. ensure_dir_for_file(output_path) outfile = open(output_path, "w", encoding="utf-8") file_to_close = outfile delete_file = True try: ret = reporter.report(morfs, outfile=outfile) if file_to_close is not None: msgfn(f"Wrote {reporter.report_type} to {output_path}") delete_file = False return ret finally: if file_to_close is not None: file_to_close.close() if delete_file: file_be_gone(output_path) # pragma: part covered (doesn't return) def get_analysis_to_report( coverage: Coverage, morfs: Optional[Iterable[TMorf]], ) -> Iterator[Tuple[FileReporter, Analysis]]: """Get the files to report on. For each morf in `morfs`, if it should be reported on (based on the omit and include configuration options), yield a pair, the `FileReporter` and `Analysis` for the morf. """ file_reporters = coverage._get_file_reporters(morfs) config = coverage.config if config.report_include: matcher = GlobMatcher(prep_patterns(config.report_include), "report_include") file_reporters = [fr for fr in file_reporters if matcher.match(fr.filename)] if config.report_omit: matcher = GlobMatcher(prep_patterns(config.report_omit), "report_omit") file_reporters = [fr for fr in file_reporters if not matcher.match(fr.filename)] if not file_reporters: raise NoDataError("No data to report.") for fr in sorted(file_reporters): try: analysis = coverage._analyze(fr) except NotPython: # Only report errors for .py files, and only if we didn't # explicitly suppress those errors. # NotPython is only raised by PythonFileReporter, which has a # should_be_python() method. if fr.should_be_python(): # type: ignore[attr-defined] if config.ignore_errors: msg = f"Couldn't parse Python file '{fr.filename}'" coverage._warn(msg, slug="couldnt-parse") else: raise except Exception as exc: if config.ignore_errors: msg = f"Couldn't parse '{fr.filename}': {exc}".rstrip() coverage._warn(msg, slug="couldnt-parse") else: raise else: yield (fr, analysis)