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