The Gaudi Framework  v30r3 (a5ef0a68)
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(prog=os.path.basename(
13  sys.argv[0]), usage="%prog [options] ")
14  parser.add_option("-l", "--list", action="store_true", dest="list",
15  default=False, help="list all available components.")
16  parser.add_option("-n", "--name", action="store", dest="name",
17  help="dump all info about component of given name.")
18  parser.set_defaults(root=os.path.join("..", "python"))
19  opts, args = parser.parse_args()
20 
21  if len(args) != 0:
22  parser.print_help()
23  sys.exit(1)
24 
25  cfgDb = Configuration.cfgDb
26  if opts.list:
27  print "Available components:\n%s" % (21 * "=")
28  for item in sorted(cfgDb):
29  print " %s (from %s)" % (item, cfgDb[item]["lib"])
30  sys.exit()
31  elif opts.name:
32  name = opts.name
33  if name not in cfgDb:
34  print "Component %s not found." % (name)
35  sys.exit()
36  print "\nDumping component information for %s:\n%s" % (
37  name, (35 + len(name)) * "=")
38  print " Library: %s" % (cfgDb[name]["lib"])
39  print " Package: %s" % (cfgDb[name]["package"])
40  print "\nProperties:\n%s" % (11 * "-")
41  try:
42  properties = getattr(Configurables, name)(
43  ).getPropertiesWithDescription()
44  except AttributeError:
45  print " Not a configurable component. No properties to show."
46  sys.exit()
47  for label, (value, desc) in sorted(properties.iteritems()):
48  print (" %s\t : %s\t (%s) " % (label, value, str(
49  desc).replace("None", " no description "))).expandtabs(30)
50  sys.exit()