1# http://pyrocko.org - GPLv3
2#
3# The Pyrocko Developers, 21st Century
4# ---|P------/S----------~Lg----------
6from __future__ import absolute_import, print_function
9guts_prefix = 'squirrel'
12def make_subparser(subparsers):
13 return subparsers.add_parser(
14 'operators',
15 help='Print available operator mappings.')
18def setup(parser):
19 parser.add_squirrel_selection_arguments()
22def run(parser, args):
23 squirrel = args.make_squirrel()
25 def scodes(codes):
26 css = list(zip(*codes))
27 if sum(not all(c == cs[0] for c in cs) for cs in css) == 1:
28 return '.'.join(
29 cs[0] if all(c == cs[0] for c in cs) else '(%s)' % ','.join(cs)
30 for cs in css)
31 else:
32 return ', '.join(str(c) for c in codes)
34 for operator, in_codes, out_codes in squirrel.get_operator_mappings():
35 print('%s <- %s <- %s' % (
36 scodes(out_codes), operator.name, scodes(in_codes)))