Coverage for sphinx_reports/Common.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-05-09 22:12 +0000

1# ==================================================================================================================== # 

2# _ _ _ # 

3# ___ _ __ | |__ (_)_ __ __ __ _ __ ___ _ __ ___ _ __| |_ ___ # 

4# / __| '_ \| '_ \| | '_ \\ \/ /____| '__/ _ \ '_ \ / _ \| '__| __/ __| # 

5# \__ \ |_) | | | | | | | |> <_____| | | __/ |_) | (_) | | | |_\__ \ # 

6# |___/ .__/|_| |_|_|_| |_/_/\_\ |_| \___| .__/ \___/|_| \__|___/ # 

7# |_| |_| # 

8# ==================================================================================================================== # 

9# Authors: # 

10# Patrick Lehmann # 

11# # 

12# License: # 

13# ==================================================================================================================== # 

14# Copyright 2023-2025 Patrick Lehmann - Bötzingen, Germany # 

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""" 

32**Common exceptions, classes and helper functions.** 

33""" 

34from enum import Flag 

35from sys import version_info 

36from typing import List 

37 

38from pyTooling.Decorators import export 

39from sphinx.errors import ExtensionError 

40 

41 

42@export 

43class ReportExtensionError(ExtensionError): 

44 # WORKAROUND: for Python <3.11 

45 # Implementing a dummy method for Python versions before 

46 __notes__: List[str] 

47 if version_info < (3, 11): # pragma: no cover 

48 def add_note(self, message: str) -> None: 

49 try: 

50 self.__notes__.append(message) 

51 except AttributeError: 

52 self.__notes__ = [message] 

53 

54 

55@export 

56class LegendStyle(Flag): 

57 Default = 0 

58 Table = 1 

59 

60 Horizontal = 1024 

61 Vertical = 2048 

62 

63 horizontal_table = Table | Horizontal 

64 vertical_table = Table | Vertical