Coverage for .tox/coverage/lib/python3.13/site-packages/wuttjamaican/cli/problems.py: 100%

29 statements  

« prev     ^ index     » next       coverage.py v7.16.1, created at 2026-09-20 15:04 -0500

1# -*- coding: utf-8; -*- 

2################################################################################ 

3# 

4# WuttJamaican -- Base package for Wutta Framework 

5# Copyright © 2023-2026 Lance Edgar 

6# 

7# This file is part of Wutta Framework. 

8# 

9# Wutta Framework is free software: you can redistribute it and/or modify it 

10# under the terms of the GNU General Public License as published by the Free 

11# Software Foundation, either version 3 of the License, or (at your option) any 

12# later version. 

13# 

14# Wutta Framework is distributed in the hope that it will be useful, but 

15# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 

16# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 

17# more details. 

18# 

19# You should have received a copy of the GNU General Public License along with 

20# Wutta Framework. If not, see <http://www.gnu.org/licenses/>. 

21# 

22################################################################################ 

23""" 

24See also: :ref:`wutta-problems` 

25""" 

26 

27import sys 

28from typing import List 

29 

30try: 

31 from typing import Annotated 

32except ImportError: # pragma: no cover 

33 from typing_extensions import Annotated 

34 

35import rich 

36import typer 

37 

38from .base import wutta_typer 

39 

40 

41@wutta_typer.command() 

42def problems( 

43 ctx: typer.Context, 

44 systems: Annotated[ 

45 List[str], 

46 typer.Option( 

47 "--system", 

48 "-s", 

49 help="System for which to perform checks; can be specified more " 

50 "than once. If not specified, all systems are assumed.", 

51 ), 

52 ] = None, 

53 problems: Annotated[ # pylint: disable=redefined-outer-name 

54 List[str], 

55 typer.Option( 

56 "--problem", 

57 "-p", 

58 help="Identify a particular problem check; can be specified " 

59 "more than once. If not specified, all checks are assumed.", 

60 ), 

61 ] = None, 

62 list_checks: Annotated[ 

63 bool, 

64 typer.Option( 

65 "--list", 

66 "-l", 

67 help="List available problem checks; optionally filtered " 

68 "per --system and --problem", 

69 ), 

70 ] = False, 

71): 

72 """ 

73 Find and report on problems with the data or system 

74 """ 

75 config = ctx.parent.wutta_config 

76 app = config.get_app() 

77 handler = app.get_problem_handler() 

78 

79 # try to warn user if unknown system is specified; but otherwise ignore 

80 supported = handler.get_supported_systems() 

81 for key in systems or []: 

82 if key not in supported: 

83 rich.print( 

84 f"\n[bold yellow]No problem reports exist for system: {key}[/bold yellow]" 

85 ) 

86 

87 checks = handler.filter_problem_checks(systems=systems, problems=problems) 

88 

89 if list_checks: 

90 

91 count = 0 

92 organized = handler.organize_problem_checks(checks) 

93 for system in sorted(organized): 

94 rich.print(f"\n[bold]{system}[/bold]") 

95 sys.stdout.write("-------------------------\n") 

96 for problem in sorted(organized[system]): 

97 sys.stdout.write(f"{problem}\n") 

98 count += 1 

99 

100 sys.stdout.write("\n") 

101 sys.stdout.write(f"found {count} problem checks\n") 

102 

103 else: 

104 handler.run_problem_checks(checks)