LSSTApplications  8.0.0.0+107,8.0.0.1+13,9.1+18,9.2,master-g084aeec0a4,master-g0aced2eed8+6,master-g15627eb03c,master-g28afc54ef9,master-g3391ba5ea0,master-g3d0fb8ae5f,master-g4432ae2e89+36,master-g5c3c32f3ec+17,master-g60f1e072bb+1,master-g6a3ac32d1b,master-g76a88a4307+1,master-g7bce1f4e06+57,master-g8ff4092549+31,master-g98e65bf68e,master-ga6b77976b1+53,master-gae20e2b580+3,master-gb584cd3397+53,master-gc5448b162b+1,master-gc54cf9771d,master-gc69578ece6+1,master-gcbf758c456+22,master-gcec1da163f+63,master-gcf15f11bcc,master-gd167108223,master-gf44c96c709
LSSTDataManagementBasePackage
Classes | Functions
lsst.pex.config.history Namespace Reference

Classes

class  Color
 
class  StackFrame
 

Functions

def _colorize
 
def format
 

Function Documentation

def lsst.pex.config.history._colorize (   text,
  category 
)
private

Definition at line 110 of file history.py.

111 def _colorize(text, category):
112  text = Color(text, category)
113  return str(text)
114 
115 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
def lsst.pex.config.history.format (   config,
  name = None,
  writeSourceLine = True,
  prefix = "",
  verbose = False 
)
Format the history record for config.name
Examples:
spatialCellExample.cc.

Definition at line 127 of file history.py.

128 def format(config, name=None, writeSourceLine=True, prefix="", verbose=False):
129  """Format the history record for config.name"""
130 
131  if name is None:
132  for i, name in enumerate(config.history.keys()):
133  if i > 0:
134  print
135  print format(config, name)
136 
137  outputs = []
138  for value, tb, label in config.history[name]:
139  output = []
140  for frame in [StackFrame(t) for t in tb]:
141  if frame.functionName in ("__new__", "__set__", "__setattr__", "execfile", "wrapper") or \
142  os.path.split(frame.fileName)[1] in ("argparse.py", "argumentParser.py"):
143  if not verbose:
144  continue
145 
146  line = []
147  if writeSourceLine:
148  line.append(["%s" % ("%s:%d" % (frame.fileName, frame.lineNumber)), "FILE",])
149 
150  line.append([frame.text, "TEXT",])
151  if False:
152  line.append([frame.functionName, "FUNCTION_NAME",])
153 
154  output.append(line)
155 
156  outputs.append([value, output])
157  #
158  # Find the maximum widths of the value and file:lineNo fields
159  #
160  if writeSourceLine:
161  sourceLengths = []
162  for value, output in outputs:
163  sourceLengths.append(max([len(x[0][0]) for x in output]))
164 
165  sourceLength = max(sourceLengths)
166  valueLength = len(prefix) + max([len(str(value)) for value, output in outputs])
167  #
168  # actually generate the config history
169  #
170  msg = []
171  fullname = "%s.%s" %(config._name, name) if config._name is not None else name
172  msg.append(_colorize(re.sub(r"^root\.", "", fullname), "NAME"))
173  for value, output in outputs:
174  line = prefix + _colorize("%-*s" % (valueLength, value), "VALUE") + " "
175  for i, vt in enumerate(output):
176  if writeSourceLine:
177  vt[0][0] = "%-*s" % (sourceLength, vt[0][0])
178 
179  output[i] = " ".join([_colorize(v, t) for v, t in vt])
180 
181  line += ("\n%*s" % (valueLength + 1, "")).join(output)
182  msg.append(line)
183 
184  return "\n".join(msg)
185 
double max
Definition: attributes.cc:218