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