Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1import argparse 

2import os 

3import sys 

4 

5from cfg_checker.common.exception import ConfigException 

6 

7 

8class MyParser(argparse.ArgumentParser): 

9 def error(self, message): 

10 sys.stderr.write('Error: {0}\n\n'.format(message)) 

11 self.print_help() 

12 

13 

14def get_arg(args, str_arg): 

15 _attr = getattr(args, str_arg) 

16 if _attr: 

17 return _attr 

18 else: 

19 _c = args.command if hasattr(args, 'command') else '' 

20 _t = args.type if hasattr(args, 'type') else '' 

21 raise ConfigException( 

22 "Argument '{}' not found executing: mcp-check {} {}".format( 

23 str_arg, 

24 _c, 

25 _t 

26 ) 

27 ) 

28 

29 

30def get_path_arg(path): 

31 if os.path.exists(path): 

32 return path 

33 else: 

34 raise ConfigException("'{}' not exists".format(path)) 

35 

36 

37def get_network_map_type_and_filename(args): 

38 if args.html or args.text: 

39 if args.html and args.text: 

40 raise ConfigException("Multuple report types not supported") 

41 if args.html is not None: 

42 return 'html', args.html 

43 if args.text is not None: 

44 return 'text', args.text 

45 else: 

46 return 'console', None 

47 

48 

49def get_package_report_type_and_filename(args): 

50 if args.html or args.csv: 

51 if args.html and args.csv: 

52 raise ConfigException("Multuple report types not supported") 

53 if args.html is not None: 

54 return 'html', args.html 

55 if args.csv is not None: 

56 return 'csv', args.csv 

57 else: 

58 raise ConfigException("Report type and filename not set")