| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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" % (name, (35 + len(name)) * "=")
37 print " Library: %s" % (cfgDb[name]["lib"])
38 print " Package: %s" % (cfgDb[name]["package"])
39 print "\nProperties:\n%s" % (11 * "-")
40 try:
41 properties = getattr(Configurables, name)(
42 ).getPropertiesWithDescription()
43 except AttributeError:
44 print " Not a configurable component. No properties to show."
45 sys.exit()
46 for label, (value, desc) in sorted(properties.iteritems()):
47 print (" %s\t : %s\t (%s) " % (label, value, str(
48 desc).replace("None", " no description "))).expandtabs(30)
49 sys.exit()