Coverage for lobster/tools/core/report/report.py: 0%

33 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-26 14:55 +0000

1#!/usr/bin/env python3 

2# 

3# LOBSTER - Lightweight Open BMW Software Traceability Evidence Report 

4# Copyright (C) 2023-2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) 

5# 

6# This program is free software: you can redistribute it and/or modify 

7# it under the terms of the GNU Affero General Public License as 

8# published by the Free Software Foundation, either version 3 of the 

9# License, or (at your option) any later version. 

10# 

11# This program is distributed in the hope that it will be useful, but 

12# WITHOUT ANY WARRANTY; without even the implied warranty of 

13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

14# Affero General Public License for more details. 

15# 

16# You should have received a copy of the GNU Affero General Public 

17# License along with this program. If not, see 

18# <https://www.gnu.org/licenses/>. 

19 

20import os 

21import sys 

22import argparse 

23 

24from lobster.exceptions import LOBSTER_Exception 

25from lobster.errors import LOBSTER_Error 

26from lobster.report import Report 

27from lobster.version import get_version 

28 

29 

30ap = argparse.ArgumentParser() 

31 

32 

33@get_version(ap) 

34def main(): 

35 # lobster-trace: core_report_req.Dummy_Requirement 

36 ap.add_argument("--lobster-config", 

37 metavar="FILE", 

38 default="lobster.conf") 

39 ap.add_argument("--out", 

40 metavar="FILE", 

41 default="report.lobster") 

42 

43 options = ap.parse_args() 

44 

45 if not os.path.isfile(options.lobster_config): 

46 print("error: cannot read config file '%s'" % options.lobster_config) 

47 return 1 

48 

49 if os.path.exists(options.out) and not os.path.isfile(options.out): 

50 print("error: cannot write to '%s'" % options.out) 

51 print("error: '%s' exists and is not a file" % options.out) 

52 return 1 

53 

54 report = Report() 

55 

56 try: 

57 report.parse_config(options.lobster_config) 

58 except LOBSTER_Error: 

59 print("lobster: aborting due to earlier errors.") 

60 return 1 

61 except LOBSTER_Exception as err: 

62 print("lobster: aborting due to earlier errors.") 

63 print("lobster: Additional data for debugging:") 

64 err.dump() 

65 return 1 

66 

67 report.write_report(options.out) 

68 return 0 

69 

70 

71if __name__ == "__main__": 

72 sys.exit(main())