The Gaudi Framework  v32r2 (46d42edc)
gaudiComponentHelp.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """
3 Print help messages for gaudi components
4 """
5 from __future__ import print_function
6 from Gaudi import Configuration
7 import Configurables
8 import os
9 import sys
10 
11 if __name__ == "__main__":
12  from optparse import OptionParser
13  parser = OptionParser(
14  prog=os.path.basename(sys.argv[0]), usage="%prog [options] ")
15  parser.add_option(
16  "-l",
17  "--list",
18  action="store_true",
19  dest="list",
20  default=False,
21  help="list all available components.")
22  parser.add_option(
23  "-n",
24  "--name",
25  action="store",
26  dest="name",
27  help="dump all info about component of given name.")
28  parser.set_defaults(root=os.path.join("..", "python"))
29  opts, args = parser.parse_args()
30 
31  if len(args) != 0:
32  parser.print_help()
33  sys.exit(1)
34 
35  cfgDb = Configuration.cfgDb
36  if opts.list:
37  print("Available components:\n%s" % (21 * "="))
38  for item in sorted(cfgDb):
39  print(" %s (from %s)" % (item, cfgDb[item]["lib"]))
40  sys.exit()
41  elif opts.name:
42  name = opts.name
43  if name not in cfgDb:
44  print("Component %s not found." % (name))
45  sys.exit()
46  print("\nDumping component information for %s:\n%s" %
47  (name, (35 + len(name)) * "="))
48  print(" Library: %s" % (cfgDb[name]["lib"]))
49  print(" Package: %s" % (cfgDb[name]["package"]))
50  print("\nProperties:\n%s" % (11 * "-"))
51  try:
52  properties = getattr(Configurables,
53  name)().getPropertiesWithDescription()
54  except AttributeError:
55  print(" Not a configurable component. No properties to show.")
56  sys.exit()
57  for label, (value, desc) in sorted(properties.iteritems()):
58  print((" %s\t : %s\t (%s) " % (label, value, str(desc).replace(
59  "None", " no description "))).expandtabs(30))
60  sys.exit()