Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 Gaudi import Configuration
6 import Configurables
7 import os
8 import sys
9 
10 if __name__ == "__main__":
11  from optparse import OptionParser
12  parser = OptionParser(
13  prog=os.path.basename(sys.argv[0]), usage="%prog [options] ")
14  parser.add_option(
15  "-l",
16  "--list",
17  action="store_true",
18  dest="list",
19  default=False,
20  help="list all available components.")
21  parser.add_option(
22  "-n",
23  "--name",
24  action="store",
25  dest="name",
26  help="dump all info about component of given name.")
27  parser.set_defaults(root=os.path.join("..", "python"))
28  opts, args = parser.parse_args()
29 
30  if len(args) != 0:
31  parser.print_help()
32  sys.exit(1)
33 
34  cfgDb = Configuration.cfgDb
35  if opts.list:
36  print "Available components:\n%s" % (21 * "=")
37  for item in sorted(cfgDb):
38  print " %s (from %s)" % (item, cfgDb[item]["lib"])
39  sys.exit()
40  elif opts.name:
41  name = opts.name
42  if name not in cfgDb:
43  print "Component %s not found." % (name)
44  sys.exit()
45  print "\nDumping component information for %s:\n%s" % (
46  name, (35 + len(name)) * "=")
47  print " Library: %s" % (cfgDb[name]["lib"])
48  print " Package: %s" % (cfgDb[name]["package"])
49  print "\nProperties:\n%s" % (11 * "-")
50  try:
51  properties = getattr(Configurables,
52  name)().getPropertiesWithDescription()
53  except AttributeError:
54  print " Not a configurable component. No properties to show."
55  sys.exit()
56  for label, (value, desc) in sorted(properties.iteritems()):
57  print(" %s\t : %s\t (%s) " % (label, value, str(desc).replace(
58  "None", " no description "))).expandtabs(30)
59  sys.exit()