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