Coverage for /usr/local/lib/python3.13/dist-packages/pyrocko/squirrel/tool/commands/info.py: 47%

30 statements  

« prev     ^ index     » next       coverage.py v7.6.0, created at 2025-12-04 10:41 +0000

1# http://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

4# ---|P------/S----------~Lg---------- 

5 

6''' 

7Implementation of :app:`squirrel info`. 

8''' 

9 

10import logging 

11import sys 

12 

13from pyrocko import squirrel as sq 

14from ..common import SquirrelCommand, ldq 

15 

16logger = logging.getLogger('psq.cli.info') 

17 

18headline = 'General information.' 

19 

20description = '''%s 

21 

22Get auxilliary information, e.g. about the supported storage schemes. 

23''' % headline 

24 

25 

26class StorageSchemeInfo(SquirrelCommand): 

27 

28 def make_subparser(self, subparsers): 

29 return subparsers.add_parser( 

30 'storage-scheme', 

31 help='Show information about builtin storage schemes.', 

32 description='Show information about builtin storage schemes.') 

33 

34 def setup(self, parser): 

35 parser.add_argument( 

36 'scheme_name', 

37 nargs='?', 

38 choices=sq.StorageSchemeChoice.choices, 

39 metavar='SCHEME', 

40 help='Show expected characteristics of a builtin storage scheme. ' 

41 'Choices: %s' % ldq( 

42 sq.StorageSchemeChoice.choices)) 

43 

44 def run(self, parser, args): 

45 if not args.scheme_name: 

46 for scheme_name in sq.StorageSchemeChoice.choices: 

47 print(scheme_name) 

48 

49 sys.exit() 

50 

51 scheme = sq.get_storage_scheme(args.scheme_name) 

52 print(scheme) 

53 print(sq.StorageSchemeLayout.describe_header()) 

54 for rate in [ 

55 0.1, 0.5, 1.0, 2.0, 10., 20., 50., 100., 125., 200., 400., 

56 800., 1000., 10000.]: 

57 

58 deltat = 1.0 / rate 

59 layout = scheme.select_layout(deltat) 

60 print(layout.describe(deltat)) 

61 

62 

63def make_subparser(subparsers): 

64 return subparsers.add_parser( 

65 'info', 

66 help=headline, 

67 subcommands=[StorageSchemeInfo()], 

68 description=description) 

69 

70 

71def setup(parser): 

72 pass 

73 

74 

75def run(parser, args): 

76 parser.print_help()