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

26 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2024-07-17 11:40 +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 

11 

12from pyrocko import squirrel as sq 

13from ..common import SquirrelCommand, ldq 

14 

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

16 

17headline = 'General information.' 

18 

19description = '''%s 

20 

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

22''' % headline 

23 

24 

25class StorageSchemeInfo(SquirrelCommand): 

26 

27 def make_subparser(self, subparsers): 

28 return subparsers.add_parser( 

29 'storage-scheme', 

30 help='Show information about a builtin storage scheme.', 

31 description='Show information about a builtin storage scheme.') 

32 

33 def setup(self, parser): 

34 parser.add_argument( 

35 'scheme_name', 

36 choices=sq.StorageSchemeChoice.choices, 

37 metavar='SCHEME', 

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

39 'Choices: %s' % ldq( 

40 sq.StorageSchemeChoice.choices)) 

41 

42 def run(self, parser, args): 

43 scheme = sq.get_storage_scheme(args.scheme_name) 

44 print(scheme) 

45 print(sq.StorageSchemeLayout.describe_header()) 

46 for rate in [ 

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

48 800., 1000., 10000.]: 

49 

50 deltat = 1.0 / rate 

51 layout = scheme.select_layout(deltat) 

52 print(layout.describe(deltat)) 

53 

54 

55def make_subparser(subparsers): 

56 return subparsers.add_parser( 

57 'info', 

58 help=headline, 

59 subcommands=[StorageSchemeInfo()], 

60 description=description) 

61 

62 

63def setup(parser): 

64 pass 

65 

66 

67def run(parser, args): 

68 parser.print_help()