Coverage for python/lsst/pex/config/history.py : 55%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # LSST Data Management System # Copyright 2008, 2009, 2010 LSST Corporation. # # This product includes software developed by the # LSST Project (http://www.lsst.org/). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the LSST License Statement and # the GNU General Public License along with this program. If not, # see <http://www.lsstcorp.org/LegalNotices/>. #
"""Control whether strings should be coloured
The usual usage is `Color(string, category)` which returns a string that may be printed; categories are given by the keys of Color.categories
Color.colorize() may be used to set or retrieve whether the user wants colour; it always returns False when sys.stdout is not attached to a terminal. """
NAME="blue", VALUE="yellow", FILE="green", TEXT="red", FUNCTION_NAME="blue", )
"black": 0, "red": 1, "green": 2, "yellow": 3, "blue": 4, "magenta": 5, "cyan": 6, "white": 7, }
"""Return a string that should display as coloured on a conformant terminal""" except KeyError: raise RuntimeError("Unknown category: %s" % category)
props = x.pop(0) if props in ("bold",): bold = True
except KeyError: raise RuntimeError("Unknown colour: %s" % self.color)
self._code += ";1"
"""Should I colour strings? With an argument, set the value
The value is usually a bool, but it may be a dict which is used to modify Color.categories
N.b. only strings written to a terminal are colourized """
unknown = [] for k in val: if k in Color.categories: if val[k] in Color.colors: Color.categories[k] = val[k] else: print("Unknown colour %s for category %s" % (val[k], k), file=sys.stderr) else: unknown.append(k)
if unknown: print("Unknown colourizing category: %s" % " ".join(unknown), file=sys.stderr)
base = "\033["
prefix = base + self._code + "m" suffix = base + "m"
return prefix + self.rawText + suffix
"""Format the history record for config.name"""
for i, name in enumerate(config.history.keys()): if i > 0: print() print(format(config, name))
os.path.split(frame.filename)[1] in ("argparse.py", "argumentParser.py"): if not verbose: continue
line.append(["%s" % ("%s:%d" % (frame.filename, frame.lineno)), "FILE", ])
if False: line.append([frame.function, "FUNCTION_NAME", ])
# # Find the maximum widths of the value and file:lineNo fields # sourceLengths = [] for value, output in outputs: sourceLengths.append(max([len(x[0][0]) for x in output])) sourceLength = max(sourceLengths)
# # actually generate the config history # vt[0][0] = "%-*s" % (sourceLength, vt[0][0])
|