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