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

17 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-10-06 06:59 +0000

1# http://pyrocko.org - GPLv3 

2# 

3# The Pyrocko Developers, 21st Century 

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

5 

6''' 

7Implementation of :app:`squirrel codes`. 

8''' 

9 

10 

11from pyrocko.squirrel.model import to_kind 

12 

13 

14headline = 'Get summary of available station/channel codes.' 

15 

16 

17def make_subparser(subparsers): 

18 return subparsers.add_parser( 

19 'codes', 

20 help=headline, 

21 description=headline) 

22 

23 

24def setup(parser): 

25 parser.add_squirrel_selection_arguments() 

26 parser.add_squirrel_query_arguments(without=['time', 'tmin', 'tmax']) 

27 

28 

29def run(parser, args): 

30 from pyrocko import squirrel as sq 

31 

32 squirrel = args.make_squirrel() 

33 

34 kwargs = args.squirrel_query 

35 kinds = kwargs.pop('kind', sq.supported_content_kinds()) 

36 codes_query = kwargs.pop('codes', None) 

37 

38 for kind in kinds: 

39 for kind_id, codes, deltat, _, count in sorted( 

40 squirrel._iter_codes_info(kind=kind, codes=codes_query)): 

41 print(to_kind(kind_id), codes, deltat, count)