Coverage for pyEDAA/Reports/CodeCoverage/UCIS/PyUCIS.py: 100%
10 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-21 23:49 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-10-21 23:49 +0000
1# ==================================================================================================================== #
2# _____ ____ _ _ ____ _ #
3# _ __ _ _| ____| _ \ / \ / \ | _ \ ___ _ __ ___ _ __| |_ ___ #
4# | '_ \| | | | _| | | | |/ _ \ / _ \ | |_) / _ \ '_ \ / _ \| '__| __/ __| #
5# | |_) | |_| | |___| |_| / ___ \ / ___ \ _| _ < __/ |_) | (_) | | | |_\__ \ #
6# | .__/ \__, |_____|____/_/ \_\/_/ \_(_)_| \_\___| .__/ \___/|_| \__|___/ #
7# |_| |___/ |_| #
8# ==================================================================================================================== #
9# Authors: #
10# Patrick Lehmann #
11# #
12# License: #
13# ==================================================================================================================== #
14# Copyright 2026-2026 Electronic Design Automation Abstraction (EDA²) #
15# #
16# Licensed under the Apache License, Version 2.0 (the "License"); #
17# you may not use this file except in compliance with the License. #
18# You may obtain a copy of the License at #
19# #
20# http://www.apache.org/licenses/LICENSE-2.0 #
21# #
22# Unless required by applicable law or agreed to in writing, software #
23# distributed under the License is distributed on an "AS IS" BASIS, #
24# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
25# See the License for the specific language governing permissions and #
26# limitations under the License. #
27# #
28# SPDX-License-Identifier: Apache-2.0 #
29# ==================================================================================================================== #
30#
31"""
32pyucis' dialect of the UCIS XML interchange format: the elements in no namespace.
34`pyucis <https://github.com/fvutils/pyucis>`__ writes UCIS XML with ``pyucis convert`` and for tools, which use it -
35e.g. PyVSC's ``vsc.write_coverage_db("coverage.xml")``. Its root ``<UCIS>`` binds the prefix ``ucis`` to the XML Schema
36instance namespace, but no element uses it: the elements are in no namespace, not in the namespace ``UCIS`` the
37standard's schema declares. A report is validated against :file:`PyUCIS-1.0.xsd`: the standard's schema without a
38target namespace. The format's model and the conversion to the common model are those of
39:mod:`pyEDAA.Reports.CodeCoverage.UCIS`.
41.. rubric:: Example
43.. code-block:: Python
45 from pathlib import Path
46 from pyEDAA.Reports.CodeCoverage.UCIS.PyUCIS import Document
48 report = Document(Path("coverage.xml"), analyzeAndConvert=True)
49 summary = report.ToCoverageSummary(mergeInstances=True)
50 for file in summary.IterateFiles():
51 print(f"{file.Path}: {file.LineCoverage:.1%}")
52"""
53from __future__ import annotations
55from typing import ClassVar, Optional as Nullable
57from pyTooling.Decorators import export
59from pyEDAA.Reports.CodeCoverage.UCIS import Document as ucis_Document, FormatVersion
62__all__ = ["SCHEMAS"]
64SCHEMAS: dict[FormatVersion, str] = {
65 FormatVersion.Version1_0: "PyUCIS-1.0.xsd"
66} #: Per format version, the XML schema a report of that version is validated against.
69@export
70class Document(ucis_Document):
71 """
72 A UCIS XML code coverage report as pyucis writes it: read into the format's model, and converted to the common
73 model.
74 """
76 _NAMESPACE: ClassVar[Nullable[str]] = None #: The elements are in no namespace.
77 _SCHEMAS: ClassVar[dict[FormatVersion, str]] = SCHEMAS #: Per format version, the XML schema to validate with.