LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Classes | Public Member Functions | Static Public Attributes | List of all members
lsst.gdb.afw.printers.GdbOptionParser Class Reference
Inheritance diagram for lsst.gdb.afw.printers.GdbOptionParser:

Classes

class  AxesPrinter
 
class  BackgroundControlPrinter
 
class  BackgroundPrinter
 
class  BaseSourceAttributesPrinter
 
class  Box2Printer
 
class  CitizenPrinter
 
class  CoordinateBasePrinter
 
class  DetectorPrinter
 
class  EigenMatrixPrinter
 
class  EigenVectorPrinter
 
class  ExposurePrinter
 
class  FootprintPrinter
 
class  FootprintSetPrinter
 
class  GilPixelPrinter
 
class  ImagePrinter
 
class  KernelPrinter
 
class  MaskedImagePrinter
 
class  PeakPrinter
 
class  PrintCitizenCommand
 
class  PrintEigenCommand
 
class  PrintImageCommand
 
class  PsfPrinter
 
class  QuadrupolePrinter
 
class  SharedPtrPrinter
 
class  SourcePrinter
 
class  StatisticsControlPrinter
 
class  TablePrinter
 
class  TableSchemaPrinter
 

Public Member Functions

def __init__
 
def parse_args
 
def exit
 
def getEigenMatrixDimensions
 
def getEigenValue
 
def register
 
def build_boost_dictionary
 
def build_eigen_dictionary
 
def build_afw_dictionary
 
def build_daf_base_dictionary
 

Static Public Attributes

list printers = []
 

Detailed Description

A subclass of the standard optparse OptionParser for gdb

GdbOptionParser raises GdbError rather than exiting when asked for help, or
when given an illegal value. E.g.

parser = gdb.printing.GdbOptionParser("show image")
parser.add_option("-a", "--all", action="store_true",
              help="Display the whole image")
parser.add_option("-w", "--width", type="int", default=8,
              help="Field width for pixels")

opts, args =  parser.parse_args(args)

Definition at line 12 of file printers.py.

Constructor & Destructor Documentation

def lsst.gdb.afw.printers.GdbOptionParser.__init__ (   self,
  prog,
  args,
  kwargs 
)
Like optparse.OptionParser's API, but with an initial command name argument

Definition at line 27 of file printers.py.

27 
28  def __init__(self, prog, *args, **kwargs):
29  """
30 Like optparse.OptionParser's API, but with an initial command name argument
31 """
32  # OptionParser is an old-style class, so no super
33  if not kwargs.get("prog"):
34  kwargs["prog"] = prog
35  optparse.OptionParser.__init__(self, *args, **kwargs)

Member Function Documentation

def lsst.gdb.afw.printers.GdbOptionParser.build_afw_dictionary ( )

Definition at line 818 of file printers.py.

819  def build_afw_dictionary():
820  printer = gdb.printing.RegexpCollectionPrettyPrinter("afw")
821 
822  printer.add_printer('lsst::afw::cameraGeom::Detector',
823  '^lsst::afw::cameraGeom::(Amp|Ccd|Detector|DetectorMosaic)$', DetectorPrinter)
824 
825  printer.add_printer('lsst::afw::detection::Footprint',
826  '^lsst::afw::detection::Footprint$', FootprintPrinter)
827  printer.add_printer('lsst::afw::detection::FootprintSet',
828  '^lsst::afw::detection::FootprintSet', FootprintSetPrinter)
829  printer.add_printer('lsst::afw::detection::Peak',
830  '^lsst::afw::detection::Peak$', PeakPrinter)
831  printer.add_printer('lsst::afw::detection::Psf',
832  '^lsst::afw::detection::Psf$', PsfPrinter)
833  printer.add_printer('lsst::afw::detection::Source',
834  '^lsst::afw::detection::Source$', SourcePrinter)
835  printer.add_printer('lsst::afw::detection::BaseSourceAttributes',
836  '^lsst::afw::detection::BaseSourceAttributes$', BaseSourceAttributesPrinter)
837 
838  printer.add_printer('lsst::afw::geom::Box',
839  '^lsst::afw::geom::Box', Box2Printer)
840  printer.add_printer('lsst::afw::geom::Extent',
841  '^lsst::afw::geom::Extent', CoordinateBasePrinter)
842  printer.add_printer('lsst::afw::geom::Point',
843  '^lsst::afw::geom::Point', CoordinateBasePrinter)
844 
845  printer.add_printer('lsst::afw::geom::ellipses::Axes',
846  '^lsst::afw::geom::ellipses::Axes', AxesPrinter)
847  printer.add_printer('lsst::afw::geom::ellipses::Quadrupole',
848  '^lsst::afw::geom::ellipses::Quadrupole', QuadrupolePrinter)
849 
850  printer.add_printer('lsst::afw::image::ImageBase',
851  'lsst::afw::image::ImageBase<[^>]+>$', ImagePrinter)
852  printer.add_printer('lsst::afw::image::Image',
853  'lsst::afw::image::Image<[^>]+>$', ImagePrinter)
854  printer.add_printer('lsst::afw::image::Mask',
855  '^lsst::afw::image::Mask<[^>]+>$', ImagePrinter)
856  printer.add_printer('lsst::afw::image::MaskedImage',
857  '^lsst::afw::image::MaskedImage<[^>]+>$', MaskedImagePrinter)
858  printer.add_printer('lsst::afw::image::Exposure',
859  '^lsst::afw::image::Exposure', ExposurePrinter)
860 
861  printer.add_printer('lsst::afw::math::Background',
862  '^lsst::afw::math::Background$', BackgroundPrinter)
863  printer.add_printer('lsst::afw::math::BackgroundControl',
864  '^lsst::afw::math::BackgroundControl$', BackgroundControlPrinter)
865  printer.add_printer('lsst::afw::math::Kernel',
866  '^lsst::afw::math::.*Kernel', KernelPrinter)
867  printer.add_printer('lsst::afw::math::StatisticsControl',
868  '^lsst::afw::math::StatisticsControl', StatisticsControlPrinter)
869 
870  printer.add_printer('lsst::afw::table::Table',
871  '^lsst::afw::table::.*Table$', TablePrinter)
872  printer.add_printer('lsst::afw::table::Schema',
873  '^lsst::afw::table::Schema$', TableSchemaPrinter)
874 
875  return printer
def lsst.gdb.afw.printers.GdbOptionParser.build_boost_dictionary ( )
Surely this must be somewhere standard?

Definition at line 788 of file printers.py.

790  """Surely this must be somewhere standard?"""
791 
792  printer = gdb.printing.RegexpCollectionPrettyPrinter("rhl-boost")
793 
794  printer.add_printer('boost::shared_ptr',
795  '^(boost|tr1|std)::shared_ptr', SharedPtrPrinter)
796  printer.add_printer('boost::gil::pixel',
797  'boost::gil::.*pixel_t', GilPixelPrinter)
798 
799  return printer
def lsst.gdb.afw.printers.GdbOptionParser.build_daf_base_dictionary ( )

Definition at line 878 of file printers.py.

880  printer = gdb.printing.RegexpCollectionPrettyPrinter("daf::base")
881 
882  printer.add_printer('lsst::daf::base::Citizen',
883  'lsst::daf::base::Citizen', CitizenPrinter)
884 
885  return printer
def lsst.gdb.afw.printers.GdbOptionParser.build_eigen_dictionary ( )
Surely this must be somewhere standard?

Definition at line 802 of file printers.py.

804  """Surely this must be somewhere standard?"""
805 
806  printer = gdb.printing.RegexpCollectionPrettyPrinter("rhl-eigen")
807 
808  printer.add_printer('eigen::Matrix',
809  '^Eigen::Matrix', EigenMatrixPrinter)
810  printer.add_printer('eigen::Vector',
811  '^Eigen::Vector', EigenVectorPrinter)
812 
813  return printer
def lsst.gdb.afw.printers.GdbOptionParser.exit (   self,
  status = 0,
  msg = "" 
)
Raise GdbError rather than exiting

Definition at line 53 of file printers.py.

53 
54  def exit(self, status=0, msg=""):
55  """Raise GdbError rather than exiting"""
56  if status == 0:
57  if msg:
58  print >> sys.stderr, msg
59  else:
60  raise gdb.GdbError(msg)
61 
try:
def lsst.gdb.afw.printers.GdbOptionParser.getEigenMatrixDimensions (   val)

Definition at line 88 of file printers.py.

88 
89  def getEigenMatrixDimensions(val):
90  m_storage = val["m_storage"]
91  try:
92  nx, ny = m_storage["m_cols"], m_storage["m_rows"]
93  except gdb.error: # only available for dynamic Matrices
94  try:
95  nx, ny = val.type.template_argument(1), val.type.template_argument(2)
96  except RuntimeError:
97  # should get dimens from template, but that's gdb bug #11060
98  size = m_storage["m_data"]["array"].type.sizeof
99  size0 = m_storage["m_data"]["array"].dereference().type.sizeof
100  # guess! Assume square
101  nx = int(math.sqrt(size/size0))
102  ny = size/(nx*size0)
103 
104  return nx, ny
def lsst.gdb.afw.printers.GdbOptionParser.getEigenValue (   var,
  x,
  y = 0 
)

Definition at line 105 of file printers.py.

106  def getEigenValue(var, x, y=0):
107  if re.search(r"Matrix", str(var.type)):
108  if False:
109  return var["operator()(int, int)"](x, y)
110 
111  NX, NY = getEigenMatrixDimensions(var)
112 
113  if x < 0 or x >= NX or y < 0 or y >= NY:
114  raise gdb.GdbError("Element (%d, %d) is out of range 0:%d, 0:%d" %
115  (x, y, NX - 1, NY - 1))
116 
117  m_data = var["m_storage"]["m_data"]
118  if False:
119  # convert to a pointer to the start of the array
120  import pdb; pdb.set_trace()
121  m_data = m_data.address.cast(m_data.type)
122 
123  try:
124  val = m_data[x + y*NX]
125  except:
126  val = m_data["array"][x + y*NX]
127  else: # Vector
128  if False:
129  return var["operator()(int)"](x)
130 
131  NX = getEigenMatrixDimensions(var)[0]
132 
133  if x < 0 or x >= NX:
134  raise gdb.GdbError("Element (%d) is out of range 0:%d" % (x, NX - 1))
135 
136  m_data = var["m_storage"]["m_data"]
137 
138  if False:
139  # convert to a pointer to the start of the array
140  m_data = m_data.address.cast(m_data.type)
141 
142  try:
143  val = m_data[x]
144  except:
145  val = m_data["array"][x]
146 
147  if val.type.code == gdb.TYPE_CODE_INT:
148  val = int(val)
149  elif val.type.code == gdb.TYPE_CODE_FLT:
150  val = float(val)
151 
152  return val
def lsst.gdb.afw.printers.GdbOptionParser.parse_args (   self,
  args,
  values = None 
)
Call OptionParser.parse_args after running gdb.string_to_argv

Definition at line 36 of file printers.py.

36 
37  def parse_args(self, args, values=None):
38  """Call OptionParser.parse_args after running gdb.string_to_argv"""
39  if args is None: # defaults to sys.argv
40  args = ""
41  try:
42  args = gdb.string_to_argv(args)
43  except TypeError:
44  pass
45 
46  help = ("-h" in args or "--help" in args)
47  opts, args = optparse.OptionParser.parse_args(self, args, values)
48  opts.help = help
49  if help:
50  args = []
51 
52  return opts, args
def lsst.gdb.afw.printers.GdbOptionParser.register (   obj = None)

Definition at line 777 of file printers.py.

778  def register(obj=None):
779  "Register my pretty-printers with objfile Obj."
780 
781  if obj is None:
782  obj = gdb
783 
784  for p in printers:
785  gdb.printing.register_pretty_printer(obj, p, replace=True)

Member Data Documentation

list lsst.gdb.afw.printers.GdbOptionParser.printers = []
static

Definition at line 775 of file printers.py.


The documentation for this class was generated from the following file: