lsst.meas.algorithms  14.0-8-gf6dacf9e
printers.py
Go to the documentation of this file.
1 from __future__ import print_function
2 from builtins import object
3 import gdb
4 import re
5 import sys
6 
7 try:
8  import gdb.printing
9 
10  class CRPixelPrinter(object):
11  "Print a CRPixel"
12 
13  def __init__(self, val):
14  self.val = val
15 
16  def to_string(self):
17  return "{id=%d (%d, %d)}" % (self.val["id"], self.val["col"], self.val["row"])
18 
19  printers = []
20 
21  def register(obj):
22  "Register my pretty-printers with objfile Obj."
23 
24  if obj is None:
25  obj = gdb
26 
27  for p in printers:
28  gdb.printing.register_pretty_printer(obj, p)
29 
30  #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
31 
33  printer = gdb.printing.RegexpCollectionPrettyPrinter("meas_algorithms")
34 
35  printer.add_printer('lsst::meas::algorithms::CRPixel',
36  '^lsst::meas::algorithms::CRPixel', CRPixelPrinter)
37  return printer
38 
39  printers.append(build_meas_algorithms_dictionary())
40 
41 except ImportError as e:
42  def register(*args, **kwargs):
43  print("Your version of gdb is too old to load the meas.algorithms python pretty printers: %s" % (
44  e), file=sys.stderr)
45  pass
46 
47  pass